summaryrefslogtreecommitdiff
path: root/src/lib/libssl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl')
-rw-r--r--src/lib/libssl/LICENSE2
-rw-r--r--src/lib/libssl/Makefile.bsd-wrapper4
-rw-r--r--src/lib/libssl/bio_ssl.c8
-rw-r--r--src/lib/libssl/crypto/Makefile2
-rw-r--r--src/lib/libssl/doc/openssl.cnf13
-rw-r--r--src/lib/libssl/doc/standards.txt19
-rw-r--r--src/lib/libssl/s23_clnt.c17
-rw-r--r--src/lib/libssl/s23_lib.c6
-rw-r--r--src/lib/libssl/s23_srvr.c181
-rw-r--r--src/lib/libssl/s3_both.c74
-rw-r--r--src/lib/libssl/s3_clnt.c389
-rw-r--r--src/lib/libssl/s3_lib.c403
-rw-r--r--src/lib/libssl/s3_pkt.c181
-rw-r--r--src/lib/libssl/s3_srvr.c388
-rw-r--r--src/lib/libssl/src/CHANGES1964
-rw-r--r--src/lib/libssl/src/Configure776
-rw-r--r--src/lib/libssl/src/FAQ139
-rw-r--r--src/lib/libssl/src/INSTALL19
-rw-r--r--src/lib/libssl/src/INSTALL.MacOS16
-rw-r--r--src/lib/libssl/src/INSTALL.OS222
-rw-r--r--src/lib/libssl/src/INSTALL.VMS12
-rw-r--r--src/lib/libssl/src/INSTALL.W3252
-rw-r--r--src/lib/libssl/src/LICENSE2
-rw-r--r--src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp4
-rw-r--r--src/lib/libssl/src/Makefile.org354
-rw-r--r--src/lib/libssl/src/NEWS55
-rw-r--r--src/lib/libssl/src/README24
-rw-r--r--src/lib/libssl/src/README.ASN1187
-rw-r--r--src/lib/libssl/src/README.ENGINE302
-rw-r--r--src/lib/libssl/src/STATUS114
-rw-r--r--src/lib/libssl/src/TABLE3912
-rw-r--r--src/lib/libssl/src/VMS/mkshared.com353
-rw-r--r--src/lib/libssl/src/apps/CA.pl11
-rw-r--r--src/lib/libssl/src/apps/CA.pl.in11
-rw-r--r--src/lib/libssl/src/apps/Makefile.ssl1245
-rw-r--r--src/lib/libssl/src/apps/app_rand.c21
-rw-r--r--src/lib/libssl/src/apps/apps.c641
-rw-r--r--src/lib/libssl/src/apps/apps.h139
-rw-r--r--src/lib/libssl/src/apps/asn1pars.c6
-rw-r--r--src/lib/libssl/src/apps/ca.c1616
-rw-r--r--src/lib/libssl/src/apps/ciphers.c19
-rw-r--r--src/lib/libssl/src/apps/crl.c29
-rw-r--r--src/lib/libssl/src/apps/crl2p7.c6
-rw-r--r--src/lib/libssl/src/apps/dgst.c68
-rw-r--r--src/lib/libssl/src/apps/dh.c27
-rw-r--r--src/lib/libssl/src/apps/dhparam.c43
-rw-r--r--src/lib/libssl/src/apps/dsa.c36
-rw-r--r--src/lib/libssl/src/apps/dsaparam.c23
-rw-r--r--src/lib/libssl/src/apps/enc.c137
-rw-r--r--src/lib/libssl/src/apps/engine.c520
-rw-r--r--src/lib/libssl/src/apps/errstr.c3
-rw-r--r--src/lib/libssl/src/apps/gendh.c27
-rw-r--r--src/lib/libssl/src/apps/gendsa.c49
-rw-r--r--src/lib/libssl/src/apps/genrsa.c58
-rw-r--r--src/lib/libssl/src/apps/makeapps.com41
-rw-r--r--src/lib/libssl/src/apps/nseq.c2
-rw-r--r--src/lib/libssl/src/apps/ocsp.c1211
-rw-r--r--src/lib/libssl/src/apps/openssl.c199
-rw-r--r--src/lib/libssl/src/apps/openssl.cnf13
-rw-r--r--src/lib/libssl/src/apps/passwd.c90
-rw-r--r--src/lib/libssl/src/apps/pkcs12.c105
-rw-r--r--src/lib/libssl/src/apps/pkcs7.c25
-rw-r--r--src/lib/libssl/src/apps/pkcs8.c45
-rw-r--r--src/lib/libssl/src/apps/progs.h154
-rw-r--r--src/lib/libssl/src/apps/progs.pl30
-rw-r--r--src/lib/libssl/src/apps/rand.c82
-rw-r--r--src/lib/libssl/src/apps/req.c705
-rw-r--r--src/lib/libssl/src/apps/rsa.c127
-rw-r--r--src/lib/libssl/src/apps/rsautl.c45
-rw-r--r--src/lib/libssl/src/apps/s_apps.h67
-rw-r--r--src/lib/libssl/src/apps/s_cb.c313
-rw-r--r--src/lib/libssl/src/apps/s_client.c186
-rw-r--r--src/lib/libssl/src/apps/s_server.c270
-rw-r--r--src/lib/libssl/src/apps/s_socket.c34
-rw-r--r--src/lib/libssl/src/apps/s_time.c67
-rw-r--r--src/lib/libssl/src/apps/sess_id.c5
-rw-r--r--src/lib/libssl/src/apps/smime.c141
-rw-r--r--src/lib/libssl/src/apps/speed.c1121
-rw-r--r--src/lib/libssl/src/apps/spkac.c54
-rw-r--r--src/lib/libssl/src/apps/testdsa.h72
-rw-r--r--src/lib/libssl/src/apps/verify.c82
-rw-r--r--src/lib/libssl/src/apps/version.c88
-rw-r--r--src/lib/libssl/src/apps/x509.c203
-rw-r--r--src/lib/libssl/src/bugs/stream.c2
-rw-r--r--src/lib/libssl/src/certs/RegTP-4R.pem19
-rw-r--r--src/lib/libssl/src/certs/RegTP-5R.pem19
-rw-r--r--src/lib/libssl/src/certs/RegTP-6R.pem19
-rw-r--r--src/lib/libssl/src/certs/expired/rsa-ssca.pem19
-rw-r--r--src/lib/libssl/src/config293
-rw-r--r--src/lib/libssl/src/crypto/Makefile.ssl139
-rw-r--r--src/lib/libssl/src/crypto/aes/Makefile.ssl103
-rw-r--r--src/lib/libssl/src/crypto/aes/README3
-rw-r--r--src/lib/libssl/src/crypto/aes/aes.h109
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_cbc.c89
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_cfb.c151
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_core.c1251
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ctr.c117
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ecb.c67
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_locl.h88
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_misc.c64
-rw-r--r--src/lib/libssl/src/crypto/aes/aes_ofb.c136
-rw-r--r--src/lib/libssl/src/crypto/asn1/Makefile.ssl1752
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bitstr.c53
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bool.c4
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bytes.c15
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_d2i_fp.c69
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_digest.c24
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_dup.c28
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_enum.c58
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_gentm.c35
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_i2d_fp.c54
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_int.c64
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_object.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_octet.c24
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_print.c70
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_set.c3
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_sign.c152
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strex.c32
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_strnid.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_time.c79
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_type.c275
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_utctm.c70
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_utf8.c27
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_verify.c58
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1.h770
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_err.c206
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_lib.c3
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1_mac.h35
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1t.h846
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn_moid.c95
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn_pack.c48
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_pr.c16
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_pu.c16
-rw-r--r--src/lib/libssl/src/crypto/asn1/f_int.c8
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_pr.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_pu.c10
-rw-r--r--src/lib/libssl/src/crypto/asn1/n_pkey.c305
-rw-r--r--src/lib/libssl/src/crypto/asn1/nsseq.c64
-rw-r--r--src/lib/libssl/src/crypto/asn1/p5_pbe.c47
-rw-r--r--src/lib/libssl/src/crypto/asn1/p5_pbev2.c109
-rw-r--r--src/lib/libssl/src/crypto/asn1/p8_pkey.c79
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_crl.c49
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_pkey.c44
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_req.c50
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_spki.c6
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509.c295
-rw-r--r--src/lib/libssl/src/crypto/asn1/t_x509a.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_dec.c958
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_enc.c497
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_fre.c226
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_new.c348
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_prn.c198
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_typ.c133
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_utl.c253
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_algor.c165
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_attrib.c111
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_bignum.c137
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_crl.c330
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_exten.c190
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_info.c2
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_long.c169
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_name.c343
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_pubkey.c80
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_req.c231
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_sig.c53
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_spki.c109
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_val.c52
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_x509.c155
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_x509a.c75
-rw-r--r--src/lib/libssl/src/crypto/bf/Makefile.ssl27
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_opts.c6
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_skey.c2
-rw-r--r--src/lib/libssl/src/crypto/bf/bfspeed.c6
-rw-r--r--src/lib/libssl/src/crypto/bf/bftest.c2
-rw-r--r--src/lib/libssl/src/crypto/bf/blowfish.h8
-rw-r--r--src/lib/libssl/src/crypto/bio/Makefile.ssl174
-rw-r--r--src/lib/libssl/src/crypto/bio/b_print.c6
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c66
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_buff.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_lbuf.c12
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_nbio.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bf_null.c1
-rw-r--r--src/lib/libssl/src/crypto/bio/bio.h33
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_cb.c2
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_err.c5
-rw-r--r--src/lib/libssl/src/crypto/bio/bio_lib.c19
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_acpt.c18
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_bio.c10
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_conn.c15
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_fd.c226
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_file.c18
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_log.c19
-rw-r--r--src/lib/libssl/src/crypto/bio/bss_sock.c131
-rw-r--r--src/lib/libssl/src/crypto/bn/Makefile.ssl276
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/README4
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/bn-586.pl213
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/ia64.S1498
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/vms.mar697
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.h177
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_add.c12
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_asm.c22
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_ctx.c13
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_div.c66
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_err.c11
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_exp.c149
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_exp2.c27
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_gcd.c338
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_kron.c182
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lcl.h39
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_lib.c336
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mod.c296
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mont.c63
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mpi.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mul.c503
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_prime.c29
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_print.c6
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_rand.c94
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_recp.c48
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_shift.c8
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_sqr.c18
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_sqrt.c387
-rw-r--r--src/lib/libssl/src/crypto/bn/bnspeed.c4
-rw-r--r--src/lib/libssl/src/crypto/bn/bntest.c261
-rw-r--r--src/lib/libssl/src/crypto/bn/expspeed.c176
-rw-r--r--src/lib/libssl/src/crypto/bn/exptest.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/vms-helper.c2
-rw-r--r--src/lib/libssl/src/crypto/buffer/Makefile.ssl21
-rw-r--r--src/lib/libssl/src/crypto/buffer/buf_err.c4
-rw-r--r--src/lib/libssl/src/crypto/buffer/buffer.c3
-rw-r--r--src/lib/libssl/src/crypto/buffer/buffer.h4
-rw-r--r--src/lib/libssl/src/crypto/cast/Makefile.ssl26
-rw-r--r--src/lib/libssl/src/crypto/cast/cast.h2
-rw-r--r--src/lib/libssl/src/crypto/cast/cast_lcl.h12
-rw-r--r--src/lib/libssl/src/crypto/cast/cast_spd.c6
-rw-r--r--src/lib/libssl/src/crypto/cast/castopts.c6
-rw-r--r--src/lib/libssl/src/crypto/cast/casttest.c2
-rw-r--r--src/lib/libssl/src/crypto/comp/Makefile.ssl46
-rw-r--r--src/lib/libssl/src/crypto/comp/c_rle.c1
-rw-r--r--src/lib/libssl/src/crypto/comp/c_zlib.c141
-rw-r--r--src/lib/libssl/src/crypto/comp/comp.h4
-rw-r--r--src/lib/libssl/src/crypto/comp/comp_err.c4
-rw-r--r--src/lib/libssl/src/crypto/conf/Makefile.ssl90
-rw-r--r--src/lib/libssl/src/crypto/conf/README78
-rw-r--r--src/lib/libssl/src/crypto/conf/cnf_save.c7
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.c730
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.h111
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_api.c49
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_api.h12
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_def.c62
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_def.h143
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_err.c18
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_lib.c158
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_mall.c76
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_mod.c616
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_sap.c107
-rw-r--r--src/lib/libssl/src/crypto/conf/keysets.pl62
-rw-r--r--src/lib/libssl/src/crypto/cpt_err.c9
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.c19
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.h4
-rw-r--r--src/lib/libssl/src/crypto/crypto-lib.com115
-rw-r--r--src/lib/libssl/src/crypto/crypto.h110
-rw-r--r--src/lib/libssl/src/crypto/cversion.c8
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.ssl267
-rw-r--r--src/lib/libssl/src/crypto/des/asm/crypt586.pl8
-rw-r--r--src/lib/libssl/src/crypto/des/asm/des-586.pl26
-rw-r--r--src/lib/libssl/src/crypto/des/asm/des686.pl20
-rw-r--r--src/lib/libssl/src/crypto/des/asm/desboth.pl8
-rw-r--r--src/lib/libssl/src/crypto/des/cbc3_enc.c52
-rw-r--r--src/lib/libssl/src/crypto/des/cbc_cksm.c8
-rw-r--r--src/lib/libssl/src/crypto/des/cfb64ede.c17
-rw-r--r--src/lib/libssl/src/crypto/des/cfb64enc.c10
-rw-r--r--src/lib/libssl/src/crypto/des/cfb_enc.c8
-rw-r--r--src/lib/libssl/src/crypto/des/des-lib.com4
-rw-r--r--src/lib/libssl/src/crypto/des/des.c112
-rw-r--r--src/lib/libssl/src/crypto/des/des.h290
-rw-r--r--src/lib/libssl/src/crypto/des/des_enc.c53
-rw-r--r--src/lib/libssl/src/crypto/des/des_locl.h79
-rw-r--r--src/lib/libssl/src/crypto/des/des_old.c271
-rw-r--r--src/lib/libssl/src/crypto/des/des_old.h437
-rw-r--r--src/lib/libssl/src/crypto/des/des_old2.c82
-rw-r--r--src/lib/libssl/src/crypto/des/des_opts.c212
-rw-r--r--src/lib/libssl/src/crypto/des/des_ver.h6
-rw-r--r--src/lib/libssl/src/crypto/des/destest.c103
-rw-r--r--src/lib/libssl/src/crypto/des/ecb3_enc.c9
-rw-r--r--src/lib/libssl/src/crypto/des/ecb_enc.c10
-rw-r--r--src/lib/libssl/src/crypto/des/ede_cbcm_enc.c24
-rw-r--r--src/lib/libssl/src/crypto/des/enc_read.c28
-rw-r--r--src/lib/libssl/src/crypto/des/enc_writ.c16
-rw-r--r--src/lib/libssl/src/crypto/des/fcrypt.c81
-rw-r--r--src/lib/libssl/src/crypto/des/fcrypt_b.c6
-rw-r--r--src/lib/libssl/src/crypto/des/ncbc_enc.c20
-rw-r--r--src/lib/libssl/src/crypto/des/ofb64ede.c21
-rw-r--r--src/lib/libssl/src/crypto/des/ofb64enc.c10
-rw-r--r--src/lib/libssl/src/crypto/des/ofb_enc.c7
-rw-r--r--src/lib/libssl/src/crypto/des/pcbc_enc.c9
-rw-r--r--src/lib/libssl/src/crypto/des/qud_cksm.c4
-rw-r--r--src/lib/libssl/src/crypto/des/rand_key.c13
-rw-r--r--src/lib/libssl/src/crypto/des/read2pwd.c69
-rw-r--r--src/lib/libssl/src/crypto/des/read_pwd.c62
-rw-r--r--src/lib/libssl/src/crypto/des/rpc_enc.c12
-rw-r--r--src/lib/libssl/src/crypto/des/rpw.c2
-rw-r--r--src/lib/libssl/src/crypto/des/set_key.c43
-rw-r--r--src/lib/libssl/src/crypto/des/speed.c54
-rw-r--r--src/lib/libssl/src/crypto/des/spr.h2
-rw-r--r--src/lib/libssl/src/crypto/des/str2key.c54
-rw-r--r--src/lib/libssl/src/crypto/des/xcbc_enc.c19
-rw-r--r--src/lib/libssl/src/crypto/dh/Makefile.ssl109
-rw-r--r--src/lib/libssl/src/crypto/dh/dh.h60
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_asn1.c87
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_check.c2
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_err.c9
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_gen.c32
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_key.c59
-rw-r--r--src/lib/libssl/src/crypto/dh/dh_lib.c150
-rw-r--r--src/lib/libssl/src/crypto/dh/dhtest.c30
-rw-r--r--src/lib/libssl/src/crypto/dsa/Makefile.ssl167
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa.h85
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_asn1.c200
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_err.c7
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_gen.c18
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_key.c3
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_lib.c151
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_ossl.c11
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_sign.c4
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa_vrf.c4
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsatest.c17
-rw-r--r--src/lib/libssl/src/crypto/dso/Makefile.ssl71
-rw-r--r--src/lib/libssl/src/crypto/dso/README24
-rw-r--r--src/lib/libssl/src/crypto/dso/dso.h168
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_dl.c112
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_dlfcn.c97
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_err.c23
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_lib.c179
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_vms.c82
-rw-r--r--src/lib/libssl/src/crypto/dso/dso_win32.c112
-rw-r--r--src/lib/libssl/src/crypto/ebcdic.c3
-rw-r--r--src/lib/libssl/src/crypto/ec/Makefile.ssl128
-rw-r--r--src/lib/libssl/src/crypto/ec/ec.h245
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_cvt.c80
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_err.c151
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_lcl.h277
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_lib.c646
-rw-r--r--src/lib/libssl/src/crypto/ec/ec_mult.c473
-rw-r--r--src/lib/libssl/src/crypto/ec/ecp_mont.c304
-rw-r--r--src/lib/libssl/src/crypto/ec/ecp_nist.c134
-rw-r--r--src/lib/libssl/src/crypto/ec/ecp_recp.c133
-rw-r--r--src/lib/libssl/src/crypto/ec/ecp_smpl.c1717
-rw-r--r--src/lib/libssl/src/crypto/ec/ectest.c634
-rw-r--r--src/lib/libssl/src/crypto/engine/Makefile.ssl507
-rw-r--r--src/lib/libssl/src/crypto/engine/README483
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_all.c118
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_cnf.c242
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_ctrl.c387
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_dyn.c446
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_err.c165
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_fat.c148
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_init.c158
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_int.h185
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_lib.c321
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_list.c383
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_openssl.c347
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_pkey.c157
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_table.c361
-rw-r--r--src/lib/libssl/src/crypto/engine/engine.h653
-rw-r--r--src/lib/libssl/src/crypto/engine/enginetest.c45
-rw-r--r--src/lib/libssl/src/crypto/engine/hw.ec8
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_4758_cca.c950
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_4758_cca_err.c149
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_4758_cca_err.h93
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_aep.c1101
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_aep_err.c157
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_aep_err.h101
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_atalla.c283
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_atalla_err.c145
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_atalla_err.h89
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cryptodev.c926
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cswift.c322
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cswift_err.c149
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cswift_err.h93
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher.c662
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher_err.c156
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ncipher_err.h100
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_nuron.c399
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_nuron_err.c142
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_nuron_err.h86
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_openbsd_dev_crypto.c594
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_sureware_err.c150
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_sureware_err.h94
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ubsec.c1041
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ubsec_err.c151
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_ubsec_err.h95
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_cipher.c145
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_dh.c120
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_digest.c145
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_dsa.c120
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_rand.c120
-rw-r--r--src/lib/libssl/src/crypto/engine/tb_rsa.c120
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/aep.h178
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/atalla.h13
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/cswift.h45
-rw-r--r--src/lib/libssl/src/crypto/engine/vendor_defns/hw_4758_cca.h149
-rw-r--r--src/lib/libssl/src/crypto/err/Makefile.ssl57
-rw-r--r--src/lib/libssl/src/crypto/err/err.c615
-rw-r--r--src/lib/libssl/src/crypto/err/err.h183
-rw-r--r--src/lib/libssl/src/crypto/err/err_all.c49
-rw-r--r--src/lib/libssl/src/crypto/err/err_prn.c46
-rw-r--r--src/lib/libssl/src/crypto/err/openssl.ec31
-rw-r--r--src/lib/libssl/src/crypto/evp/Makefile.ssl1129
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_b64.c5
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_enc.c20
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_md.c30
-rw-r--r--src/lib/libssl/src/crypto/evp/bio_ok.c52
-rw-r--r--src/lib/libssl/src/crypto/evp/c_all.c12
-rw-r--r--src/lib/libssl/src/crypto/evp/c_allc.c30
-rw-r--r--src/lib/libssl/src/crypto/evp/c_alld.c18
-rw-r--r--src/lib/libssl/src/crypto/evp/digest.c254
-rw-r--r--src/lib/libssl/src/crypto/evp/e_aes.c99
-rw-r--r--src/lib/libssl/src/crypto/evp/e_bf.c14
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cast.c16
-rw-r--r--src/lib/libssl/src/crypto/evp/e_des.c21
-rw-r--r--src/lib/libssl/src/crypto/evp/e_des3.c88
-rw-r--r--src/lib/libssl/src/crypto/evp/e_idea.c22
-rw-r--r--src/lib/libssl/src/crypto/evp/e_null.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/e_rc2.c67
-rw-r--r--src/lib/libssl/src/crypto/evp/e_rc4.c37
-rw-r--r--src/lib/libssl/src/crypto/evp/e_rc5.c65
-rw-r--r--src/lib/libssl/src/crypto/evp/e_xcbc_d.c39
-rw-r--r--src/lib/libssl/src/crypto/evp/encode.c7
-rw-r--r--src/lib/libssl/src/crypto/evp/evp.h502
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_acnf.c74
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_enc.c290
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_err.c11
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_key.c39
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_locl.h125
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_pbe.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_pkey.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/evp_test.c365
-rw-r--r--src/lib/libssl/src/crypto/evp/evptests.txt82
-rw-r--r--src/lib/libssl/src/crypto/evp/m_dss.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/m_dss1.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/m_md2.c25
-rw-r--r--src/lib/libssl/src/crypto/evp/m_md4.c27
-rw-r--r--src/lib/libssl/src/crypto/evp/m_md5.c25
-rw-r--r--src/lib/libssl/src/crypto/evp/m_mdc2.c25
-rw-r--r--src/lib/libssl/src/crypto/evp/m_null.c25
-rw-r--r--src/lib/libssl/src/crypto/evp/m_ripemd.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/m_sha.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/m_sha1.c24
-rw-r--r--src/lib/libssl/src/crypto/evp/names.c4
-rw-r--r--src/lib/libssl/src/crypto/evp/openbsd_hw.c446
-rw-r--r--src/lib/libssl/src/crypto/evp/p5_crpt.c40
-rw-r--r--src/lib/libssl/src/crypto/evp/p5_crpt2.c14
-rw-r--r--src/lib/libssl/src/crypto/evp/p_dec.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/p_enc.c6
-rw-r--r--src/lib/libssl/src/crypto/evp/p_lib.c46
-rw-r--r--src/lib/libssl/src/crypto/evp/p_open.c14
-rw-r--r--src/lib/libssl/src/crypto/evp/p_seal.c17
-rw-r--r--src/lib/libssl/src/crypto/evp/p_sign.c8
-rw-r--r--src/lib/libssl/src/crypto/evp/p_verify.c6
-rw-r--r--src/lib/libssl/src/crypto/ex_data.c615
-rw-r--r--src/lib/libssl/src/crypto/hmac/Makefile.ssl25
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmac.c51
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmac.h12
-rw-r--r--src/lib/libssl/src/crypto/hmac/hmactest.c3
-rw-r--r--src/lib/libssl/src/crypto/idea/Makefile.ssl16
-rw-r--r--src/lib/libssl/src/crypto/idea/idea.h2
-rw-r--r--src/lib/libssl/src/crypto/install.com17
-rw-r--r--src/lib/libssl/src/crypto/krb5/Makefile.ssl90
-rw-r--r--src/lib/libssl/src/crypto/krb5/krb5_asn.c167
-rw-r--r--src/lib/libssl/src/crypto/krb5/krb5_asn.h256
-rw-r--r--src/lib/libssl/src/crypto/lhash/Makefile.ssl17
-rw-r--r--src/lib/libssl/src/crypto/lhash/lh_stats.c22
-rw-r--r--src/lib/libssl/src/crypto/lhash/lh_test.c1
-rw-r--r--src/lib/libssl/src/crypto/lhash/lhash.c63
-rw-r--r--src/lib/libssl/src/crypto/lhash/lhash.h92
-rw-r--r--src/lib/libssl/src/crypto/md2/Makefile.ssl16
-rw-r--r--src/lib/libssl/src/crypto/md2/md2.h8
-rw-r--r--src/lib/libssl/src/crypto/md2/md2_dgst.c13
-rw-r--r--src/lib/libssl/src/crypto/md2/md2test.c9
-rw-r--r--src/lib/libssl/src/crypto/md32_common.h22
-rw-r--r--src/lib/libssl/src/crypto/md4/Makefile.ssl15
-rw-r--r--src/lib/libssl/src/crypto/md4/md4.h14
-rw-r--r--src/lib/libssl/src/crypto/md4/md4_dgst.c3
-rw-r--r--src/lib/libssl/src/crypto/md4/md4_locl.h2
-rw-r--r--src/lib/libssl/src/crypto/md4/md4test.c7
-rw-r--r--src/lib/libssl/src/crypto/md5/Makefile.ssl11
-rw-r--r--src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S8
-rw-r--r--src/lib/libssl/src/crypto/md5/md5.h12
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_dgst.c3
-rw-r--r--src/lib/libssl/src/crypto/md5/md5_locl.h6
-rw-r--r--src/lib/libssl/src/crypto/md5/md5test.c7
-rw-r--r--src/lib/libssl/src/crypto/mdc2/Makefile.ssl27
-rw-r--r--src/lib/libssl/src/crypto/mdc2/mdc2.h10
-rw-r--r--src/lib/libssl/src/crypto/mem.c127
-rw-r--r--src/lib/libssl/src/crypto/mem_dbg.c80
-rw-r--r--src/lib/libssl/src/crypto/o_time.c203
-rw-r--r--src/lib/libssl/src/crypto/o_time.h66
-rw-r--r--src/lib/libssl/src/crypto/objects/Makefile.ssl57
-rw-r--r--src/lib/libssl/src/crypto/objects/o_names.c147
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.c46
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.h2842
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_dat.pl13
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_err.c4
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_lib.c7
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_mac.h593
-rw-r--r--src/lib/libssl/src/crypto/objects/obj_mac.num121
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.h64
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.pl17
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.txt211
-rw-r--r--src/lib/libssl/src/crypto/ocsp/Makefile.ssl221
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp.h619
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_asn.c182
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_cl.c370
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_err.c139
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_ext.c528
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_ht.c164
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_lib.c261
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_prn.c291
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_srv.c264
-rw-r--r--src/lib/libssl/src/crypto/ocsp/ocsp_vfy.c444
-rw-r--r--src/lib/libssl/src/crypto/opensslconf.h.in7
-rw-r--r--src/lib/libssl/src/crypto/opensslv.h22
-rw-r--r--src/lib/libssl/src/crypto/ossl_typ.h120
-rw-r--r--src/lib/libssl/src/crypto/pem/Makefile.ssl268
-rw-r--r--src/lib/libssl/src/crypto/pem/pem.h33
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_all.c23
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_err.c4
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_info.c14
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_lib.c278
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_oth.c85
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_pk8.c243
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_pkey.c139
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_seal.c31
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_sign.c2
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_x509.c69
-rw-r--r--src/lib/libssl/src/crypto/pem/pem_xaux.c68
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86unix.pl83
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/Makefile.ssl477
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_add.c87
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_asn.c125
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_attr.c155
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_crpt.c10
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_crt.c6
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_decr.c69
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_init.c8
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_key.c16
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_kiss.c10
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_mutl.c15
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_npas.c10
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_p8d.c68
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_p8e.c97
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/p12_utl.c40
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/pk12err.c4
-rw-r--r--src/lib/libssl/src/crypto/pkcs12/pkcs12.h125
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/Makefile.ssl199
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/bio_ber.c6
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/enc.c2
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/example.c1
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_asn1.c213
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_attr.c60
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_doit.c161
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_lib.c22
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pk7_smime.c25
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7.h104
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7err.c5
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/sign.c8
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/verify.c8
-rw-r--r--src/lib/libssl/src/crypto/rand/Makefile.ssl118
-rw-r--r--src/lib/libssl/src/crypto/rand/md_rand.c53
-rw-r--r--src/lib/libssl/src/crypto/rand/rand.h30
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_egd.c240
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_err.c5
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lcl.h60
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lib.c82
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_os2.c147
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_unix.c274
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_vms.c135
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_win.c63
-rw-r--r--src/lib/libssl/src/crypto/rand/randfile.c26
-rw-r--r--src/lib/libssl/src/crypto/rand/randtest.c9
-rw-r--r--src/lib/libssl/src/crypto/rc2/Makefile.ssl16
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2.h2
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2speed.c6
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2test.c2
-rw-r--r--src/lib/libssl/src/crypto/rc4/Makefile.ssl10
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4.c4
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4.h2
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4speed.c6
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4test.c2
-rw-r--r--src/lib/libssl/src/crypto/rc5/Makefile.ssl16
-rw-r--r--src/lib/libssl/src/crypto/rc5/rc5.h2
-rw-r--r--src/lib/libssl/src/crypto/rijndael/Makefile.ssl89
-rw-r--r--src/lib/libssl/src/crypto/rijndael/README80
-rw-r--r--src/lib/libssl/src/crypto/rijndael/rd_fst.c1400
-rw-r--r--src/lib/libssl/src/crypto/rijndael/rd_fst.h42
-rw-r--r--src/lib/libssl/src/crypto/rijndael/rijndael.h7
-rw-r--r--src/lib/libssl/src/crypto/ripemd/Makefile.ssl13
-rw-r--r--src/lib/libssl/src/crypto/ripemd/ripemd.h14
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_dgst.c3
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmd_locl.h4
-rw-r--r--src/lib/libssl/src/crypto/ripemd/rmdtest.c9
-rw-r--r--src/lib/libssl/src/crypto/rsa/Makefile.ssl224
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa.h150
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_asn1.c121
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_chk.c2
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_eay.c114
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_err.c5
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_lib.c175
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_none.c8
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_null.c23
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_oaep.c300
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_pk1.c12
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_saos.c14
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_sign.c30
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_ssl.c10
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_test.c14
-rw-r--r--src/lib/libssl/src/crypto/sha/Makefile.ssl20
-rw-r--r--src/lib/libssl/src/crypto/sha/sha.h24
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1_one.c2
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1dgst.c2
-rw-r--r--src/lib/libssl/src/crypto/sha/sha1test.c16
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_dgst.c2
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_locl.h5
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_one.c2
-rw-r--r--src/lib/libssl/src/crypto/sha/shatest.c16
-rw-r--r--src/lib/libssl/src/crypto/stack/Makefile.ssl12
-rw-r--r--src/lib/libssl/src/crypto/stack/safestack.h378
-rw-r--r--src/lib/libssl/src/crypto/stack/stack.c14
-rw-r--r--src/lib/libssl/src/crypto/symhacks.h131
-rw-r--r--src/lib/libssl/src/crypto/threads/mttest.c8
-rw-r--r--src/lib/libssl/src/crypto/threads/th-lock.c6
-rw-r--r--src/lib/libssl/src/crypto/tmdiff.c44
-rw-r--r--src/lib/libssl/src/crypto/txt_db/Makefile.ssl12
-rw-r--r--src/lib/libssl/src/crypto/txt_db/txt_db.c8
-rw-r--r--src/lib/libssl/src/crypto/txt_db/txt_db.h6
-rw-r--r--src/lib/libssl/src/crypto/ui/Makefile.ssl117
-rw-r--r--src/lib/libssl/src/crypto/ui/ui.h387
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_compat.c67
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_compat.h83
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_err.c111
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c899
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_locl.h148
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_openssl.c661
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_util.c86
-rw-r--r--src/lib/libssl/src/crypto/uid.c7
-rw-r--r--src/lib/libssl/src/crypto/x509/Makefile.ssl647
-rw-r--r--src/lib/libssl/src/crypto/x509/by_file.c4
-rw-r--r--src/lib/libssl/src/crypto/x509/x509.h321
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_att.c26
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_cmp.c37
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_d2.c2
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_err.c8
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_ext.c19
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_lu.c40
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_obj.c1
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_req.c16
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_trs.c29
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_txt.c10
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_v3.c9
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.c347
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_vfy.h67
-rw-r--r--src/lib/libssl/src/crypto/x509/x509cset.c169
-rw-r--r--src/lib/libssl/src/crypto/x509/x509spki.c1
-rw-r--r--src/lib/libssl/src/crypto/x509/x_all.c203
-rw-r--r--src/lib/libssl/src/crypto/x509v3/Makefile.ssl602
-rw-r--r--src/lib/libssl/src/crypto/x509v3/ext_dat.h16
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_akey.c71
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_akeya.c72
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_alt.c112
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_bcons.c58
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_bitst.c1
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_conf.c395
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_cpols.c328
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_crld.c181
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_enum.c12
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_extku.c132
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_genn.c264
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_info.c126
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_int.c11
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_lib.c80
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_ocsp.c272
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_pku.c61
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_prn.c80
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_purp.c104
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_skey.c15
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_sxnet.c112
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_utl.c45
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3conf.c1
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3err.c9
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3prin.c2
-rw-r--r--src/lib/libssl/src/crypto/x509v3/x509v3.h274
-rw-r--r--src/lib/libssl/src/demos/asn1/README.ASN17
-rw-r--r--src/lib/libssl/src/demos/asn1/ocsp.c366
-rw-r--r--src/lib/libssl/src/demos/b64.c4
-rw-r--r--src/lib/libssl/src/demos/easy_tls/Makefile123
-rw-r--r--src/lib/libssl/src/demos/easy_tls/README65
-rw-r--r--src/lib/libssl/src/demos/easy_tls/cacerts.pem18
-rw-r--r--src/lib/libssl/src/demos/easy_tls/cert.pem31
-rw-r--r--src/lib/libssl/src/demos/easy_tls/easy-tls.c1235
-rw-r--r--src/lib/libssl/src/demos/easy_tls/easy-tls.h57
-rw-r--r--src/lib/libssl/src/demos/easy_tls/test.c244
-rw-r--r--src/lib/libssl/src/demos/easy_tls/test.h11
-rw-r--r--src/lib/libssl/src/demos/maurice/example1.c8
-rw-r--r--src/lib/libssl/src/demos/maurice/example3.c6
-rw-r--r--src/lib/libssl/src/demos/maurice/loadkeys.c9
-rw-r--r--src/lib/libssl/src/demos/pkcs12/README3
-rw-r--r--src/lib/libssl/src/demos/pkcs12/pkread.c61
-rw-r--r--src/lib/libssl/src/demos/pkcs12/pkwrite.c46
-rw-r--r--src/lib/libssl/src/demos/sign/sign.c4
-rw-r--r--src/lib/libssl/src/demos/ssl/cli.cpp4
-rw-r--r--src/lib/libssl/src/demos/ssl/inetdsrv.cpp4
-rw-r--r--src/lib/libssl/src/demos/ssl/serv.cpp4
-rw-r--r--src/lib/libssl/src/demos/state_machine/Makefile9
-rw-r--r--src/lib/libssl/src/demos/state_machine/state_machine.c416
-rw-r--r--src/lib/libssl/src/demos/tunala/A-client.pem84
-rw-r--r--src/lib/libssl/src/demos/tunala/A-server.pem84
-rw-r--r--src/lib/libssl/src/demos/tunala/CA.pem24
-rw-r--r--src/lib/libssl/src/demos/tunala/INSTALL107
-rw-r--r--src/lib/libssl/src/demos/tunala/Makefile41
-rw-r--r--src/lib/libssl/src/demos/tunala/Makefile.am7
-rw-r--r--src/lib/libssl/src/demos/tunala/README233
-rw-r--r--src/lib/libssl/src/demos/tunala/autogunk.sh25
-rw-r--r--src/lib/libssl/src/demos/tunala/autoungunk.sh18
-rw-r--r--src/lib/libssl/src/demos/tunala/breakage.c66
-rw-r--r--src/lib/libssl/src/demos/tunala/buffer.c205
-rw-r--r--src/lib/libssl/src/demos/tunala/cb.c133
-rw-r--r--src/lib/libssl/src/demos/tunala/configure.in28
-rw-r--r--src/lib/libssl/src/demos/tunala/ip.c146
-rw-r--r--src/lib/libssl/src/demos/tunala/sm.c151
-rw-r--r--src/lib/libssl/src/demos/tunala/tunala.c1093
-rw-r--r--src/lib/libssl/src/demos/tunala/tunala.h214
-rw-r--r--src/lib/libssl/src/demos/x509/README3
-rw-r--r--src/lib/libssl/src/demos/x509/mkcert.c168
-rw-r--r--src/lib/libssl/src/demos/x509/mkreq.c157
-rw-r--r--src/lib/libssl/src/doc/HOWTO/certificates.txt85
-rw-r--r--src/lib/libssl/src/doc/apps/CA.pl.pod5
-rw-r--r--src/lib/libssl/src/doc/apps/ca.pod133
-rw-r--r--src/lib/libssl/src/doc/apps/enc.pod16
-rw-r--r--src/lib/libssl/src/doc/apps/ocsp.pod348
-rw-r--r--src/lib/libssl/src/doc/apps/openssl.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/passwd.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs12.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/pkcs7.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/rand.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/req.pod59
-rw-r--r--src/lib/libssl/src/doc/apps/rsa.pod2
-rw-r--r--src/lib/libssl/src/doc/apps/s_client.pod25
-rw-r--r--src/lib/libssl/src/doc/apps/s_server.pod28
-rw-r--r--src/lib/libssl/src/doc/apps/verify.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/version.pod8
-rw-r--r--src/lib/libssl/src/doc/apps/x509.pod122
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_f_md.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod7
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_accept.pod31
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_connect.pod34
-rw-r--r--src/lib/libssl/src/doc/crypto/BIO_s_socket.pod12
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_add.pod89
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_bn2bin.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod20
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_rand.pod5
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_swap.pod23
-rw-r--r--src/lib/libssl/src/doc/crypto/BN_zero.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/DH_set_method.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/DSA_set_method.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/ERR_get_error.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod67
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod119
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod289
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_SignInit.pod39
-rw-r--r--src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod36
-rw-r--r--src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod29
-rw-r--r--src/lib/libssl/src/doc/crypto/RAND_egd.pod18
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_generate_key.pod2
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/RSA_set_method.pod26
-rw-r--r--src/lib/libssl/src/doc/crypto/blowfish.pod4
-rw-r--r--src/lib/libssl/src/doc/crypto/bn.pod17
-rw-r--r--src/lib/libssl/src/doc/crypto/bn_internal.pod19
-rw-r--r--src/lib/libssl/src/doc/crypto/crypto.pod3
-rw-r--r--src/lib/libssl/src/doc/crypto/des.pod324
-rw-r--r--src/lib/libssl/src/doc/crypto/hmac.pod31
-rw-r--r--src/lib/libssl/src/doc/crypto/lhash.pod196
-rw-r--r--src/lib/libssl/src/doc/crypto/pem.pod476
-rw-r--r--src/lib/libssl/src/doc/crypto/rsa.pod1
-rw-r--r--src/lib/libssl/src/doc/crypto/threads.pod6
-rw-r--r--src/lib/libssl/src/doc/crypto/ui.pod194
-rw-r--r--src/lib/libssl/src/doc/crypto/ui_compat.pod55
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod70
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod34
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod4
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod57
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod75
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod24
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod90
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod150
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod153
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod97
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod89
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod63
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod170
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod166
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod14
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod32
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_accept.pod5
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod228
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_clear.pod22
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_connect.pod5
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod26
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod3
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod41
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_error.pod8
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod2
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_get_session.pod12
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_new.pod1
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_read.pod25
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod59
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_session_reused.pod45
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod23
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_session.pod13
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod6
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_shutdown.pod67
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_state_string.pod45
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_want.pod77
-rw-r--r--src/lib/libssl/src/doc/ssl/SSL_write.pod16
-rw-r--r--src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod14
-rw-r--r--src/lib/libssl/src/doc/ssl/ssl.pod39
-rw-r--r--src/lib/libssl/src/doc/ssleay.txt16
-rw-r--r--src/lib/libssl/src/doc/standards.txt19
-rw-r--r--src/lib/libssl/src/e_os.h208
-rw-r--r--src/lib/libssl/src/e_os2.h235
-rw-r--r--src/lib/libssl/src/install.com2
-rw-r--r--src/lib/libssl/src/makevms.com100
-rw-r--r--src/lib/libssl/src/ms/32all.bat5
-rw-r--r--src/lib/libssl/src/ms/testss.bat2
-rw-r--r--src/lib/libssl/src/openssl.spec37
-rw-r--r--src/lib/libssl/src/os2/OS2-EMX.cmd61
-rw-r--r--src/lib/libssl/src/perl/OpenSSL.xs41
-rw-r--r--src/lib/libssl/src/perl/openssl_bio.xs10
-rw-r--r--src/lib/libssl/src/perl/openssl_bn.xs12
-rw-r--r--src/lib/libssl/src/perl/openssl_cipher.xs10
-rw-r--r--src/lib/libssl/src/perl/openssl_digest.xs7
-rw-r--r--src/lib/libssl/src/perl/openssl_ssl.xs12
-rw-r--r--src/lib/libssl/src/shlib/Makefile.hpux10-cc27
-rw-r--r--src/lib/libssl/src/shlib/hpux10-cc.sh18
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared-gcc.sh48
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared-installed28
-rw-r--r--src/lib/libssl/src/shlib/svr5-shared.sh48
-rw-r--r--src/lib/libssl/src/ssl/Makefile.ssl1140
-rw-r--r--src/lib/libssl/src/ssl/bio_ssl.c8
-rw-r--r--src/lib/libssl/src/ssl/install.com2
-rw-r--r--src/lib/libssl/src/ssl/kssl.c2195
-rw-r--r--src/lib/libssl/src/ssl/kssl.h173
-rw-r--r--src/lib/libssl/src/ssl/kssl_lcl.h87
-rw-r--r--src/lib/libssl/src/ssl/s23_clnt.c17
-rw-r--r--src/lib/libssl/src/ssl/s23_lib.c6
-rw-r--r--src/lib/libssl/src/ssl/s23_srvr.c181
-rw-r--r--src/lib/libssl/src/ssl/s2_clnt.c177
-rw-r--r--src/lib/libssl/src/ssl/s2_enc.c19
-rw-r--r--src/lib/libssl/src/ssl/s2_lib.c36
-rw-r--r--src/lib/libssl/src/ssl/s2_meth.c4
-rw-r--r--src/lib/libssl/src/ssl/s2_pkt.c63
-rw-r--r--src/lib/libssl/src/ssl/s2_srvr.c196
-rw-r--r--src/lib/libssl/src/ssl/s3_both.c74
-rw-r--r--src/lib/libssl/src/ssl/s3_clnt.c389
-rw-r--r--src/lib/libssl/src/ssl/s3_enc.c201
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c403
-rw-r--r--src/lib/libssl/src/ssl/s3_pkt.c181
-rw-r--r--src/lib/libssl/src/ssl/s3_srvr.c388
-rw-r--r--src/lib/libssl/src/ssl/ssl-lib.com36
-rw-r--r--src/lib/libssl/src/ssl/ssl.h442
-rw-r--r--src/lib/libssl/src/ssl/ssl2.h9
-rw-r--r--src/lib/libssl/src/ssl/ssl3.h91
-rw-r--r--src/lib/libssl/src/ssl/ssl_algs.c26
-rw-r--r--src/lib/libssl/src/ssl/ssl_asn1.c40
-rw-r--r--src/lib/libssl/src/ssl/ssl_cert.c130
-rw-r--r--src/lib/libssl/src/ssl/ssl_ciph.c77
-rw-r--r--src/lib/libssl/src/ssl/ssl_err.c23
-rw-r--r--src/lib/libssl/src/ssl/ssl_err2.c2
-rw-r--r--src/lib/libssl/src/ssl/ssl_lib.c437
-rw-r--r--src/lib/libssl/src/ssl/ssl_locl.h88
-rw-r--r--src/lib/libssl/src/ssl/ssl_rsa.c42
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c122
-rw-r--r--src/lib/libssl/src/ssl/ssl_stat.c92
-rw-r--r--src/lib/libssl/src/ssl/ssl_task.c2
-rw-r--r--src/lib/libssl/src/ssl/ssl_txt.c14
-rw-r--r--src/lib/libssl/src/ssl/ssltest.c283
-rw-r--r--src/lib/libssl/src/ssl/t1_enc.c221
-rw-r--r--src/lib/libssl/src/ssl/tls1.h30
-rw-r--r--src/lib/libssl/src/test/Makefile.ssl320
-rw-r--r--src/lib/libssl/src/test/maketests.com44
-rw-r--r--src/lib/libssl/src/test/tests.com31
-rw-r--r--src/lib/libssl/src/test/testss15
-rw-r--r--src/lib/libssl/src/test/testssl120
-rw-r--r--src/lib/libssl/src/test/tmp.bctest2
-rw-r--r--src/lib/libssl/src/tools/Makefile.ssl5
-rw-r--r--src/lib/libssl/src/tools/c89.sh15
-rw-r--r--src/lib/libssl/src/tools/c_rehash.in4
-rw-r--r--src/lib/libssl/src/util/clean-depend.pl20
-rw-r--r--src/lib/libssl/src/util/cygwin.sh125
-rw-r--r--src/lib/libssl/src/util/domd22
-rw-r--r--src/lib/libssl/src/util/libeay.num1271
-rw-r--r--src/lib/libssl/src/util/mk1mf.pl98
-rw-r--r--src/lib/libssl/src/util/mkdef.pl980
-rw-r--r--src/lib/libssl/src/util/mkerr.pl200
-rw-r--r--src/lib/libssl/src/util/mkfiles.pl6
-rw-r--r--src/lib/libssl/src/util/mkstack.pl2
-rw-r--r--src/lib/libssl/src/util/pl/BC-16.pl4
-rw-r--r--src/lib/libssl/src/util/pl/BC-32.pl3
-rw-r--r--src/lib/libssl/src/util/pl/OS2-EMX.pl96
-rw-r--r--src/lib/libssl/src/util/pl/VC-16.pl3
-rw-r--r--src/lib/libssl/src/util/pl/VC-32.pl9
-rw-r--r--src/lib/libssl/src/util/selftest.pl12
-rw-r--r--src/lib/libssl/src/util/ssleay.num76
-rw-r--r--src/lib/libssl/ssl.h442
-rw-r--r--src/lib/libssl/ssl/Makefile2
-rw-r--r--src/lib/libssl/ssl2.h9
-rw-r--r--src/lib/libssl/ssl3.h91
-rw-r--r--src/lib/libssl/ssl_algs.c26
-rw-r--r--src/lib/libssl/ssl_asn1.c40
-rw-r--r--src/lib/libssl/ssl_cert.c130
-rw-r--r--src/lib/libssl/ssl_ciph.c77
-rw-r--r--src/lib/libssl/ssl_err.c23
-rw-r--r--src/lib/libssl/ssl_err2.c2
-rw-r--r--src/lib/libssl/ssl_lib.c437
-rw-r--r--src/lib/libssl/ssl_locl.h88
-rw-r--r--src/lib/libssl/ssl_rsa.c42
-rw-r--r--src/lib/libssl/ssl_sess.c122
-rw-r--r--src/lib/libssl/ssl_stat.c92
-rw-r--r--src/lib/libssl/ssl_txt.c14
-rw-r--r--src/lib/libssl/t1_enc.c221
-rw-r--r--src/lib/libssl/test/Makefile.ssl320
-rw-r--r--src/lib/libssl/test/maketests.com44
-rw-r--r--src/lib/libssl/test/tests.com31
-rw-r--r--src/lib/libssl/test/testss15
-rw-r--r--src/lib/libssl/test/testssl120
-rw-r--r--src/lib/libssl/test/tmp.bctest2
-rw-r--r--src/lib/libssl/tls1.h30
948 files changed, 101469 insertions, 23738 deletions
diff --git a/src/lib/libssl/LICENSE b/src/lib/libssl/LICENSE
index 3fd259ac32..7b93e0dbce 100644
--- a/src/lib/libssl/LICENSE
+++ b/src/lib/libssl/LICENSE
@@ -12,7 +12,7 @@
12 --------------- 12 ---------------
13 13
14/* ==================================================================== 14/* ====================================================================
15 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. 15 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
16 * 16 *
17 * Redistribution and use in source and binary forms, with or without 17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions 18 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libssl/Makefile.bsd-wrapper b/src/lib/libssl/Makefile.bsd-wrapper
index 0b37f1d31e..71e293369a 100644
--- a/src/lib/libssl/Makefile.bsd-wrapper
+++ b/src/lib/libssl/Makefile.bsd-wrapper
@@ -1,5 +1,5 @@
1# Build wrapper for OpenSSL 1# Build wrapper for OpenSSL
2# $OpenBSD: Makefile.bsd-wrapper,v 1.44 2002/05/15 01:48:54 beck Exp $ 2# $OpenBSD: Makefile.bsd-wrapper,v 1.45 2002/05/15 02:29:01 beck Exp $
3 3
4# Our lndir is hacked; specify a full path to avoid potential conflicts 4# Our lndir is hacked; specify a full path to avoid potential conflicts
5# with the one installed with X11. 5# with the one installed with X11.
@@ -673,7 +673,7 @@ maninstall:
673 --center='OpenSSL' --release="OpenBSD `uname -r`" \ 673 --center='OpenSSL' --release="OpenBSD `uname -r`" \
674 `basename ${.ALLSRC}` ) | nroff -Tps -man > ${.TARGET} 674 `basename ${.ALLSRC}` ) | nroff -Tps -man > ${.TARGET}
675 675
676SSL_SRC=openssl 676SSL_SRC=src
677 677
678all: prereq ${MANALL} ${PSALL} 678all: prereq ${MANALL} ${PSALL}
679# egcs bombs optimising this file on vax 679# egcs bombs optimising this file on vax
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c
index d85555a7e6..467e149947 100644
--- a/src/lib/libssl/bio_ssl.c
+++ b/src/lib/libssl/bio_ssl.c
@@ -206,6 +206,10 @@ static int ssl_read(BIO *b, char *out, int outl)
206 BIO_set_retry_special(b); 206 BIO_set_retry_special(b);
207 retry_reason=BIO_RR_SSL_X509_LOOKUP; 207 retry_reason=BIO_RR_SSL_X509_LOOKUP;
208 break; 208 break;
209 case SSL_ERROR_WANT_ACCEPT:
210 BIO_set_retry_special(b);
211 retry_reason=BIO_RR_ACCEPT;
212 break;
209 case SSL_ERROR_WANT_CONNECT: 213 case SSL_ERROR_WANT_CONNECT:
210 BIO_set_retry_special(b); 214 BIO_set_retry_special(b);
211 retry_reason=BIO_RR_CONNECT; 215 retry_reason=BIO_RR_CONNECT;
@@ -482,7 +486,9 @@ static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
482 { 486 {
483 case BIO_CTRL_SET_CALLBACK: 487 case BIO_CTRL_SET_CALLBACK:
484 { 488 {
485 SSL_set_info_callback(ssl,fp); 489 /* FIXME: setting this via a completely different prototype
490 seems like a crap idea */
491 SSL_set_info_callback(ssl,(void (*)(const SSL *,int,int))fp);
486 } 492 }
487 break; 493 break;
488 default: 494 default:
diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile
index 2bfd04d516..97e12a758d 100644
--- a/src/lib/libssl/crypto/Makefile
+++ b/src/lib/libssl/crypto/Makefile
@@ -1,7 +1,7 @@
1 1
2LIB= crypto 2LIB= crypto
3 3
4SSLEAYDIST= openssl 4SSLEAYDIST= src
5 5
6LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto 6LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
7LCRYPTO_INC= ${.CURDIR}/../${SSLEAYDIST}/include 7LCRYPTO_INC= ${.CURDIR}/../${SSLEAYDIST}/include
diff --git a/src/lib/libssl/doc/openssl.cnf b/src/lib/libssl/doc/openssl.cnf
index dbe8cbefe0..eca51c3322 100644
--- a/src/lib/libssl/doc/openssl.cnf
+++ b/src/lib/libssl/doc/openssl.cnf
@@ -48,6 +48,14 @@ RANDFILE = $dir/private/.rand # private random number file
48 48
49x509_extensions = usr_cert # The extentions to add to the cert 49x509_extensions = usr_cert # The extentions to add to the cert
50 50
51# Comment out the following two lines for the "traditional"
52# (and highly broken) format.
53name_opt = ca_default # Subject Name options
54cert_opt = ca_default # Certificate field options
55
56# Extension copying option: use with caution.
57# copy_extensions = copy
58
51# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs 59# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
52# so this is commented out by default to leave a V1 CRL. 60# so this is commented out by default to leave a V1 CRL.
53# crl_extensions = crl_ext 61# crl_extensions = crl_ext
@@ -132,7 +140,7 @@ commonName = Common Name (eg, YOUR name)
132commonName_max = 64 140commonName_max = 64
133 141
134emailAddress = Email Address 142emailAddress = Email Address
135emailAddress_max = 40 143emailAddress_max = 64
136 144
137# SET-ex3 = SET extension number 3 145# SET-ex3 = SET extension number 3
138 146
@@ -180,6 +188,9 @@ authorityKeyIdentifier=keyid,issuer:always
180# This stuff is for subjectAltName and issuerAltname. 188# This stuff is for subjectAltName and issuerAltname.
181# Import the email address. 189# Import the email address.
182# subjectAltName=email:copy 190# subjectAltName=email:copy
191# An alternative to produce certificates that aren't
192# deprecated according to PKIX.
193# subjectAltName=email:move
183 194
184# Copy subject details 195# Copy subject details
185# issuerAltName=issuer:copy 196# issuerAltName=issuer:copy
diff --git a/src/lib/libssl/doc/standards.txt b/src/lib/libssl/doc/standards.txt
index 61ccc5d7e0..596d9001e6 100644
--- a/src/lib/libssl/doc/standards.txt
+++ b/src/lib/libssl/doc/standards.txt
@@ -24,7 +24,8 @@ http://www.rsasecurity.com/rsalabs/pkcs/.
24Implemented: 24Implemented:
25------------ 25------------
26 26
27These are documents that describe things that are implemented in OpenSSL. 27These are documents that describe things that are implemented (in
28whole or at least great parts) in OpenSSL.
28 29
291319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992. 301319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992.
30 (Format: TXT=25661 bytes) (Status: INFORMATIONAL) 31 (Format: TXT=25661 bytes) (Status: INFORMATIONAL)
@@ -59,6 +60,11 @@ PKCS#8: Private-Key Information Syntax Standard
59 60
60PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. 61PKCS#12: Personal Information Exchange Syntax Standard, version 1.0.
61 62
632560 X.509 Internet Public Key Infrastructure Online Certificate
64 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin,
65 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED
66 STANDARD)
67
62 68
63Related: 69Related:
64-------- 70--------
@@ -84,6 +90,10 @@ STARTTLS documents.
84 Certification and Related Services. B. Kaliski. February 1993. 90 Certification and Related Services. B. Kaliski. February 1993.
85 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) 91 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD)
86 92
932256 A Summary of the X.500(96) User Schema for use with LDAPv3. M.
94 Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED
95 STANDARD)
96
872487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. 972487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman.
88 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) 98 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD)
89 99
@@ -114,8 +124,7 @@ To be implemented:
114These are documents that describe things that are planed to be 124These are documents that describe things that are planed to be
115implemented in the hopefully short future. 125implemented in the hopefully short future.
116 126
1172560 X.509 Internet Public Key Infrastructure Online Certificate 1272712 Addition of Kerberos Cipher Suites to Transport Layer Security
118 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin, 128 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes)
119 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED 129 (Status: PROPOSED STANDARD)
120 STANDARD)
121 130
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c
index 5050a13ef2..b2be8340fb 100644
--- a/src/lib/libssl/s23_clnt.c
+++ b/src/lib/libssl/s23_clnt.c
@@ -68,7 +68,7 @@ static int ssl23_client_hello(SSL *s);
68static int ssl23_get_server_hello(SSL *s); 68static int ssl23_get_server_hello(SSL *s);
69static SSL_METHOD *ssl23_get_client_method(int ver) 69static SSL_METHOD *ssl23_get_client_method(int ver)
70 { 70 {
71#ifndef NO_SSL2 71#ifndef OPENSSL_NO_SSL2
72 if (ver == SSL2_VERSION) 72 if (ver == SSL2_VERSION)
73 return(SSLv2_client_method()); 73 return(SSLv2_client_method());
74#endif 74#endif
@@ -100,7 +100,7 @@ int ssl23_connect(SSL *s)
100 { 100 {
101 BUF_MEM *buf; 101 BUF_MEM *buf;
102 unsigned long Time=time(NULL); 102 unsigned long Time=time(NULL);
103 void (*cb)()=NULL; 103 void (*cb)(const SSL *ssl,int type,int val)=NULL;
104 int ret= -1; 104 int ret= -1;
105 int new_state,state; 105 int new_state,state;
106 106
@@ -113,8 +113,8 @@ int ssl23_connect(SSL *s)
113 else if (s->ctx->info_callback != NULL) 113 else if (s->ctx->info_callback != NULL)
114 cb=s->ctx->info_callback; 114 cb=s->ctx->info_callback;
115 115
116 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
117 s->in_handshake++; 116 s->in_handshake++;
117 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
118 118
119 for (;;) 119 for (;;)
120 { 120 {
@@ -211,6 +211,7 @@ static int ssl23_client_hello(SSL *s)
211 unsigned char *buf; 211 unsigned char *buf;
212 unsigned char *p,*d; 212 unsigned char *p,*d;
213 int i,ch_len; 213 int i,ch_len;
214 int ret;
214 215
215 buf=(unsigned char *)s->init_buf->data; 216 buf=(unsigned char *)s->init_buf->data;
216 if (s->state == SSL23_ST_CW_CLNT_HELLO_A) 217 if (s->state == SSL23_ST_CW_CLNT_HELLO_A)
@@ -302,7 +303,11 @@ static int ssl23_client_hello(SSL *s)
302 } 303 }
303 304
304 /* SSL3_ST_CW_CLNT_HELLO_B */ 305 /* SSL3_ST_CW_CLNT_HELLO_B */
305 return(ssl23_write_bytes(s)); 306 ret = ssl23_write_bytes(s);
307 if (ret >= 2)
308 if (s->msg_callback)
309 s->msg_callback(1, SSL2_VERSION, 0, s->init_buf->data+2, ret-2, s, s->msg_callback_arg); /* CLIENT-HELLO */
310 return ret;
306 } 311 }
307 312
308static int ssl23_get_server_hello(SSL *s) 313static int ssl23_get_server_hello(SSL *s)
@@ -322,7 +327,7 @@ static int ssl23_get_server_hello(SSL *s)
322 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && 327 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) &&
323 (p[5] == 0x00) && (p[6] == 0x02)) 328 (p[5] == 0x00) && (p[6] == 0x02))
324 { 329 {
325#ifdef NO_SSL2 330#ifdef OPENSSL_NO_SSL2
326 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); 331 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
327 goto err; 332 goto err;
328#else 333#else
@@ -435,7 +440,7 @@ static int ssl23_get_server_hello(SSL *s)
435 (p[3] == 0) && 440 (p[3] == 0) &&
436 (p[4] == 2)) 441 (p[4] == 2))
437 { 442 {
438 void (*cb)()=NULL; 443 void (*cb)(const SSL *ssl,int type,int val)=NULL;
439 int j; 444 int j;
440 445
441 /* An alert */ 446 /* An alert */
diff --git a/src/lib/libssl/s23_lib.c b/src/lib/libssl/s23_lib.c
index ad2d8dadf7..b70002a647 100644
--- a/src/lib/libssl/s23_lib.c
+++ b/src/lib/libssl/s23_lib.c
@@ -111,7 +111,7 @@ SSL_METHOD *sslv23_base_method(void)
111static int ssl23_num_ciphers(void) 111static int ssl23_num_ciphers(void)
112 { 112 {
113 return(ssl3_num_ciphers() 113 return(ssl3_num_ciphers()
114#ifndef NO_SSL2 114#ifndef OPENSSL_NO_SSL2
115 + ssl2_num_ciphers() 115 + ssl2_num_ciphers()
116#endif 116#endif
117 ); 117 );
@@ -124,7 +124,7 @@ static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
124 if (u < uu) 124 if (u < uu)
125 return(ssl3_get_cipher(u)); 125 return(ssl3_get_cipher(u));
126 else 126 else
127#ifndef NO_SSL2 127#ifndef OPENSSL_NO_SSL2
128 return(ssl2_get_cipher(u-uu)); 128 return(ssl2_get_cipher(u-uu));
129#else 129#else
130 return(NULL); 130 return(NULL);
@@ -144,7 +144,7 @@ static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
144 ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; 144 ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
145 c.id=id; 145 c.id=id;
146 cp=ssl3_get_cipher_by_char(p); 146 cp=ssl3_get_cipher_by_char(p);
147#ifndef NO_SSL2 147#ifndef OPENSSL_NO_SSL2
148 if (cp == NULL) 148 if (cp == NULL)
149 cp=ssl2_get_cipher_by_char(p); 149 cp=ssl2_get_cipher_by_char(p);
150#endif 150#endif
diff --git a/src/lib/libssl/s23_srvr.c b/src/lib/libssl/s23_srvr.c
index 050618235f..9e89cc7f9a 100644
--- a/src/lib/libssl/s23_srvr.c
+++ b/src/lib/libssl/s23_srvr.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 <openssl/buffer.h> 113#include <openssl/buffer.h>
@@ -67,7 +120,7 @@ static SSL_METHOD *ssl23_get_server_method(int ver);
67int ssl23_get_client_hello(SSL *s); 120int ssl23_get_client_hello(SSL *s);
68static SSL_METHOD *ssl23_get_server_method(int ver) 121static SSL_METHOD *ssl23_get_server_method(int ver)
69 { 122 {
70#ifndef NO_SSL2 123#ifndef OPENSSL_NO_SSL2
71 if (ver == SSL2_VERSION) 124 if (ver == SSL2_VERSION)
72 return(SSLv2_server_method()); 125 return(SSLv2_server_method());
73#endif 126#endif
@@ -99,7 +152,7 @@ int ssl23_accept(SSL *s)
99 { 152 {
100 BUF_MEM *buf; 153 BUF_MEM *buf;
101 unsigned long Time=time(NULL); 154 unsigned long Time=time(NULL);
102 void (*cb)()=NULL; 155 void (*cb)(const SSL *ssl,int type,int val)=NULL;
103 int ret= -1; 156 int ret= -1;
104 int new_state,state; 157 int new_state,state;
105 158
@@ -112,8 +165,8 @@ int ssl23_accept(SSL *s)
112 else if (s->ctx->info_callback != NULL) 165 else if (s->ctx->info_callback != NULL)
113 cb=s->ctx->info_callback; 166 cb=s->ctx->info_callback;
114 167
115 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
116 s->in_handshake++; 168 s->in_handshake++;
169 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
117 170
118 for (;;) 171 for (;;)
119 { 172 {
@@ -179,9 +232,9 @@ int ssl23_accept(SSL *s)
179 } 232 }
180 } 233 }
181end: 234end:
235 s->in_handshake--;
182 if (cb != NULL) 236 if (cb != NULL)
183 cb(s,SSL_CB_ACCEPT_EXIT,ret); 237 cb(s,SSL_CB_ACCEPT_EXIT,ret);
184 s->in_handshake--;
185 return(ret); 238 return(ret);
186 } 239 }
187 240
@@ -202,13 +255,13 @@ int ssl23_get_client_hello(SSL *s)
202 * 9/10 client_version / 255 * 9/10 client_version /
203 */ 256 */
204 char *buf= &(buf_space[0]); 257 char *buf= &(buf_space[0]);
205 unsigned char *p,*d,*dd; 258 unsigned char *p,*d,*d_len,*dd;
206 unsigned int i; 259 unsigned int i;
207 unsigned int csl,sil,cl; 260 unsigned int csl,sil,cl;
208 int n=0,j; 261 int n=0,j;
209 int type=0; 262 int type=0;
210 int v[2]; 263 int v[2];
211#ifndef NO_RSA 264#ifndef OPENSSL_NO_RSA
212 int use_sslv2_strong=0; 265 int use_sslv2_strong=0;
213#endif 266#endif
214 267
@@ -270,72 +323,6 @@ int ssl23_get_client_hello(SSL *s)
270 else if (!(s->options & SSL_OP_NO_SSLv2)) 323 else if (!(s->options & SSL_OP_NO_SSLv2))
271 type=1; 324 type=1;
272 325
273 if (s->options & SSL_OP_NON_EXPORT_FIRST)
274 /* Not only utterly confusing, but broken
275 * ('fractured programming'?) -- the details
276 * of this block nearly make it work
277 * as intended in this environment, but on one
278 * of the fine points (w.r.t. restarts) it fails.
279 * The obvious fix would be even more devastating
280 * to program structure; if you want the functionality,
281 * throw this away and implement it in a way
282 * that makes sense */
283 {
284#if 0
285 STACK_OF(SSL_CIPHER) *sk;
286 SSL_CIPHER *c;
287 int ne2,ne3;
288
289 j=((p[0]&0x7f)<<8)|p[1];
290 if (j > (1024*4))
291 {
292 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE);
293 goto err;
294 }
295
296 n=ssl23_read_bytes(s,j+2);
297 if (n <= 0) return(n);
298 p=s->packet;
299
300 if ((buf=OPENSSL_malloc(n)) == NULL)
301 {
302 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,ERR_R_MALLOC_FAILURE);
303 goto err;
304 }
305 memcpy(buf,p,n);
306
307 p+=5;
308 n2s(p,csl);
309 p+=4;
310
311 sk=ssl_bytes_to_cipher_list(
312 s,p,csl,NULL);
313 if (sk != NULL)
314 {
315 ne2=ne3=0;
316 for (j=0; j<sk_SSL_CIPHER_num(sk); j++)
317 {
318 c=sk_SSL_CIPHER_value(sk,j);
319 if (!SSL_C_IS_EXPORT(c))
320 {
321 if ((c->id>>24L) == 2L)
322 ne2=1;
323 else
324 ne3=1;
325 }
326 }
327 if (ne2 && !ne3)
328 {
329 type=1;
330 use_sslv2_strong=1;
331 goto next_bit;
332 }
333 }
334#else
335 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_OPTION);
336 goto err;
337#endif
338 }
339 } 326 }
340 } 327 }
341 else if ((p[0] == SSL3_RT_HANDSHAKE) && 328 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
@@ -352,17 +339,22 @@ int ssl23_get_client_hello(SSL *s)
352 /* We must look at client_version inside the Client Hello message 339 /* We must look at client_version inside the Client Hello message
353 * to get the correct minor version. 340 * to get the correct minor version.
354 * However if we have only a pathologically small fragment of the 341 * However if we have only a pathologically small fragment of the
355 * Client Hello message, this would be difficult, we'd have 342 * Client Hello message, this would be difficult, and we'd have
356 * to read at least one additional record to find out. 343 * to read more records to find out.
357 * This doesn't usually happen in real life, so we just complain 344 * No known SSL 3.0 client fragments ClientHello like this,
358 * for now. 345 * so we simply assume TLS 1.0 to avoid protocol version downgrade
359 */ 346 * attacks. */
360 if (p[3] == 0 && p[4] < 6) 347 if (p[3] == 0 && p[4] < 6)
361 { 348 {
349#if 0
362 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); 350 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL);
363 goto err; 351 goto err;
352#else
353 v[1] = TLS1_VERSION_MINOR;
354#endif
364 } 355 }
365 v[1]=p[10]; /* minor version according to client_version */ 356 else
357 v[1]=p[10]; /* minor version according to client_version */
366 if (v[1] >= TLS1_VERSION_MINOR) 358 if (v[1] >= TLS1_VERSION_MINOR)
367 { 359 {
368 if (!(s->options & SSL_OP_NO_TLSv1)) 360 if (!(s->options & SSL_OP_NO_TLSv1))
@@ -376,10 +368,21 @@ int ssl23_get_client_hello(SSL *s)
376 type=3; 368 type=3;
377 } 369 }
378 } 370 }
379 else if (!(s->options & SSL_OP_NO_SSLv3)) 371 else
380 { 372 {
381 s->version=SSL3_VERSION; 373 /* client requests SSL 3.0 */
382 type=3; 374 if (!(s->options & SSL_OP_NO_SSLv3))
375 {
376 s->version=SSL3_VERSION;
377 type=3;
378 }
379 else if (!(s->options & SSL_OP_NO_TLSv1))
380 {
381 /* we won't be able to use TLS of course,
382 * but this will send an appropriate alert */
383 s->version=TLS1_VERSION;
384 type=3;
385 }
383 } 386 }
384 } 387 }
385 else if ((strncmp("GET ", (char *)p,4) == 0) || 388 else if ((strncmp("GET ", (char *)p,4) == 0) ||
@@ -417,7 +420,9 @@ int ssl23_get_client_hello(SSL *s)
417 j=ssl23_read_bytes(s,n+2); 420 j=ssl23_read_bytes(s,n+2);
418 if (j <= 0) return(j); 421 if (j <= 0) return(j);
419 422
420 ssl3_finish_mac(s,&(s->packet[2]),s->packet_length-2); 423 ssl3_finish_mac(s, s->packet+2, s->packet_length-2);
424 if (s->msg_callback)
425 s->msg_callback(0, SSL2_VERSION, 0, s->packet+2, s->packet_length-2, s, s->msg_callback_arg); /* CLIENT-HELLO */
421 426
422 p=s->packet; 427 p=s->packet;
423 p+=5; 428 p+=5;
@@ -431,6 +436,13 @@ int ssl23_get_client_hello(SSL *s)
431 goto err; 436 goto err;
432 } 437 }
433 438
439 /* record header: msg_type ... */
440 *(d++) = SSL3_MT_CLIENT_HELLO;
441 /* ... and length (actual value will be written later) */
442 d_len = d;
443 d += 3;
444
445 /* client_version */
434 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ 446 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */
435 *(d++) = v[1]; 447 *(d++) = v[1];
436 448
@@ -461,7 +473,8 @@ int ssl23_get_client_hello(SSL *s)
461 *(d++)=1; 473 *(d++)=1;
462 *(d++)=0; 474 *(d++)=0;
463 475
464 i=(d-(unsigned char *)s->init_buf->data); 476 i = (d-(unsigned char *)s->init_buf->data) - 4;
477 l2n3((long)i, d_len);
465 478
466 /* get the data reused from the init_buf */ 479 /* get the data reused from the init_buf */
467 s->s3->tmp.reuse_message=1; 480 s->s3->tmp.reuse_message=1;
@@ -474,7 +487,7 @@ int ssl23_get_client_hello(SSL *s)
474 487
475 if (type == 1) 488 if (type == 1)
476 { 489 {
477#ifdef NO_SSL2 490#ifdef OPENSSL_NO_SSL2
478 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); 491 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
479 goto err; 492 goto err;
480#else 493#else
diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c
index 10d8d3b15a..58a24cd883 100644
--- a/src/lib/libssl/s3_both.c
+++ b/src/lib/libssl/s3_both.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-2002 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
@@ -109,6 +109,7 @@
109 * 109 *
110 */ 110 */
111 111
112#include <limits.h>
112#include <string.h> 113#include <string.h>
113#include <stdio.h> 114#include <stdio.h>
114#include <openssl/buffer.h> 115#include <openssl/buffer.h>
@@ -118,7 +119,7 @@
118#include <openssl/x509.h> 119#include <openssl/x509.h>
119#include "ssl_locl.h" 120#include "ssl_locl.h"
120 121
121/* send s->init_buf in records of type 'type' */ 122/* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */
122int ssl3_do_write(SSL *s, int type) 123int ssl3_do_write(SSL *s, int type)
123 { 124 {
124 int ret; 125 int ret;
@@ -132,7 +133,11 @@ int ssl3_do_write(SSL *s, int type)
132 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret); 133 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret);
133 134
134 if (ret == s->init_num) 135 if (ret == s->init_num)
136 {
137 if (s->msg_callback)
138 s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg);
135 return(1); 139 return(1);
140 }
136 s->init_off+=ret; 141 s->init_off+=ret;
137 s->init_num-=ret; 142 s->init_num-=ret;
138 return(0); 143 return(0);
@@ -158,7 +163,7 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
158 p+=i; 163 p+=i;
159 l=i; 164 l=i;
160 165
161#ifdef WIN16 166#ifdef OPENSSL_SYS_WIN16
162 /* MSVC 1.5 does not clear the top bytes of the word unless 167 /* MSVC 1.5 does not clear the top bytes of the word unless
163 * I do this. 168 * I do this.
164 */ 169 */
@@ -205,7 +210,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
205 } 210 }
206 s->s3->change_cipher_spec=0; 211 s->s3->change_cipher_spec=0;
207 212
208 p = (unsigned char *)s->init_buf->data; 213 p = (unsigned char *)s->init_msg;
209 i = s->s3->tmp.peer_finish_md_len; 214 i = s->s3->tmp.peer_finish_md_len;
210 215
211 if (i != n) 216 if (i != n)
@@ -272,7 +277,11 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
272 } 277 }
273 if (x != NULL) 278 if (x != NULL)
274 { 279 {
275 X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL); 280 if(!X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL))
281 {
282 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB);
283 return(0);
284 }
276 285
277 for (;;) 286 for (;;)
278 { 287 {
@@ -351,7 +360,9 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
351 goto f_err; 360 goto f_err;
352 } 361 }
353 *ok=1; 362 *ok=1;
354 return((int)s->s3->tmp.message_size); 363 s->init_msg = s->init_buf->data + 4;
364 s->init_num = (int)s->s3->tmp.message_size;
365 return s->init_num;
355 } 366 }
356 367
357 p=(unsigned char *)s->init_buf->data; 368 p=(unsigned char *)s->init_buf->data;
@@ -383,7 +394,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
383 * if their format is correct. Does not count for 394 * if their format is correct. Does not count for
384 * 'Finished' MAC. */ 395 * 'Finished' MAC. */
385 if (p[1] == 0 && p[2] == 0 &&p[3] == 0) 396 if (p[1] == 0 && p[2] == 0 &&p[3] == 0)
397 {
398 s->init_num = 0;
386 skip_message = 1; 399 skip_message = 1;
400
401 if (s->msg_callback)
402 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, 4, s, s->msg_callback_arg);
403 }
387 } 404 }
388 while (skip_message); 405 while (skip_message);
389 406
@@ -407,8 +424,6 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
407 ssl3_init_finished_mac(s); 424 ssl3_init_finished_mac(s);
408 } 425 }
409 426
410 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);
411
412 s->s3->tmp.message_type= *(p++); 427 s->s3->tmp.message_type= *(p++);
413 428
414 n2l3(p,l); 429 n2l3(p,l);
@@ -418,7 +433,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
418 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); 433 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
419 goto f_err; 434 goto f_err;
420 } 435 }
421 if (l && !BUF_MEM_grow(s->init_buf,(int)l)) 436 if (l > (INT_MAX-4)) /* BUF_MEM_grow takes an 'int' parameter */
437 {
438 al=SSL_AD_ILLEGAL_PARAMETER;
439 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
440 goto f_err;
441 }
442 if (l && !BUF_MEM_grow(s->init_buf,(int)l+4))
422 { 443 {
423 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); 444 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);
424 goto err; 445 goto err;
@@ -426,12 +447,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
426 s->s3->tmp.message_size=l; 447 s->s3->tmp.message_size=l;
427 s->state=stn; 448 s->state=stn;
428 449
429 s->init_num=0; 450 s->init_msg = s->init_buf->data + 4;
451 s->init_num = 0;
430 } 452 }
431 453
432 /* next state (stn) */ 454 /* next state (stn) */
433 p=(unsigned char *)s->init_buf->data; 455 p = s->init_msg;
434 n=s->s3->tmp.message_size; 456 n = s->s3->tmp.message_size - s->init_num;
435 while (n > 0) 457 while (n > 0)
436 { 458 {
437 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0); 459 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0);
@@ -444,7 +466,9 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
444 s->init_num += i; 466 s->init_num += i;
445 n -= i; 467 n -= i;
446 } 468 }
447 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num); 469 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num + 4);
470 if (s->msg_callback)
471 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data, (size_t)s->init_num + 4, s, s->msg_callback_arg);
448 *ok=1; 472 *ok=1;
449 return s->init_num; 473 return s->init_num;
450f_err: 474f_err:
@@ -512,6 +536,7 @@ int ssl_verify_alarm_type(long type)
512 { 536 {
513 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: 537 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
514 case X509_V_ERR_UNABLE_TO_GET_CRL: 538 case X509_V_ERR_UNABLE_TO_GET_CRL:
539 case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:
515 al=SSL_AD_UNKNOWN_CA; 540 al=SSL_AD_UNKNOWN_CA;
516 break; 541 break;
517 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: 542 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
@@ -523,6 +548,8 @@ int ssl_verify_alarm_type(long type)
523 case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: 548 case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
524 case X509_V_ERR_CERT_NOT_YET_VALID: 549 case X509_V_ERR_CERT_NOT_YET_VALID:
525 case X509_V_ERR_CRL_NOT_YET_VALID: 550 case X509_V_ERR_CRL_NOT_YET_VALID:
551 case X509_V_ERR_CERT_UNTRUSTED:
552 case X509_V_ERR_CERT_REJECTED:
526 al=SSL_AD_BAD_CERTIFICATE; 553 al=SSL_AD_BAD_CERTIFICATE;
527 break; 554 break;
528 case X509_V_ERR_CERT_SIGNATURE_FAILURE: 555 case X509_V_ERR_CERT_SIGNATURE_FAILURE:
@@ -544,11 +571,16 @@ int ssl_verify_alarm_type(long type)
544 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: 571 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
545 case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: 572 case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
546 case X509_V_ERR_CERT_CHAIN_TOO_LONG: 573 case X509_V_ERR_CERT_CHAIN_TOO_LONG:
574 case X509_V_ERR_PATH_LENGTH_EXCEEDED:
575 case X509_V_ERR_INVALID_CA:
547 al=SSL_AD_UNKNOWN_CA; 576 al=SSL_AD_UNKNOWN_CA;
548 break; 577 break;
549 case X509_V_ERR_APPLICATION_VERIFICATION: 578 case X509_V_ERR_APPLICATION_VERIFICATION:
550 al=SSL_AD_HANDSHAKE_FAILURE; 579 al=SSL_AD_HANDSHAKE_FAILURE;
551 break; 580 break;
581 case X509_V_ERR_INVALID_PURPOSE:
582 al=SSL_AD_UNSUPPORTED_CERTIFICATE;
583 break;
552 default: 584 default:
553 al=SSL_AD_CERTIFICATE_UNKNOWN; 585 al=SSL_AD_CERTIFICATE_UNKNOWN;
554 break; 586 break;
@@ -560,6 +592,7 @@ int ssl3_setup_buffers(SSL *s)
560 { 592 {
561 unsigned char *p; 593 unsigned char *p;
562 unsigned int extra; 594 unsigned int extra;
595 size_t len;
563 596
564 if (s->s3->rbuf.buf == NULL) 597 if (s->s3->rbuf.buf == NULL)
565 { 598 {
@@ -567,18 +600,21 @@ int ssl3_setup_buffers(SSL *s)
567 extra=SSL3_RT_MAX_EXTRA; 600 extra=SSL3_RT_MAX_EXTRA;
568 else 601 else
569 extra=0; 602 extra=0;
570 if ((p=OPENSSL_malloc(SSL3_RT_MAX_PACKET_SIZE+extra)) 603 len = SSL3_RT_MAX_PACKET_SIZE + extra;
571 == NULL) 604 if ((p=OPENSSL_malloc(len)) == NULL)
572 goto err; 605 goto err;
573 s->s3->rbuf.buf=p; 606 s->s3->rbuf.buf = p;
607 s->s3->rbuf.len = len;
574 } 608 }
575 609
576 if (s->s3->wbuf.buf == NULL) 610 if (s->s3->wbuf.buf == NULL)
577 { 611 {
578 if ((p=OPENSSL_malloc(SSL3_RT_MAX_PACKET_SIZE)) 612 len = SSL3_RT_MAX_PACKET_SIZE;
579 == NULL) 613 len += SSL3_RT_HEADER_LENGTH + 256; /* extra space for empty fragment */
614 if ((p=OPENSSL_malloc(len)) == NULL)
580 goto err; 615 goto err;
581 s->s3->wbuf.buf=p; 616 s->s3->wbuf.buf = p;
617 s->s3->wbuf.len = len;
582 } 618 }
583 s->packet= &(s->s3->rbuf.buf[0]); 619 s->packet= &(s->s3->rbuf.buf[0]);
584 return(1); 620 return(1);
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c
index eec45cfa48..e5853ede95 100644
--- a/src/lib/libssl/s3_clnt.c
+++ b/src/lib/libssl/s3_clnt.c
@@ -55,15 +55,68 @@
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 <openssl/buffer.h> 113#include <openssl/buffer.h>
61#include <openssl/rand.h> 114#include <openssl/rand.h>
62#include <openssl/objects.h> 115#include <openssl/objects.h>
63#include <openssl/md5.h>
64#include <openssl/sha.h>
65#include <openssl/evp.h> 116#include <openssl/evp.h>
66#include "ssl_locl.h" 117#include "ssl_locl.h"
118#include "kssl_lcl.h"
119#include <openssl/md5.h>
67 120
68static SSL_METHOD *ssl3_get_client_method(int ver); 121static SSL_METHOD *ssl3_get_client_method(int ver);
69static int ssl3_client_hello(SSL *s); 122static int ssl3_client_hello(SSL *s);
@@ -106,7 +159,7 @@ int ssl3_connect(SSL *s)
106 BUF_MEM *buf; 159 BUF_MEM *buf;
107 unsigned long Time=time(NULL),l; 160 unsigned long Time=time(NULL),l;
108 long num1; 161 long num1;
109 void (*cb)()=NULL; 162 void (*cb)(const SSL *ssl,int type,int val)=NULL;
110 int ret= -1; 163 int ret= -1;
111 int new_state,state,skip=0;; 164 int new_state,state,skip=0;;
112 165
@@ -119,8 +172,8 @@ int ssl3_connect(SSL *s)
119 else if (s->ctx->info_callback != NULL) 172 else if (s->ctx->info_callback != NULL)
120 cb=s->ctx->info_callback; 173 cb=s->ctx->info_callback;
121 174
122 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
123 s->in_handshake++; 175 s->in_handshake++;
176 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
124 177
125 for (;;) 178 for (;;)
126 { 179 {
@@ -143,7 +196,7 @@ int ssl3_connect(SSL *s)
143 196
144 if ((s->version & 0xff00 ) != 0x0300) 197 if ((s->version & 0xff00 ) != 0x0300)
145 { 198 {
146 SSLerr(SSL_F_SSL3_CONNECT, SSL_R_INTERNAL_ERROR); 199 SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);
147 ret = -1; 200 ret = -1;
148 goto end; 201 goto end;
149 } 202 }
@@ -441,9 +494,9 @@ int ssl3_connect(SSL *s)
441 skip=0; 494 skip=0;
442 } 495 }
443end: 496end:
497 s->in_handshake--;
444 if (cb != NULL) 498 if (cb != NULL)
445 cb(s,SSL_CB_CONNECT_EXIT,ret); 499 cb(s,SSL_CB_CONNECT_EXIT,ret);
446 s->in_handshake--;
447 return(ret); 500 return(ret);
448 } 501 }
449 502
@@ -554,7 +607,7 @@ static int ssl3_get_server_hello(SSL *s)
554 &ok); 607 &ok);
555 608
556 if (!ok) return((int)n); 609 if (!ok) return((int)n);
557 d=p=(unsigned char *)s->init_buf->data; 610 d=p=(unsigned char *)s->init_msg;
558 611
559 if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) 612 if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff)))
560 { 613 {
@@ -687,16 +740,13 @@ static int ssl3_get_server_certificate(SSL *s)
687 STACK_OF(X509) *sk=NULL; 740 STACK_OF(X509) *sk=NULL;
688 SESS_CERT *sc; 741 SESS_CERT *sc;
689 EVP_PKEY *pkey=NULL; 742 EVP_PKEY *pkey=NULL;
743 int need_cert = 1; /* VRS: 0=> will allow null cert if auth == KRB5 */
690 744
691 n=ssl3_get_message(s, 745 n=ssl3_get_message(s,
692 SSL3_ST_CR_CERT_A, 746 SSL3_ST_CR_CERT_A,
693 SSL3_ST_CR_CERT_B, 747 SSL3_ST_CR_CERT_B,
694 -1, 748 -1,
695#if defined(MSDOS) && !defined(WIN32) 749 s->max_cert_list,
696 1024*30, /* 30k max cert list :-) */
697#else
698 1024*100, /* 100k max cert list :-) */
699#endif
700 &ok); 750 &ok);
701 751
702 if (!ok) return((int)n); 752 if (!ok) return((int)n);
@@ -713,7 +763,7 @@ static int ssl3_get_server_certificate(SSL *s)
713 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); 763 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE);
714 goto f_err; 764 goto f_err;
715 } 765 }
716 d=p=(unsigned char *)s->init_buf->data; 766 d=p=(unsigned char *)s->init_msg;
717 767
718 if ((sk=sk_X509_new_null()) == NULL) 768 if ((sk=sk_X509_new_null()) == NULL)
719 { 769 {
@@ -763,7 +813,12 @@ static int ssl3_get_server_certificate(SSL *s)
763 } 813 }
764 814
765 i=ssl_verify_cert_chain(s,sk); 815 i=ssl_verify_cert_chain(s,sk);
766 if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)) 816 if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)
817#ifndef OPENSSL_NO_KRB5
818 && (s->s3->tmp.new_cipher->algorithms & (SSL_MKEY_MASK|SSL_AUTH_MASK))
819 != (SSL_aKRB5|SSL_kKRB5)
820#endif /* OPENSSL_NO_KRB5 */
821 )
767 { 822 {
768 al=ssl_verify_alarm_type(s->verify_result); 823 al=ssl_verify_alarm_type(s->verify_result);
769 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); 824 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED);
@@ -782,39 +837,66 @@ static int ssl3_get_server_certificate(SSL *s)
782 * certificate, which we don't include in s3_srvr.c */ 837 * certificate, which we don't include in s3_srvr.c */
783 x=sk_X509_value(sk,0); 838 x=sk_X509_value(sk,0);
784 sk=NULL; 839 sk=NULL;
840 /* VRS 19990621: possible memory leak; sk=null ==> !sk_pop_free() @end*/
785 841
786 pkey=X509_get_pubkey(x); 842 pkey=X509_get_pubkey(x);
787 843
788 if ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)) 844 /* VRS: allow null cert if auth == KRB5 */
845 need_cert = ((s->s3->tmp.new_cipher->algorithms
846 & (SSL_MKEY_MASK|SSL_AUTH_MASK))
847 == (SSL_aKRB5|SSL_kKRB5))? 0: 1;
848
849#ifdef KSSL_DEBUG
850 printf("pkey,x = %p, %p\n", pkey,x);
851 printf("ssl_cert_type(x,pkey) = %d\n", ssl_cert_type(x,pkey));
852 printf("cipher, alg, nc = %s, %lx, %d\n", s->s3->tmp.new_cipher->name,
853 s->s3->tmp.new_cipher->algorithms, need_cert);
854#endif /* KSSL_DEBUG */
855
856 if (need_cert && ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)))
789 { 857 {
790 x=NULL; 858 x=NULL;
791 al=SSL3_AL_FATAL; 859 al=SSL3_AL_FATAL;
792 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); 860 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,
861 SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS);
793 goto f_err; 862 goto f_err;
794 } 863 }
795 864
796 i=ssl_cert_type(x,pkey); 865 i=ssl_cert_type(x,pkey);
797 if (i < 0) 866 if (need_cert && i < 0)
798 { 867 {
799 x=NULL; 868 x=NULL;
800 al=SSL3_AL_FATAL; 869 al=SSL3_AL_FATAL;
801 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNKNOWN_CERTIFICATE_TYPE); 870 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,
871 SSL_R_UNKNOWN_CERTIFICATE_TYPE);
802 goto f_err; 872 goto f_err;
803 } 873 }
804 874
805 sc->peer_cert_type=i; 875 if (need_cert)
806 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); 876 {
807 if (sc->peer_pkeys[i].x509 != NULL) /* Why would this ever happen? 877 sc->peer_cert_type=i;
808 * We just created sc a couple of 878 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
809 * lines ago. */ 879 /* Why would the following ever happen?
810 X509_free(sc->peer_pkeys[i].x509); 880 * We just created sc a couple of lines ago. */
811 sc->peer_pkeys[i].x509=x; 881 if (sc->peer_pkeys[i].x509 != NULL)
812 sc->peer_key= &(sc->peer_pkeys[i]); 882 X509_free(sc->peer_pkeys[i].x509);
813 883 sc->peer_pkeys[i].x509=x;
814 if (s->session->peer != NULL) 884 sc->peer_key= &(sc->peer_pkeys[i]);
815 X509_free(s->session->peer); 885
816 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); 886 if (s->session->peer != NULL)
817 s->session->peer=x; 887 X509_free(s->session->peer);
888 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
889 s->session->peer=x;
890 }
891 else
892 {
893 sc->peer_cert_type=i;
894 sc->peer_key= NULL;
895
896 if (s->session->peer != NULL)
897 X509_free(s->session->peer);
898 s->session->peer=NULL;
899 }
818 s->session->verify_result = s->verify_result; 900 s->session->verify_result = s->verify_result;
819 901
820 x=NULL; 902 x=NULL;
@@ -834,7 +916,7 @@ err:
834 916
835static int ssl3_get_key_exchange(SSL *s) 917static int ssl3_get_key_exchange(SSL *s)
836 { 918 {
837#ifndef NO_RSA 919#ifndef OPENSSL_NO_RSA
838 unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; 920 unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2];
839#endif 921#endif
840 EVP_MD_CTX md_ctx; 922 EVP_MD_CTX md_ctx;
@@ -842,18 +924,20 @@ static int ssl3_get_key_exchange(SSL *s)
842 int al,i,j,param_len,ok; 924 int al,i,j,param_len,ok;
843 long n,alg; 925 long n,alg;
844 EVP_PKEY *pkey=NULL; 926 EVP_PKEY *pkey=NULL;
845#ifndef NO_RSA 927#ifndef OPENSSL_NO_RSA
846 RSA *rsa=NULL; 928 RSA *rsa=NULL;
847#endif 929#endif
848#ifndef NO_DH 930#ifndef OPENSSL_NO_DH
849 DH *dh=NULL; 931 DH *dh=NULL;
850#endif 932#endif
851 933
934 /* use same message size as in ssl3_get_certificate_request()
935 * as ServerKeyExchange message may be skipped */
852 n=ssl3_get_message(s, 936 n=ssl3_get_message(s,
853 SSL3_ST_CR_KEY_EXCH_A, 937 SSL3_ST_CR_KEY_EXCH_A,
854 SSL3_ST_CR_KEY_EXCH_B, 938 SSL3_ST_CR_KEY_EXCH_B,
855 -1, 939 -1,
856 1024*8, /* ?? */ 940 s->max_cert_list,
857 &ok); 941 &ok);
858 942
859 if (!ok) return((int)n); 943 if (!ok) return((int)n);
@@ -864,18 +948,18 @@ static int ssl3_get_key_exchange(SSL *s)
864 return(1); 948 return(1);
865 } 949 }
866 950
867 param=p=(unsigned char *)s->init_buf->data; 951 param=p=(unsigned char *)s->init_msg;
868 952
869 if (s->session->sess_cert != NULL) 953 if (s->session->sess_cert != NULL)
870 { 954 {
871#ifndef NO_RSA 955#ifndef OPENSSL_NO_RSA
872 if (s->session->sess_cert->peer_rsa_tmp != NULL) 956 if (s->session->sess_cert->peer_rsa_tmp != NULL)
873 { 957 {
874 RSA_free(s->session->sess_cert->peer_rsa_tmp); 958 RSA_free(s->session->sess_cert->peer_rsa_tmp);
875 s->session->sess_cert->peer_rsa_tmp=NULL; 959 s->session->sess_cert->peer_rsa_tmp=NULL;
876 } 960 }
877#endif 961#endif
878#ifndef NO_DH 962#ifndef OPENSSL_NO_DH
879 if (s->session->sess_cert->peer_dh_tmp) 963 if (s->session->sess_cert->peer_dh_tmp)
880 { 964 {
881 DH_free(s->session->sess_cert->peer_dh_tmp); 965 DH_free(s->session->sess_cert->peer_dh_tmp);
@@ -890,8 +974,9 @@ static int ssl3_get_key_exchange(SSL *s)
890 974
891 param_len=0; 975 param_len=0;
892 alg=s->s3->tmp.new_cipher->algorithms; 976 alg=s->s3->tmp.new_cipher->algorithms;
977 EVP_MD_CTX_init(&md_ctx);
893 978
894#ifndef NO_RSA 979#ifndef OPENSSL_NO_RSA
895 if (alg & SSL_kRSA) 980 if (alg & SSL_kRSA)
896 { 981 {
897 if ((rsa=RSA_new()) == NULL) 982 if ((rsa=RSA_new()) == NULL)
@@ -935,17 +1020,17 @@ static int ssl3_get_key_exchange(SSL *s)
935 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); 1020 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
936 else 1021 else
937 { 1022 {
938 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1023 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
939 goto err; 1024 goto err;
940 } 1025 }
941 s->session->sess_cert->peer_rsa_tmp=rsa; 1026 s->session->sess_cert->peer_rsa_tmp=rsa;
942 rsa=NULL; 1027 rsa=NULL;
943 } 1028 }
944#else /* NO_RSA */ 1029#else /* OPENSSL_NO_RSA */
945 if (0) 1030 if (0)
946 ; 1031 ;
947#endif 1032#endif
948#ifndef NO_DH 1033#ifndef OPENSSL_NO_DH
949 else if (alg & SSL_kEDH) 1034 else if (alg & SSL_kEDH)
950 { 1035 {
951 if ((dh=DH_new()) == NULL) 1036 if ((dh=DH_new()) == NULL)
@@ -999,14 +1084,14 @@ static int ssl3_get_key_exchange(SSL *s)
999 p+=i; 1084 p+=i;
1000 n-=param_len; 1085 n-=param_len;
1001 1086
1002#ifndef NO_RSA 1087#ifndef OPENSSL_NO_RSA
1003 if (alg & SSL_aRSA) 1088 if (alg & SSL_aRSA)
1004 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); 1089 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
1005#else 1090#else
1006 if (0) 1091 if (0)
1007 ; 1092 ;
1008#endif 1093#endif
1009#ifndef NO_DSA 1094#ifndef OPENSSL_NO_DSA
1010 else if (alg & SSL_aDSS) 1095 else if (alg & SSL_aDSS)
1011 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509); 1096 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
1012#endif 1097#endif
@@ -1021,7 +1106,7 @@ static int ssl3_get_key_exchange(SSL *s)
1021 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); 1106 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER);
1022 goto f_err; 1107 goto f_err;
1023 } 1108 }
1024#endif /* !NO_DH */ 1109#endif /* !OPENSSL_NO_DH */
1025 if (alg & SSL_aFZA) 1110 if (alg & SSL_aFZA)
1026 { 1111 {
1027 al=SSL_AD_HANDSHAKE_FAILURE; 1112 al=SSL_AD_HANDSHAKE_FAILURE;
@@ -1048,7 +1133,7 @@ static int ssl3_get_key_exchange(SSL *s)
1048 goto f_err; 1133 goto f_err;
1049 } 1134 }
1050 1135
1051#ifndef NO_RSA 1136#ifndef OPENSSL_NO_RSA
1052 if (pkey->type == EVP_PKEY_RSA) 1137 if (pkey->type == EVP_PKEY_RSA)
1053 { 1138 {
1054 int num; 1139 int num;
@@ -1057,12 +1142,12 @@ static int ssl3_get_key_exchange(SSL *s)
1057 q=md_buf; 1142 q=md_buf;
1058 for (num=2; num > 0; num--) 1143 for (num=2; num > 0; num--)
1059 { 1144 {
1060 EVP_DigestInit(&md_ctx,(num == 2) 1145 EVP_DigestInit_ex(&md_ctx,(num == 2)
1061 ?s->ctx->md5:s->ctx->sha1); 1146 ?s->ctx->md5:s->ctx->sha1, NULL);
1062 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1147 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1063 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1148 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1064 EVP_DigestUpdate(&md_ctx,param,param_len); 1149 EVP_DigestUpdate(&md_ctx,param,param_len);
1065 EVP_DigestFinal(&md_ctx,q,(unsigned int *)&i); 1150 EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i);
1066 q+=i; 1151 q+=i;
1067 j+=i; 1152 j+=i;
1068 } 1153 }
@@ -1084,11 +1169,11 @@ static int ssl3_get_key_exchange(SSL *s)
1084 } 1169 }
1085 else 1170 else
1086#endif 1171#endif
1087#ifndef NO_DSA 1172#ifndef OPENSSL_NO_DSA
1088 if (pkey->type == EVP_PKEY_DSA) 1173 if (pkey->type == EVP_PKEY_DSA)
1089 { 1174 {
1090 /* lets do DSS */ 1175 /* lets do DSS */
1091 EVP_VerifyInit(&md_ctx,EVP_dss1()); 1176 EVP_VerifyInit_ex(&md_ctx,EVP_dss1(), NULL);
1092 EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1177 EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1093 EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1178 EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1094 EVP_VerifyUpdate(&md_ctx,param,param_len); 1179 EVP_VerifyUpdate(&md_ctx,param,param_len);
@@ -1103,7 +1188,7 @@ static int ssl3_get_key_exchange(SSL *s)
1103 else 1188 else
1104#endif 1189#endif
1105 { 1190 {
1106 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1191 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1107 goto err; 1192 goto err;
1108 } 1193 }
1109 } 1194 }
@@ -1112,7 +1197,7 @@ static int ssl3_get_key_exchange(SSL *s)
1112 /* still data left over */ 1197 /* still data left over */
1113 if (!(alg & SSL_aNULL)) 1198 if (!(alg & SSL_aNULL))
1114 { 1199 {
1115 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1200 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1116 goto err; 1201 goto err;
1117 } 1202 }
1118 if (n != 0) 1203 if (n != 0)
@@ -1123,19 +1208,21 @@ static int ssl3_get_key_exchange(SSL *s)
1123 } 1208 }
1124 } 1209 }
1125 EVP_PKEY_free(pkey); 1210 EVP_PKEY_free(pkey);
1211 EVP_MD_CTX_cleanup(&md_ctx);
1126 return(1); 1212 return(1);
1127f_err: 1213f_err:
1128 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1214 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1129err: 1215err:
1130 EVP_PKEY_free(pkey); 1216 EVP_PKEY_free(pkey);
1131#ifndef NO_RSA 1217#ifndef OPENSSL_NO_RSA
1132 if (rsa != NULL) 1218 if (rsa != NULL)
1133 RSA_free(rsa); 1219 RSA_free(rsa);
1134#endif 1220#endif
1135#ifndef NO_DH 1221#ifndef OPENSSL_NO_DH
1136 if (dh != NULL) 1222 if (dh != NULL)
1137 DH_free(dh); 1223 DH_free(dh);
1138#endif 1224#endif
1225 EVP_MD_CTX_cleanup(&md_ctx);
1139 return(-1); 1226 return(-1);
1140 } 1227 }
1141 1228
@@ -1152,11 +1239,7 @@ static int ssl3_get_certificate_request(SSL *s)
1152 SSL3_ST_CR_CERT_REQ_A, 1239 SSL3_ST_CR_CERT_REQ_A,
1153 SSL3_ST_CR_CERT_REQ_B, 1240 SSL3_ST_CR_CERT_REQ_B,
1154 -1, 1241 -1,
1155#if defined(MSDOS) && !defined(WIN32) 1242 s->max_cert_list,
1156 1024*30, /* 30k max cert list :-) */
1157#else
1158 1024*100, /* 100k max cert list :-) */
1159#endif
1160 &ok); 1243 &ok);
1161 1244
1162 if (!ok) return((int)n); 1245 if (!ok) return((int)n);
@@ -1188,7 +1271,7 @@ static int ssl3_get_certificate_request(SSL *s)
1188 } 1271 }
1189 } 1272 }
1190 1273
1191 d=p=(unsigned char *)s->init_buf->data; 1274 d=p=(unsigned char *)s->init_msg;
1192 1275
1193 if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL) 1276 if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL)
1194 { 1277 {
@@ -1308,6 +1391,7 @@ static int ssl3_get_server_done(SSL *s)
1308 /* should contain no data */ 1391 /* should contain no data */
1309 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); 1392 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);
1310 SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); 1393 SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH);
1394 return -1;
1311 } 1395 }
1312 ret=1; 1396 ret=1;
1313 return(ret); 1397 return(ret);
@@ -1318,10 +1402,13 @@ static int ssl3_send_client_key_exchange(SSL *s)
1318 unsigned char *p,*d; 1402 unsigned char *p,*d;
1319 int n; 1403 int n;
1320 unsigned long l; 1404 unsigned long l;
1321#ifndef NO_RSA 1405#ifndef OPENSSL_NO_RSA
1322 unsigned char *q; 1406 unsigned char *q;
1323 EVP_PKEY *pkey=NULL; 1407 EVP_PKEY *pkey=NULL;
1324#endif 1408#endif
1409#ifndef OPENSSL_NO_KRB5
1410 KSSL_ERR kssl_err;
1411#endif /* OPENSSL_NO_KRB5 */
1325 1412
1326 if (s->state == SSL3_ST_CW_KEY_EXCH_A) 1413 if (s->state == SSL3_ST_CW_KEY_EXCH_A)
1327 { 1414 {
@@ -1330,8 +1417,10 @@ static int ssl3_send_client_key_exchange(SSL *s)
1330 1417
1331 l=s->s3->tmp.new_cipher->algorithms; 1418 l=s->s3->tmp.new_cipher->algorithms;
1332 1419
1333#ifndef NO_RSA 1420 /* Fool emacs indentation */
1334 if (l & SSL_kRSA) 1421 if (0) {}
1422#ifndef OPENSSL_NO_RSA
1423 else if (l & SSL_kRSA)
1335 { 1424 {
1336 RSA *rsa; 1425 RSA *rsa;
1337 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; 1426 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
@@ -1345,7 +1434,7 @@ static int ssl3_send_client_key_exchange(SSL *s)
1345 (pkey->type != EVP_PKEY_RSA) || 1434 (pkey->type != EVP_PKEY_RSA) ||
1346 (pkey->pkey.rsa == NULL)) 1435 (pkey->pkey.rsa == NULL))
1347 { 1436 {
1348 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1437 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1349 goto err; 1438 goto err;
1350 } 1439 }
1351 rsa=pkey->pkey.rsa; 1440 rsa=pkey->pkey.rsa;
@@ -1388,10 +1477,136 @@ static int ssl3_send_client_key_exchange(SSL *s)
1388 tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); 1477 tmp_buf,SSL_MAX_MASTER_KEY_LENGTH);
1389 memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); 1478 memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH);
1390 } 1479 }
1391 else
1392#endif 1480#endif
1393#ifndef NO_DH 1481#ifndef OPENSSL_NO_KRB5
1394 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1482 else if (l & SSL_kKRB5)
1483 {
1484 krb5_error_code krb5rc;
1485 KSSL_CTX *kssl_ctx = s->kssl_ctx;
1486 /* krb5_data krb5_ap_req; */
1487 krb5_data *enc_ticket;
1488 krb5_data authenticator, *authp = NULL;
1489 EVP_CIPHER_CTX ciph_ctx;
1490 EVP_CIPHER *enc = NULL;
1491 unsigned char iv[EVP_MAX_IV_LENGTH];
1492 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
1493 unsigned char epms[SSL_MAX_MASTER_KEY_LENGTH
1494 + EVP_MAX_IV_LENGTH];
1495 int padl, outl = sizeof(epms);
1496
1497 EVP_CIPHER_CTX_init(&ciph_ctx);
1498
1499#ifdef KSSL_DEBUG
1500 printf("ssl3_send_client_key_exchange(%lx & %lx)\n",
1501 l, SSL_kKRB5);
1502#endif /* KSSL_DEBUG */
1503
1504 authp = NULL;
1505#ifdef KRB5SENDAUTH
1506 if (KRB5SENDAUTH) authp = &authenticator;
1507#endif /* KRB5SENDAUTH */
1508
1509 krb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp,
1510 &kssl_err);
1511 enc = kssl_map_enc(kssl_ctx->enctype);
1512 if (enc == NULL)
1513 goto err;
1514#ifdef KSSL_DEBUG
1515 {
1516 printf("kssl_cget_tkt rtn %d\n", krb5rc);
1517 if (krb5rc && kssl_err.text)
1518 printf("kssl_cget_tkt kssl_err=%s\n", kssl_err.text);
1519 }
1520#endif /* KSSL_DEBUG */
1521
1522 if (krb5rc)
1523 {
1524 ssl3_send_alert(s,SSL3_AL_FATAL,
1525 SSL_AD_HANDSHAKE_FAILURE);
1526 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1527 kssl_err.reason);
1528 goto err;
1529 }
1530
1531 /* 20010406 VRS - Earlier versions used KRB5 AP_REQ
1532 ** in place of RFC 2712 KerberosWrapper, as in:
1533 **
1534 ** Send ticket (copy to *p, set n = length)
1535 ** n = krb5_ap_req.length;
1536 ** memcpy(p, krb5_ap_req.data, krb5_ap_req.length);
1537 ** if (krb5_ap_req.data)
1538 ** kssl_krb5_free_data_contents(NULL,&krb5_ap_req);
1539 **
1540 ** Now using real RFC 2712 KerberosWrapper
1541 ** (Thanks to Simon Wilkinson <sxw@sxw.org.uk>)
1542 ** Note: 2712 "opaque" types are here replaced
1543 ** with a 2-byte length followed by the value.
1544 ** Example:
1545 ** KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms
1546 ** Where "xx xx" = length bytes. Shown here with
1547 ** optional authenticator omitted.
1548 */
1549
1550 /* KerberosWrapper.Ticket */
1551 s2n(enc_ticket->length,p);
1552 memcpy(p, enc_ticket->data, enc_ticket->length);
1553 p+= enc_ticket->length;
1554 n = enc_ticket->length + 2;
1555
1556 /* KerberosWrapper.Authenticator */
1557 if (authp && authp->length)
1558 {
1559 s2n(authp->length,p);
1560 memcpy(p, authp->data, authp->length);
1561 p+= authp->length;
1562 n+= authp->length + 2;
1563
1564 free(authp->data);
1565 authp->data = NULL;
1566 authp->length = 0;
1567 }
1568 else
1569 {
1570 s2n(0,p);/* null authenticator length */
1571 n+=2;
1572 }
1573
1574 if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0)
1575 goto err;
1576
1577 /* 20010420 VRS. Tried it this way; failed.
1578 ** EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL);
1579 ** EVP_CIPHER_CTX_set_key_length(&ciph_ctx,
1580 ** kssl_ctx->length);
1581 ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv);
1582 */
1583
1584 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */
1585 EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,
1586 kssl_ctx->key,iv);
1587 EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf,
1588 SSL_MAX_MASTER_KEY_LENGTH);
1589 EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl);
1590 outl += padl;
1591 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
1592
1593 /* KerberosWrapper.EncryptedPreMasterSecret */
1594 s2n(outl,p);
1595 memcpy(p, epms, outl);
1596 p+=outl;
1597 n+=outl + 2;
1598
1599 s->session->master_key_length=
1600 s->method->ssl3_enc->generate_master_secret(s,
1601 s->session->master_key,
1602 tmp_buf, SSL_MAX_MASTER_KEY_LENGTH);
1603
1604 memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH);
1605 memset(epms, 0, outl);
1606 }
1607#endif
1608#ifndef OPENSSL_NO_DH
1609 else if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1395 { 1610 {
1396 DH *dh_srvr,*dh_clnt; 1611 DH *dh_srvr,*dh_clnt;
1397 1612
@@ -1445,11 +1660,11 @@ static int ssl3_send_client_key_exchange(SSL *s)
1445 1660
1446 /* perhaps clean things up a bit EAY EAY EAY EAY*/ 1661 /* perhaps clean things up a bit EAY EAY EAY EAY*/
1447 } 1662 }
1448 else
1449#endif 1663#endif
1664 else
1450 { 1665 {
1451 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); 1666 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE);
1452 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1667 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1453 goto err; 1668 goto err;
1454 } 1669 }
1455 1670
@@ -1473,11 +1688,11 @@ static int ssl3_send_client_verify(SSL *s)
1473 unsigned char *p,*d; 1688 unsigned char *p,*d;
1474 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1689 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
1475 EVP_PKEY *pkey; 1690 EVP_PKEY *pkey;
1476#ifndef NO_RSA 1691#ifndef OPENSSL_NO_RSA
1477 unsigned u=0; 1692 unsigned u=0;
1478#endif 1693#endif
1479 unsigned long n; 1694 unsigned long n;
1480#ifndef NO_DSA 1695#ifndef OPENSSL_NO_DSA
1481 int j; 1696 int j;
1482#endif 1697#endif
1483 1698
@@ -1490,7 +1705,7 @@ static int ssl3_send_client_verify(SSL *s)
1490 s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), 1705 s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2),
1491 &(data[MD5_DIGEST_LENGTH])); 1706 &(data[MD5_DIGEST_LENGTH]));
1492 1707
1493#ifndef NO_RSA 1708#ifndef OPENSSL_NO_RSA
1494 if (pkey->type == EVP_PKEY_RSA) 1709 if (pkey->type == EVP_PKEY_RSA)
1495 { 1710 {
1496 s->method->ssl3_enc->cert_verify_mac(s, 1711 s->method->ssl3_enc->cert_verify_mac(s,
@@ -1507,7 +1722,7 @@ static int ssl3_send_client_verify(SSL *s)
1507 } 1722 }
1508 else 1723 else
1509#endif 1724#endif
1510#ifndef NO_DSA 1725#ifndef OPENSSL_NO_DSA
1511 if (pkey->type == EVP_PKEY_DSA) 1726 if (pkey->type == EVP_PKEY_DSA)
1512 { 1727 {
1513 if (!DSA_sign(pkey->save_type, 1728 if (!DSA_sign(pkey->save_type,
@@ -1524,7 +1739,7 @@ static int ssl3_send_client_verify(SSL *s)
1524 else 1739 else
1525#endif 1740#endif
1526 { 1741 {
1527 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,SSL_R_INTERNAL_ERROR); 1742 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_INTERNAL_ERROR);
1528 goto err; 1743 goto err;
1529 } 1744 }
1530 *(d++)=SSL3_MT_CERTIFICATE_VERIFY; 1745 *(d++)=SSL3_MT_CERTIFICATE_VERIFY;
@@ -1623,10 +1838,10 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1623 long algs; 1838 long algs;
1624 EVP_PKEY *pkey=NULL; 1839 EVP_PKEY *pkey=NULL;
1625 SESS_CERT *sc; 1840 SESS_CERT *sc;
1626#ifndef NO_RSA 1841#ifndef OPENSSL_NO_RSA
1627 RSA *rsa; 1842 RSA *rsa;
1628#endif 1843#endif
1629#ifndef NO_DH 1844#ifndef OPENSSL_NO_DH
1630 DH *dh; 1845 DH *dh;
1631#endif 1846#endif
1632 1847
@@ -1634,20 +1849,20 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1634 1849
1635 if (sc == NULL) 1850 if (sc == NULL)
1636 { 1851 {
1637 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_INTERNAL_ERROR); 1852 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR);
1638 goto err; 1853 goto err;
1639 } 1854 }
1640 1855
1641 algs=s->s3->tmp.new_cipher->algorithms; 1856 algs=s->s3->tmp.new_cipher->algorithms;
1642 1857
1643 /* we don't have a certificate */ 1858 /* we don't have a certificate */
1644 if (algs & (SSL_aDH|SSL_aNULL)) 1859 if (algs & (SSL_aDH|SSL_aNULL|SSL_aKRB5))
1645 return(1); 1860 return(1);
1646 1861
1647#ifndef NO_RSA 1862#ifndef OPENSSL_NO_RSA
1648 rsa=s->session->sess_cert->peer_rsa_tmp; 1863 rsa=s->session->sess_cert->peer_rsa_tmp;
1649#endif 1864#endif
1650#ifndef NO_DH 1865#ifndef OPENSSL_NO_DH
1651 dh=s->session->sess_cert->peer_dh_tmp; 1866 dh=s->session->sess_cert->peer_dh_tmp;
1652#endif 1867#endif
1653 1868
@@ -1665,14 +1880,14 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1665 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); 1880 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT);
1666 goto f_err; 1881 goto f_err;
1667 } 1882 }
1668#ifndef NO_DSA 1883#ifndef OPENSSL_NO_DSA
1669 else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) 1884 else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN))
1670 { 1885 {
1671 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); 1886 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT);
1672 goto f_err; 1887 goto f_err;
1673 } 1888 }
1674#endif 1889#endif
1675#ifndef NO_RSA 1890#ifndef OPENSSL_NO_RSA
1676 if ((algs & SSL_kRSA) && 1891 if ((algs & SSL_kRSA) &&
1677 !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) 1892 !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL)))
1678 { 1893 {
@@ -1680,7 +1895,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1680 goto f_err; 1895 goto f_err;
1681 } 1896 }
1682#endif 1897#endif
1683#ifndef NO_DH 1898#ifndef OPENSSL_NO_DH
1684 if ((algs & SSL_kEDH) && 1899 if ((algs & SSL_kEDH) &&
1685 !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) 1900 !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL)))
1686 { 1901 {
@@ -1692,7 +1907,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1692 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); 1907 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT);
1693 goto f_err; 1908 goto f_err;
1694 } 1909 }
1695#ifndef NO_DSA 1910#ifndef OPENSSL_NO_DSA
1696 else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) 1911 else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA))
1697 { 1912 {
1698 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); 1913 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT);
@@ -1703,7 +1918,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1703 1918
1704 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) 1919 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP))
1705 { 1920 {
1706#ifndef NO_RSA 1921#ifndef OPENSSL_NO_RSA
1707 if (algs & SSL_kRSA) 1922 if (algs & SSL_kRSA)
1708 { 1923 {
1709 if (rsa == NULL 1924 if (rsa == NULL
@@ -1715,7 +1930,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1715 } 1930 }
1716 else 1931 else
1717#endif 1932#endif
1718#ifndef NO_DH 1933#ifndef OPENSSL_NO_DH
1719 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1934 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1720 { 1935 {
1721 if (dh == NULL 1936 if (dh == NULL
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index c32c06de32..686992406c 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.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-2002 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
@@ -110,10 +110,10 @@
110 */ 110 */
111 111
112#include <stdio.h> 112#include <stdio.h>
113#include <openssl/md5.h>
114#include <openssl/sha.h>
115#include <openssl/objects.h> 113#include <openssl/objects.h>
116#include "ssl_locl.h" 114#include "ssl_locl.h"
115#include "kssl_lcl.h"
116#include <openssl/md5.h>
117 117
118const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT; 118const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;
119 119
@@ -170,7 +170,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
170 SSL3_TXT_ADH_RC4_128_MD5, 170 SSL3_TXT_ADH_RC4_128_MD5,
171 SSL3_CK_ADH_RC4_128_MD5, 171 SSL3_CK_ADH_RC4_128_MD5,
172 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3, 172 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
173 SSL_NOT_EXP, 173 SSL_NOT_EXP|SSL_MEDIUM,
174 0, 174 0,
175 128, 175 128,
176 128, 176 128,
@@ -196,7 +196,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
196 SSL3_TXT_ADH_DES_64_CBC_SHA, 196 SSL3_TXT_ADH_DES_64_CBC_SHA,
197 SSL3_CK_ADH_DES_64_CBC_SHA, 197 SSL3_CK_ADH_DES_64_CBC_SHA,
198 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3, 198 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
199 SSL_NOT_EXP, 199 SSL_NOT_EXP|SSL_LOW,
200 0, 200 0,
201 56, 201 56,
202 56, 202 56,
@@ -209,7 +209,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
209 SSL3_TXT_ADH_DES_192_CBC_SHA, 209 SSL3_TXT_ADH_DES_192_CBC_SHA,
210 SSL3_CK_ADH_DES_192_CBC_SHA, 210 SSL3_CK_ADH_DES_192_CBC_SHA,
211 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3, 211 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
212 SSL_NOT_EXP, 212 SSL_NOT_EXP|SSL_HIGH,
213 0, 213 0,
214 168, 214 168,
215 168, 215 168,
@@ -518,7 +518,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
518 SSL3_TXT_FZA_DMS_RC4_SHA, 518 SSL3_TXT_FZA_DMS_RC4_SHA,
519 SSL3_CK_FZA_DMS_RC4_SHA, 519 SSL3_CK_FZA_DMS_RC4_SHA,
520 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3, 520 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
521 SSL_NOT_EXP, 521 SSL_NOT_EXP|SSL_MEDIUM,
522 0, 522 0,
523 128, 523 128,
524 128, 524 128,
@@ -526,6 +526,97 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
526 SSL_ALL_STRENGTHS, 526 SSL_ALL_STRENGTHS,
527 }, 527 },
528 528
529#ifndef OPENSSL_NO_KRB5
530/* The Kerberos ciphers
531** 20000107 VRS: And the first shall be last,
532** in hopes of avoiding the lynx ssl renegotiation problem.
533*/
534/* Cipher 21 VRS */
535 {
536 1,
537 SSL3_TXT_KRB5_DES_40_CBC_SHA,
538 SSL3_CK_KRB5_DES_40_CBC_SHA,
539 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
540 SSL_EXPORT|SSL_EXP40,
541 0,
542 40,
543 56,
544 SSL_ALL_CIPHERS,
545 SSL_ALL_STRENGTHS,
546 },
547
548/* Cipher 22 VRS */
549 {
550 1,
551 SSL3_TXT_KRB5_DES_40_CBC_MD5,
552 SSL3_CK_KRB5_DES_40_CBC_MD5,
553 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
554 SSL_EXPORT|SSL_EXP40,
555 0,
556 40,
557 56,
558 SSL_ALL_CIPHERS,
559 SSL_ALL_STRENGTHS,
560 },
561
562/* Cipher 23 VRS */
563 {
564 1,
565 SSL3_TXT_KRB5_DES_64_CBC_SHA,
566 SSL3_CK_KRB5_DES_64_CBC_SHA,
567 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
568 SSL_NOT_EXP|SSL_LOW,
569 0,
570 56,
571 56,
572 SSL_ALL_CIPHERS,
573 SSL_ALL_STRENGTHS,
574 },
575
576/* Cipher 24 VRS */
577 {
578 1,
579 SSL3_TXT_KRB5_DES_64_CBC_MD5,
580 SSL3_CK_KRB5_DES_64_CBC_MD5,
581 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
582 SSL_NOT_EXP|SSL_LOW,
583 0,
584 56,
585 56,
586 SSL_ALL_CIPHERS,
587 SSL_ALL_STRENGTHS,
588 },
589
590/* Cipher 25 VRS */
591 {
592 1,
593 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
594 SSL3_CK_KRB5_DES_192_CBC3_SHA,
595 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3,
596 SSL_NOT_EXP|SSL_HIGH,
597 0,
598 112,
599 168,
600 SSL_ALL_CIPHERS,
601 SSL_ALL_STRENGTHS,
602 },
603
604/* Cipher 26 VRS */
605 {
606 1,
607 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
608 SSL3_CK_KRB5_DES_192_CBC3_MD5,
609 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3,
610 SSL_NOT_EXP|SSL_HIGH,
611 0,
612 112,
613 168,
614 SSL_ALL_CIPHERS,
615 SSL_ALL_STRENGTHS,
616 },
617#endif /* OPENSSL_NO_KRB5 */
618
619
529#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 620#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
530 /* New TLS Export CipherSuites */ 621 /* New TLS Export CipherSuites */
531 /* Cipher 60 */ 622 /* Cipher 60 */
@@ -612,7 +703,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
612 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA, 703 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
613 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA, 704 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
614 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, 705 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
615 SSL_NOT_EXP, 706 SSL_NOT_EXP|SSL_MEDIUM,
616 0, 707 0,
617 128, 708 128,
618 128, 709 128,
@@ -620,6 +711,165 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
620 SSL_ALL_STRENGTHS 711 SSL_ALL_STRENGTHS
621 }, 712 },
622#endif 713#endif
714 /* New AES ciphersuites */
715
716 /* Cipher 2F */
717 {
718 1,
719 TLS1_TXT_RSA_WITH_AES_128_SHA,
720 TLS1_CK_RSA_WITH_AES_128_SHA,
721 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
722 SSL_NOT_EXP|SSL_MEDIUM,
723 0,
724 128,
725 128,
726 SSL_ALL_CIPHERS,
727 SSL_ALL_STRENGTHS,
728 },
729 /* Cipher 30 */
730 {
731 0,
732 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
733 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
734 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
735 SSL_NOT_EXP|SSL_MEDIUM,
736 0,
737 128,
738 128,
739 SSL_ALL_CIPHERS,
740 SSL_ALL_STRENGTHS,
741 },
742 /* Cipher 31 */
743 {
744 0,
745 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
746 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
747 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
748 SSL_NOT_EXP|SSL_MEDIUM,
749 0,
750 128,
751 128,
752 SSL_ALL_CIPHERS,
753 SSL_ALL_STRENGTHS,
754 },
755 /* Cipher 32 */
756 {
757 1,
758 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
759 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
760 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
761 SSL_NOT_EXP|SSL_MEDIUM,
762 0,
763 128,
764 128,
765 SSL_ALL_CIPHERS,
766 SSL_ALL_STRENGTHS,
767 },
768 /* Cipher 33 */
769 {
770 1,
771 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
772 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
773 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
774 SSL_NOT_EXP|SSL_MEDIUM,
775 0,
776 128,
777 128,
778 SSL_ALL_CIPHERS,
779 SSL_ALL_STRENGTHS,
780 },
781 /* Cipher 34 */
782 {
783 1,
784 TLS1_TXT_ADH_WITH_AES_128_SHA,
785 TLS1_CK_ADH_WITH_AES_128_SHA,
786 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
787 SSL_NOT_EXP|SSL_MEDIUM,
788 0,
789 128,
790 128,
791 SSL_ALL_CIPHERS,
792 SSL_ALL_STRENGTHS,
793 },
794
795 /* Cipher 35 */
796 {
797 1,
798 TLS1_TXT_RSA_WITH_AES_256_SHA,
799 TLS1_CK_RSA_WITH_AES_256_SHA,
800 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
801 SSL_NOT_EXP|SSL_HIGH,
802 0,
803 256,
804 256,
805 SSL_ALL_CIPHERS,
806 SSL_ALL_STRENGTHS,
807 },
808 /* Cipher 36 */
809 {
810 0,
811 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
812 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
813 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
814 SSL_NOT_EXP|SSL_HIGH,
815 0,
816 256,
817 256,
818 SSL_ALL_CIPHERS,
819 SSL_ALL_STRENGTHS,
820 },
821 /* Cipher 37 */
822 {
823 0,
824 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
825 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
826 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
827 SSL_NOT_EXP|SSL_HIGH,
828 0,
829 256,
830 256,
831 SSL_ALL_CIPHERS,
832 SSL_ALL_STRENGTHS,
833 },
834 /* Cipher 38 */
835 {
836 1,
837 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
838 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
839 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
840 SSL_NOT_EXP|SSL_HIGH,
841 0,
842 256,
843 256,
844 SSL_ALL_CIPHERS,
845 SSL_ALL_STRENGTHS,
846 },
847 /* Cipher 39 */
848 {
849 1,
850 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
851 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
852 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
853 SSL_NOT_EXP|SSL_HIGH,
854 0,
855 256,
856 256,
857 SSL_ALL_CIPHERS,
858 SSL_ALL_STRENGTHS,
859 },
860 /* Cipher 3A */
861 {
862 1,
863 TLS1_TXT_ADH_WITH_AES_256_SHA,
864 TLS1_CK_ADH_WITH_AES_256_SHA,
865 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
866 SSL_NOT_EXP|SSL_HIGH,
867 0,
868 256,
869 256,
870 SSL_ALL_CIPHERS,
871 SSL_ALL_STRENGTHS,
872 },
623 873
624/* end of list */ 874/* end of list */
625 }; 875 };
@@ -693,6 +943,9 @@ SSL_CIPHER *ssl3_get_cipher(unsigned int u)
693 943
694int ssl3_pending(SSL *s) 944int ssl3_pending(SSL *s)
695 { 945 {
946 if (s->rstate == SSL_ST_READ_BODY)
947 return 0;
948
696 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0; 949 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
697 } 950 }
698 951
@@ -702,6 +955,8 @@ int ssl3_new(SSL *s)
702 955
703 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err; 956 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
704 memset(s3,0,sizeof *s3); 957 memset(s3,0,sizeof *s3);
958 EVP_MD_CTX_init(&s3->finish_dgst1);
959 EVP_MD_CTX_init(&s3->finish_dgst2);
705 960
706 s->s3=s3; 961 s->s3=s3;
707 962
@@ -723,12 +978,14 @@ void ssl3_free(SSL *s)
723 OPENSSL_free(s->s3->wbuf.buf); 978 OPENSSL_free(s->s3->wbuf.buf);
724 if (s->s3->rrec.comp != NULL) 979 if (s->s3->rrec.comp != NULL)
725 OPENSSL_free(s->s3->rrec.comp); 980 OPENSSL_free(s->s3->rrec.comp);
726#ifndef NO_DH 981#ifndef OPENSSL_NO_DH
727 if (s->s3->tmp.dh != NULL) 982 if (s->s3->tmp.dh != NULL)
728 DH_free(s->s3->tmp.dh); 983 DH_free(s->s3->tmp.dh);
729#endif 984#endif
730 if (s->s3->tmp.ca_names != NULL) 985 if (s->s3->tmp.ca_names != NULL)
731 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); 986 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
987 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
988 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
732 memset(s->s3,0,sizeof *s->s3); 989 memset(s->s3,0,sizeof *s->s3);
733 OPENSSL_free(s->s3); 990 OPENSSL_free(s->s3);
734 s->s3=NULL; 991 s->s3=NULL;
@@ -737,6 +994,7 @@ void ssl3_free(SSL *s)
737void ssl3_clear(SSL *s) 994void ssl3_clear(SSL *s)
738 { 995 {
739 unsigned char *rp,*wp; 996 unsigned char *rp,*wp;
997 size_t rlen, wlen;
740 998
741 ssl3_cleanup_key_block(s); 999 ssl3_cleanup_key_block(s);
742 if (s->s3->tmp.ca_names != NULL) 1000 if (s->s3->tmp.ca_names != NULL)
@@ -747,17 +1005,24 @@ void ssl3_clear(SSL *s)
747 OPENSSL_free(s->s3->rrec.comp); 1005 OPENSSL_free(s->s3->rrec.comp);
748 s->s3->rrec.comp=NULL; 1006 s->s3->rrec.comp=NULL;
749 } 1007 }
750#ifndef NO_DH 1008#ifndef OPENSSL_NO_DH
751 if (s->s3->tmp.dh != NULL) 1009 if (s->s3->tmp.dh != NULL)
752 DH_free(s->s3->tmp.dh); 1010 DH_free(s->s3->tmp.dh);
753#endif 1011#endif
754 1012
755 rp=s->s3->rbuf.buf; 1013 rp = s->s3->rbuf.buf;
756 wp=s->s3->wbuf.buf; 1014 wp = s->s3->wbuf.buf;
1015 rlen = s->s3->rbuf.len;
1016 wlen = s->s3->wbuf.len;
1017
1018 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
1019 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
757 1020
758 memset(s->s3,0,sizeof *s->s3); 1021 memset(s->s3,0,sizeof *s->s3);
759 if (rp != NULL) s->s3->rbuf.buf=rp; 1022 s->s3->rbuf.buf = rp;
760 if (wp != NULL) s->s3->wbuf.buf=wp; 1023 s->s3->wbuf.buf = wp;
1024 s->s3->rbuf.len = rlen;
1025 s->s3->wbuf.len = wlen;
761 1026
762 ssl_free_wbio_buffer(s); 1027 ssl_free_wbio_buffer(s);
763 1028
@@ -769,17 +1034,17 @@ void ssl3_clear(SSL *s)
769 s->version=SSL3_VERSION; 1034 s->version=SSL3_VERSION;
770 } 1035 }
771 1036
772long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg) 1037long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
773 { 1038 {
774 int ret=0; 1039 int ret=0;
775 1040
776#if !defined(NO_DSA) || !defined(NO_RSA) 1041#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
777 if ( 1042 if (
778#ifndef NO_RSA 1043#ifndef OPENSSL_NO_RSA
779 cmd == SSL_CTRL_SET_TMP_RSA || 1044 cmd == SSL_CTRL_SET_TMP_RSA ||
780 cmd == SSL_CTRL_SET_TMP_RSA_CB || 1045 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
781#endif 1046#endif
782#ifndef NO_DSA 1047#ifndef OPENSSL_NO_DSA
783 cmd == SSL_CTRL_SET_TMP_DH || 1048 cmd == SSL_CTRL_SET_TMP_DH ||
784 cmd == SSL_CTRL_SET_TMP_DH_CB || 1049 cmd == SSL_CTRL_SET_TMP_DH_CB ||
785#endif 1050#endif
@@ -813,7 +1078,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
813 case SSL_CTRL_GET_FLAGS: 1078 case SSL_CTRL_GET_FLAGS:
814 ret=(int)(s->s3->flags); 1079 ret=(int)(s->s3->flags);
815 break; 1080 break;
816#ifndef NO_RSA 1081#ifndef OPENSSL_NO_RSA
817 case SSL_CTRL_NEED_TMP_RSA: 1082 case SSL_CTRL_NEED_TMP_RSA:
818 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) && 1083 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
819 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || 1084 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
@@ -846,7 +1111,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
846 } 1111 }
847 break; 1112 break;
848#endif 1113#endif
849#ifndef NO_DH 1114#ifndef OPENSSL_NO_DH
850 case SSL_CTRL_SET_TMP_DH: 1115 case SSL_CTRL_SET_TMP_DH:
851 { 1116 {
852 DH *dh = (DH *)parg; 1117 DH *dh = (DH *)parg;
@@ -892,12 +1157,12 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
892 { 1157 {
893 int ret=0; 1158 int ret=0;
894 1159
895#if !defined(NO_DSA) || !defined(NO_RSA) 1160#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
896 if ( 1161 if (
897#ifndef NO_RSA 1162#ifndef OPENSSL_NO_RSA
898 cmd == SSL_CTRL_SET_TMP_RSA_CB || 1163 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
899#endif 1164#endif
900#ifndef NO_DSA 1165#ifndef OPENSSL_NO_DSA
901 cmd == SSL_CTRL_SET_TMP_DH_CB || 1166 cmd == SSL_CTRL_SET_TMP_DH_CB ||
902#endif 1167#endif
903 0) 1168 0)
@@ -912,14 +1177,14 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
912 1177
913 switch (cmd) 1178 switch (cmd)
914 { 1179 {
915#ifndef NO_RSA 1180#ifndef OPENSSL_NO_RSA
916 case SSL_CTRL_SET_TMP_RSA_CB: 1181 case SSL_CTRL_SET_TMP_RSA_CB:
917 { 1182 {
918 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; 1183 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
919 } 1184 }
920 break; 1185 break;
921#endif 1186#endif
922#ifndef NO_DH 1187#ifndef OPENSSL_NO_DH
923 case SSL_CTRL_SET_TMP_DH_CB: 1188 case SSL_CTRL_SET_TMP_DH_CB:
924 { 1189 {
925 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; 1190 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
@@ -932,7 +1197,7 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
932 return(ret); 1197 return(ret);
933 } 1198 }
934 1199
935long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg) 1200long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
936 { 1201 {
937 CERT *cert; 1202 CERT *cert;
938 1203
@@ -940,7 +1205,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
940 1205
941 switch (cmd) 1206 switch (cmd)
942 { 1207 {
943#ifndef NO_RSA 1208#ifndef OPENSSL_NO_RSA
944 case SSL_CTRL_NEED_TMP_RSA: 1209 case SSL_CTRL_NEED_TMP_RSA:
945 if ( (cert->rsa_tmp == NULL) && 1210 if ( (cert->rsa_tmp == NULL) &&
946 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || 1211 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
@@ -985,7 +1250,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
985 } 1250 }
986 break; 1251 break;
987#endif 1252#endif
988#ifndef NO_DH 1253#ifndef OPENSSL_NO_DH
989 case SSL_CTRL_SET_TMP_DH: 1254 case SSL_CTRL_SET_TMP_DH:
990 { 1255 {
991 DH *new=NULL,*dh; 1256 DH *new=NULL,*dh;
@@ -1042,14 +1307,14 @@ long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
1042 1307
1043 switch (cmd) 1308 switch (cmd)
1044 { 1309 {
1045#ifndef NO_RSA 1310#ifndef OPENSSL_NO_RSA
1046 case SSL_CTRL_SET_TMP_RSA_CB: 1311 case SSL_CTRL_SET_TMP_RSA_CB:
1047 { 1312 {
1048 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; 1313 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
1049 } 1314 }
1050 break; 1315 break;
1051#endif 1316#endif
1052#ifndef NO_DH 1317#ifndef OPENSSL_NO_DH
1053 case SSL_CTRL_SET_TMP_DH_CB: 1318 case SSL_CTRL_SET_TMP_DH_CB:
1054 { 1319 {
1055 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; 1320 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
@@ -1114,10 +1379,11 @@ int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
1114 return(2); 1379 return(2);
1115 } 1380 }
1116 1381
1117SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have, 1382SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
1118 STACK_OF(SSL_CIPHER) *pref) 1383 STACK_OF(SSL_CIPHER) *srvr)
1119 { 1384 {
1120 SSL_CIPHER *c,*ret=NULL; 1385 SSL_CIPHER *c,*ret=NULL;
1386 STACK_OF(SSL_CIPHER) *prio, *allow;
1121 int i,j,ok; 1387 int i,j,ok;
1122 CERT *cert; 1388 CERT *cert;
1123 unsigned long alg,mask,emask; 1389 unsigned long alg,mask,emask;
@@ -1125,26 +1391,62 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
1125 /* Let's see which ciphers we can support */ 1391 /* Let's see which ciphers we can support */
1126 cert=s->cert; 1392 cert=s->cert;
1127 1393
1128 sk_SSL_CIPHER_set_cmp_func(pref,ssl_cipher_ptr_id_cmp); 1394#if 0
1395 /* Do not set the compare functions, because this may lead to a
1396 * reordering by "id". We want to keep the original ordering.
1397 * We may pay a price in performance during sk_SSL_CIPHER_find(),
1398 * but would have to pay with the price of sk_SSL_CIPHER_dup().
1399 */
1400 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
1401 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
1402#endif
1129 1403
1130#ifdef CIPHER_DEBUG 1404#ifdef CIPHER_DEBUG
1131 printf("Have:\n"); 1405 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), srvr);
1132 for(i=0 ; i < sk_num(pref) ; ++i) 1406 for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
1133 { 1407 {
1134 c=(SSL_CIPHER *)sk_value(pref,i); 1408 c=sk_SSL_CIPHER_value(srvr,i);
1409 printf("%p:%s\n",c,c->name);
1410 }
1411 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), clnt);
1412 for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
1413 {
1414 c=sk_SSL_CIPHER_value(clnt,i);
1135 printf("%p:%s\n",c,c->name); 1415 printf("%p:%s\n",c,c->name);
1136 } 1416 }
1137#endif 1417#endif
1138 1418
1139 for (i=0; i<sk_SSL_CIPHER_num(have); i++) 1419 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
1420 {
1421 prio = srvr;
1422 allow = clnt;
1423 }
1424 else
1425 {
1426 prio = clnt;
1427 allow = srvr;
1428 }
1429
1430 for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
1140 { 1431 {
1141 c=sk_SSL_CIPHER_value(have,i); 1432 c=sk_SSL_CIPHER_value(prio,i);
1142 1433
1143 ssl_set_cert_masks(cert,c); 1434 ssl_set_cert_masks(cert,c);
1144 mask=cert->mask; 1435 mask=cert->mask;
1145 emask=cert->export_mask; 1436 emask=cert->export_mask;
1146 1437
1438#ifdef KSSL_DEBUG
1439 printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);
1440#endif /* KSSL_DEBUG */
1441
1147 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1442 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
1443#ifndef OPENSSL_NO_KRB5
1444 if (alg & SSL_KRB5)
1445 {
1446 if ( !kssl_keytab_is_available(s->kssl_ctx) )
1447 continue;
1448 }
1449#endif /* OPENSSL_NO_KRB5 */
1148 if (SSL_C_IS_EXPORT(c)) 1450 if (SSL_C_IS_EXPORT(c))
1149 { 1451 {
1150 ok=((alg & emask) == alg)?1:0; 1452 ok=((alg & emask) == alg)?1:0;
@@ -1164,10 +1466,10 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
1164 1466
1165 if (!ok) continue; 1467 if (!ok) continue;
1166 1468
1167 j=sk_SSL_CIPHER_find(pref,c); 1469 j=sk_SSL_CIPHER_find(allow,c);
1168 if (j >= 0) 1470 if (j >= 0)
1169 { 1471 {
1170 ret=sk_SSL_CIPHER_value(pref,j); 1472 ret=sk_SSL_CIPHER_value(allow,j);
1171 break; 1473 break;
1172 } 1474 }
1173 } 1475 }
@@ -1181,31 +1483,31 @@ int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
1181 1483
1182 alg=s->s3->tmp.new_cipher->algorithms; 1484 alg=s->s3->tmp.new_cipher->algorithms;
1183 1485
1184#ifndef NO_DH 1486#ifndef OPENSSL_NO_DH
1185 if (alg & (SSL_kDHr|SSL_kEDH)) 1487 if (alg & (SSL_kDHr|SSL_kEDH))
1186 { 1488 {
1187# ifndef NO_RSA 1489# ifndef OPENSSL_NO_RSA
1188 p[ret++]=SSL3_CT_RSA_FIXED_DH; 1490 p[ret++]=SSL3_CT_RSA_FIXED_DH;
1189# endif 1491# endif
1190# ifndef NO_DSA 1492# ifndef OPENSSL_NO_DSA
1191 p[ret++]=SSL3_CT_DSS_FIXED_DH; 1493 p[ret++]=SSL3_CT_DSS_FIXED_DH;
1192# endif 1494# endif
1193 } 1495 }
1194 if ((s->version == SSL3_VERSION) && 1496 if ((s->version == SSL3_VERSION) &&
1195 (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) 1497 (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
1196 { 1498 {
1197# ifndef NO_RSA 1499# ifndef OPENSSL_NO_RSA
1198 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH; 1500 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
1199# endif 1501# endif
1200# ifndef NO_DSA 1502# ifndef OPENSSL_NO_DSA
1201 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH; 1503 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
1202# endif 1504# endif
1203 } 1505 }
1204#endif /* !NO_DH */ 1506#endif /* !OPENSSL_NO_DH */
1205#ifndef NO_RSA 1507#ifndef OPENSSL_NO_RSA
1206 p[ret++]=SSL3_CT_RSA_SIGN; 1508 p[ret++]=SSL3_CT_RSA_SIGN;
1207#endif 1509#endif
1208#ifndef NO_DSA 1510#ifndef OPENSSL_NO_DSA
1209 p[ret++]=SSL3_CT_DSS_SIGN; 1511 p[ret++]=SSL3_CT_DSS_SIGN;
1210#endif 1512#endif
1211 return(ret); 1513 return(ret);
@@ -1312,13 +1614,12 @@ static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
1312 if (s->s3->renegotiate) ssl3_renegotiate_check(s); 1614 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
1313 s->s3->in_read_app_data=1; 1615 s->s3->in_read_app_data=1;
1314 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); 1616 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
1315 if ((ret == -1) && (s->s3->in_read_app_data == 0)) 1617 if ((ret == -1) && (s->s3->in_read_app_data == 2))
1316 { 1618 {
1317 /* ssl3_read_bytes decided to call s->handshake_func, which 1619 /* ssl3_read_bytes decided to call s->handshake_func, which
1318 * called ssl3_read_bytes to read handshake data. 1620 * called ssl3_read_bytes to read handshake data.
1319 * However, ssl3_read_bytes actually found application data 1621 * However, ssl3_read_bytes actually found application data
1320 * and thinks that application data makes sense here (signalled 1622 * and thinks that application data makes sense here; so disable
1321 * by resetting 'in_read_app_data', strangely); so disable
1322 * handshake processing and try to read application data again. */ 1623 * handshake processing and try to read application data again. */
1323 s->in_handshake++; 1624 s->in_handshake++;
1324 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); 1625 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c
index 9ab76604a6..43e8502b66 100644
--- a/src/lib/libssl/s3_pkt.c
+++ b/src/lib/libssl/s3_pkt.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-2002 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
@@ -117,7 +117,7 @@
117#include "ssl_locl.h" 117#include "ssl_locl.h"
118 118
119static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, 119static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
120 unsigned int len); 120 unsigned int len, int create_empty_fragment);
121static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, 121static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
122 unsigned int len); 122 unsigned int len);
123static int ssl3_get_record(SSL *s); 123static int ssl3_get_record(SSL *s);
@@ -162,15 +162,13 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
162 162
163 { 163 {
164 /* avoid buffer overflow */ 164 /* avoid buffer overflow */
165 int max_max = SSL3_RT_MAX_PACKET_SIZE - s->packet_length; 165 int max_max = s->s3->rbuf.len - s->packet_length;
166 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)
167 max_max += SSL3_RT_MAX_EXTRA;
168 if (max > max_max) 166 if (max > max_max)
169 max = max_max; 167 max = max_max;
170 } 168 }
171 if (n > max) /* does not happen */ 169 if (n > max) /* does not happen */
172 { 170 {
173 SSLerr(SSL_F_SSL3_READ_N,SSL_R_INTERNAL_ERROR); 171 SSLerr(SSL_F_SSL3_READ_N,ERR_R_INTERNAL_ERROR);
174 return -1; 172 return -1;
175 } 173 }
176 174
@@ -231,14 +229,15 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
231static int ssl3_get_record(SSL *s) 229static int ssl3_get_record(SSL *s)
232 { 230 {
233 int ssl_major,ssl_minor,al; 231 int ssl_major,ssl_minor,al;
234 int n,i,ret= -1; 232 int enc_err,n,i,ret= -1;
235 SSL3_RECORD *rr; 233 SSL3_RECORD *rr;
236 SSL_SESSION *sess; 234 SSL_SESSION *sess;
237 unsigned char *p; 235 unsigned char *p;
238 unsigned char md[EVP_MAX_MD_SIZE]; 236 unsigned char md[EVP_MAX_MD_SIZE];
239 short version; 237 short version;
240 unsigned int mac_size; 238 unsigned int mac_size;
241 int clear=0,extra; 239 int clear=0;
240 size_t extra;
242 241
243 rr= &(s->s3->rrec); 242 rr= &(s->s3->rrec);
244 sess=s->session; 243 sess=s->session;
@@ -247,14 +246,20 @@ static int ssl3_get_record(SSL *s)
247 extra=SSL3_RT_MAX_EXTRA; 246 extra=SSL3_RT_MAX_EXTRA;
248 else 247 else
249 extra=0; 248 extra=0;
249 if (extra != s->s3->rbuf.len - SSL3_RT_MAX_PACKET_SIZE)
250 {
251 /* actually likely an application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER
252 * set after ssl3_setup_buffers() was done */
253 SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR);
254 return -1;
255 }
250 256
251again: 257again:
252 /* check if we have the header */ 258 /* check if we have the header */
253 if ( (s->rstate != SSL_ST_READ_BODY) || 259 if ( (s->rstate != SSL_ST_READ_BODY) ||
254 (s->packet_length < SSL3_RT_HEADER_LENGTH)) 260 (s->packet_length < SSL3_RT_HEADER_LENGTH))
255 { 261 {
256 n=ssl3_read_n(s,SSL3_RT_HEADER_LENGTH, 262 n=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);
257 SSL3_RT_MAX_PACKET_SIZE,0);
258 if (n <= 0) return(n); /* error or non-blocking */ 263 if (n <= 0) return(n); /* error or non-blocking */
259 s->rstate=SSL_ST_READ_BODY; 264 s->rstate=SSL_ST_READ_BODY;
260 265
@@ -291,8 +296,7 @@ again:
291 goto err; 296 goto err;
292 } 297 }
293 298
294 if (rr->length > 299 if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
295 (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
296 { 300 {
297 al=SSL_AD_RECORD_OVERFLOW; 301 al=SSL_AD_RECORD_OVERFLOW;
298 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG); 302 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG);
@@ -304,7 +308,7 @@ again:
304 308
305 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ 309 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */
306 310
307 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH)) 311 if (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH)
308 { 312 {
309 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ 313 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */
310 i=rr->length; 314 i=rr->length;
@@ -332,7 +336,7 @@ again:
332 * rr->length bytes of encrypted compressed stuff. */ 336 * rr->length bytes of encrypted compressed stuff. */
333 337
334 /* check is not needed I believe */ 338 /* check is not needed I believe */
335 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) 339 if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
336 { 340 {
337 al=SSL_AD_RECORD_OVERFLOW; 341 al=SSL_AD_RECORD_OVERFLOW;
338 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG); 342 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
@@ -342,16 +346,23 @@ again:
342 /* decrypt in place in 'rr->input' */ 346 /* decrypt in place in 'rr->input' */
343 rr->data=rr->input; 347 rr->data=rr->input;
344 348
345 if (!s->method->ssl3_enc->enc(s,0)) 349 enc_err = s->method->ssl3_enc->enc(s,0);
350 if (enc_err <= 0)
346 { 351 {
347 al=SSL_AD_DECRYPT_ERROR; 352 if (enc_err == 0)
348 goto f_err; 353 /* SSLerr() and ssl3_send_alert() have been called */
354 goto err;
355
356 /* otherwise enc_err == -1 */
357 goto decryption_failed_or_bad_record_mac;
349 } 358 }
359
350#ifdef TLS_DEBUG 360#ifdef TLS_DEBUG
351printf("dec %d\n",rr->length); 361printf("dec %d\n",rr->length);
352{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); } 362{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); }
353printf("\n"); 363printf("\n");
354#endif 364#endif
365
355 /* r->length is now the compressed data plus mac */ 366 /* r->length is now the compressed data plus mac */
356 if ( (sess == NULL) || 367 if ( (sess == NULL) ||
357 (s->enc_read_ctx == NULL) || 368 (s->enc_read_ctx == NULL) ||
@@ -364,33 +375,37 @@ printf("\n");
364 375
365 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size) 376 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)
366 { 377 {
378#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */
367 al=SSL_AD_RECORD_OVERFLOW; 379 al=SSL_AD_RECORD_OVERFLOW;
368 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); 380 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
369 goto f_err; 381 goto f_err;
382#else
383 goto decryption_failed_or_bad_record_mac;
384#endif
370 } 385 }
371 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ 386 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */
372 if (rr->length < mac_size) 387 if (rr->length < mac_size)
373 { 388 {
389#if 0 /* OK only for stream ciphers */
374 al=SSL_AD_DECODE_ERROR; 390 al=SSL_AD_DECODE_ERROR;
375 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); 391 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
376 goto f_err; 392 goto f_err;
393#else
394 goto decryption_failed_or_bad_record_mac;
395#endif
377 } 396 }
378 rr->length-=mac_size; 397 rr->length-=mac_size;
379 i=s->method->ssl3_enc->mac(s,md,0); 398 i=s->method->ssl3_enc->mac(s,md,0);
380 if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) 399 if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0)
381 { 400 {
382 al=SSL_AD_BAD_RECORD_MAC; 401 goto decryption_failed_or_bad_record_mac;
383 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_MAC_DECODE);
384 ret= -1;
385 goto f_err;
386 } 402 }
387 } 403 }
388 404
389 /* r->length is now just compressed */ 405 /* r->length is now just compressed */
390 if (s->expand != NULL) 406 if (s->expand != NULL)
391 { 407 {
392 if (rr->length > 408 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra)
393 (unsigned int)SSL3_RT_MAX_COMPRESSED_LENGTH+extra)
394 { 409 {
395 al=SSL_AD_RECORD_OVERFLOW; 410 al=SSL_AD_RECORD_OVERFLOW;
396 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG); 411 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);
@@ -404,7 +419,7 @@ printf("\n");
404 } 419 }
405 } 420 }
406 421
407 if (rr->length > (unsigned int)SSL3_RT_MAX_PLAIN_LENGTH+extra) 422 if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra)
408 { 423 {
409 al=SSL_AD_RECORD_OVERFLOW; 424 al=SSL_AD_RECORD_OVERFLOW;
410 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG); 425 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);
@@ -427,6 +442,15 @@ printf("\n");
427 if (rr->length == 0) goto again; 442 if (rr->length == 0) goto again;
428 443
429 return(1); 444 return(1);
445
446decryption_failed_or_bad_record_mac:
447 /* Separate 'decryption_failed' alert was introduced with TLS 1.0,
448 * SSL 3.0 only has 'bad_record_mac'. But unless a decryption
449 * failure is directly visible from the ciphertext anyway,
450 * we should not reveal which kind of error occured -- this
451 * might become visible to an attacker (e.g. via logfile) */
452 al=SSL_AD_BAD_RECORD_MAC;
453 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
430f_err: 454f_err:
431 ssl3_send_alert(s,SSL3_AL_FATAL,al); 455 ssl3_send_alert(s,SSL3_AL_FATAL,al);
432err: 456err:
@@ -488,7 +512,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
488 if (i == 0) 512 if (i == 0)
489 { 513 {
490 SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 514 SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
491 return(-1); 515 return -1;
492 } 516 }
493 } 517 }
494 518
@@ -500,18 +524,22 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
500 else 524 else
501 nw=n; 525 nw=n;
502 526
503 i=do_ssl3_write(s,type,&(buf[tot]),nw); 527 i=do_ssl3_write(s, type, &(buf[tot]), nw, 0);
504 if (i <= 0) 528 if (i <= 0)
505 { 529 {
506 s->s3->wnum=tot; 530 s->s3->wnum=tot;
507 return(i); 531 return i;
508 } 532 }
509 533
510 if ((i == (int)n) || 534 if ((i == (int)n) ||
511 (type == SSL3_RT_APPLICATION_DATA && 535 (type == SSL3_RT_APPLICATION_DATA &&
512 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) 536 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)))
513 { 537 {
514 return(tot+i); 538 /* next chunk of data should get another prepended empty fragment
539 * in ciphersuites with known-IV weakness: */
540 s->s3->empty_fragment_done = 0;
541
542 return tot+i;
515 } 543 }
516 544
517 n-=i; 545 n-=i;
@@ -520,15 +548,16 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
520 } 548 }
521 549
522static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, 550static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
523 unsigned int len) 551 unsigned int len, int create_empty_fragment)
524 { 552 {
525 unsigned char *p,*plen; 553 unsigned char *p,*plen;
526 int i,mac_size,clear=0; 554 int i,mac_size,clear=0;
555 int prefix_len = 0;
527 SSL3_RECORD *wr; 556 SSL3_RECORD *wr;
528 SSL3_BUFFER *wb; 557 SSL3_BUFFER *wb;
529 SSL_SESSION *sess; 558 SSL_SESSION *sess;
530 559
531 /* first check is there is a SSL3_RECORD still being written 560 /* first check if there is a SSL3_BUFFER still being written
532 * out. This will happen with non blocking IO */ 561 * out. This will happen with non blocking IO */
533 if (s->s3->wbuf.left != 0) 562 if (s->s3->wbuf.left != 0)
534 return(ssl3_write_pending(s,type,buf,len)); 563 return(ssl3_write_pending(s,type,buf,len));
@@ -542,7 +571,8 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
542 /* if it went, fall through and send more stuff */ 571 /* if it went, fall through and send more stuff */
543 } 572 }
544 573
545 if (len == 0) return(len); 574 if (len == 0 && !create_empty_fragment)
575 return 0;
546 576
547 wr= &(s->s3->wrec); 577 wr= &(s->s3->wrec);
548 wb= &(s->s3->wbuf); 578 wb= &(s->s3->wbuf);
@@ -558,16 +588,44 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
558 else 588 else
559 mac_size=EVP_MD_size(s->write_hash); 589 mac_size=EVP_MD_size(s->write_hash);
560 590
561 p=wb->buf; 591 /* 'create_empty_fragment' is true only when this function calls itself */
592 if (!clear && !create_empty_fragment && !s->s3->empty_fragment_done)
593 {
594 /* countermeasure against known-IV weakness in CBC ciphersuites
595 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
596
597 if (s->s3->need_empty_fragments && type == SSL3_RT_APPLICATION_DATA)
598 {
599 /* recursive function call with 'create_empty_fragment' set;
600 * this prepares and buffers the data for an empty fragment
601 * (these 'prefix_len' bytes are sent out later
602 * together with the actual payload) */
603 prefix_len = do_ssl3_write(s, type, buf, 0, 1);
604 if (prefix_len <= 0)
605 goto err;
606
607 if (s->s3->wbuf.len < (size_t)prefix_len + SSL3_RT_MAX_PACKET_SIZE)
608 {
609 /* insufficient space */
610 SSLerr(SSL_F_DO_SSL3_WRITE, ERR_R_INTERNAL_ERROR);
611 goto err;
612 }
613 }
614
615 s->s3->empty_fragment_done = 1;
616 }
617
618 p = wb->buf + prefix_len;
562 619
563 /* write the header */ 620 /* write the header */
621
564 *(p++)=type&0xff; 622 *(p++)=type&0xff;
565 wr->type=type; 623 wr->type=type;
566 624
567 *(p++)=(s->version>>8); 625 *(p++)=(s->version>>8);
568 *(p++)=s->version&0xff; 626 *(p++)=s->version&0xff;
569 627
570 /* record where we are to write out packet length */ 628 /* field where we are to write out packet length */
571 plen=p; 629 plen=p;
572 p+=2; 630 p+=2;
573 631
@@ -618,19 +676,28 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
618 wr->type=type; /* not needed but helps for debugging */ 676 wr->type=type; /* not needed but helps for debugging */
619 wr->length+=SSL3_RT_HEADER_LENGTH; 677 wr->length+=SSL3_RT_HEADER_LENGTH;
620 678
621 /* Now lets setup wb */ 679 if (create_empty_fragment)
622 wb->left=wr->length; 680 {
623 wb->offset=0; 681 /* we are in a recursive call;
682 * just return the length, don't write out anything here
683 */
684 return wr->length;
685 }
686
687 /* now let's set up wb */
688 wb->left = prefix_len + wr->length;
689 wb->offset = 0;
624 690
691 /* memorize arguments so that ssl3_write_pending can detect bad write retries later */
625 s->s3->wpend_tot=len; 692 s->s3->wpend_tot=len;
626 s->s3->wpend_buf=buf; 693 s->s3->wpend_buf=buf;
627 s->s3->wpend_type=type; 694 s->s3->wpend_type=type;
628 s->s3->wpend_ret=len; 695 s->s3->wpend_ret=len;
629 696
630 /* we now just need to write the buffer */ 697 /* we now just need to write the buffer */
631 return(ssl3_write_pending(s,type,buf,len)); 698 return ssl3_write_pending(s,type,buf,len);
632err: 699err:
633 return(-1); 700 return -1;
634 } 701 }
635 702
636/* if s->s3->wbuf.left != 0, we need to call this */ 703/* if s->s3->wbuf.left != 0, we need to call this */
@@ -709,7 +776,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
709 int al,i,j,ret; 776 int al,i,j,ret;
710 unsigned int n; 777 unsigned int n;
711 SSL3_RECORD *rr; 778 SSL3_RECORD *rr;
712 void (*cb)()=NULL; 779 void (*cb)(const SSL *ssl,int type2,int val)=NULL;
713 780
714 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ 781 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */
715 if (!ssl3_setup_buffers(s)) 782 if (!ssl3_setup_buffers(s))
@@ -718,7 +785,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
718 if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) || 785 if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) ||
719 (peek && (type != SSL3_RT_APPLICATION_DATA))) 786 (peek && (type != SSL3_RT_APPLICATION_DATA)))
720 { 787 {
721 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR); 788 SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR);
722 return -1; 789 return -1;
723 } 790 }
724 791
@@ -890,6 +957,9 @@ start:
890 goto err; 957 goto err;
891 } 958 }
892 959
960 if (s->msg_callback)
961 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
962
893 if (SSL_is_init_finished(s) && 963 if (SSL_is_init_finished(s) &&
894 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && 964 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
895 !s->s3->renegotiate) 965 !s->s3->renegotiate)
@@ -935,6 +1005,9 @@ start:
935 1005
936 s->s3->alert_fragment_len = 0; 1006 s->s3->alert_fragment_len = 0;
937 1007
1008 if (s->msg_callback)
1009 s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg);
1010
938 if (s->info_callback != NULL) 1011 if (s->info_callback != NULL)
939 cb=s->info_callback; 1012 cb=s->info_callback;
940 else if (s->ctx->info_callback != NULL) 1013 else if (s->ctx->info_callback != NULL)
@@ -998,6 +1071,10 @@ start:
998 } 1071 }
999 1072
1000 rr->length=0; 1073 rr->length=0;
1074
1075 if (s->msg_callback)
1076 s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg);
1077
1001 s->s3->change_cipher_spec=1; 1078 s->s3->change_cipher_spec=1;
1002 if (!do_change_cipher_spec(s)) 1079 if (!do_change_cipher_spec(s))
1003 goto err; 1080 goto err;
@@ -1052,10 +1129,11 @@ start:
1052 switch (rr->type) 1129 switch (rr->type)
1053 { 1130 {
1054 default: 1131 default:
1055#ifndef NO_TLS 1132#ifndef OPENSSL_NO_TLS
1056 /* TLS just ignores unknown message types */ 1133 /* TLS just ignores unknown message types */
1057 if (s->version == TLS1_VERSION) 1134 if (s->version == TLS1_VERSION)
1058 { 1135 {
1136 rr->length = 0;
1059 goto start; 1137 goto start;
1060 } 1138 }
1061#endif 1139#endif
@@ -1069,7 +1147,7 @@ start:
1069 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that 1147 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that
1070 * should not happen when type != rr->type */ 1148 * should not happen when type != rr->type */
1071 al=SSL_AD_UNEXPECTED_MESSAGE; 1149 al=SSL_AD_UNEXPECTED_MESSAGE;
1072 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_INTERNAL_ERROR); 1150 SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR);
1073 goto f_err; 1151 goto f_err;
1074 case SSL3_RT_APPLICATION_DATA: 1152 case SSL3_RT_APPLICATION_DATA:
1075 /* At this point, we were expecting handshake data, 1153 /* At this point, we were expecting handshake data,
@@ -1092,7 +1170,7 @@ start:
1092 ) 1170 )
1093 )) 1171 ))
1094 { 1172 {
1095 s->s3->in_read_app_data=0; 1173 s->s3->in_read_app_data=2;
1096 return(-1); 1174 return(-1);
1097 } 1175 }
1098 else 1176 else
@@ -1156,6 +1234,8 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1156 { 1234 {
1157 /* Map tls/ssl alert value to correct one */ 1235 /* Map tls/ssl alert value to correct one */
1158 desc=s->method->ssl3_enc->alert_value(desc); 1236 desc=s->method->ssl3_enc->alert_value(desc);
1237 if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)
1238 desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */
1159 if (desc < 0) return; 1239 if (desc < 0) return;
1160 /* If a fatal one, remove from cache */ 1240 /* If a fatal one, remove from cache */
1161 if ((level == 2) && (s->session != NULL)) 1241 if ((level == 2) && (s->session != NULL))
@@ -1164,7 +1244,7 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1164 s->s3->alert_dispatch=1; 1244 s->s3->alert_dispatch=1;
1165 s->s3->send_alert[0]=level; 1245 s->s3->send_alert[0]=level;
1166 s->s3->send_alert[1]=desc; 1246 s->s3->send_alert[1]=desc;
1167 if (s->s3->wbuf.left == 0) /* data still being written out */ 1247 if (s->s3->wbuf.left == 0) /* data still being written out? */
1168 ssl3_dispatch_alert(s); 1248 ssl3_dispatch_alert(s);
1169 /* else data is still being written out, we will get written 1249 /* else data is still being written out, we will get written
1170 * some time in the future */ 1250 * some time in the future */
@@ -1173,22 +1253,25 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1173int ssl3_dispatch_alert(SSL *s) 1253int ssl3_dispatch_alert(SSL *s)
1174 { 1254 {
1175 int i,j; 1255 int i,j;
1176 void (*cb)()=NULL; 1256 void (*cb)(const SSL *ssl,int type,int val)=NULL;
1177 1257
1178 s->s3->alert_dispatch=0; 1258 s->s3->alert_dispatch=0;
1179 i=do_ssl3_write(s,SSL3_RT_ALERT,&s->s3->send_alert[0],2); 1259 i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], 2, 0);
1180 if (i <= 0) 1260 if (i <= 0)
1181 { 1261 {
1182 s->s3->alert_dispatch=1; 1262 s->s3->alert_dispatch=1;
1183 } 1263 }
1184 else 1264 else
1185 { 1265 {
1186 /* If it is important, send it now. If the message 1266 /* Alert sent to BIO. If it is important, flush it now.
1187 * does not get sent due to non-blocking IO, we will 1267 * If the message does not get sent due to non-blocking IO,
1188 * not worry too much. */ 1268 * we will not worry too much. */
1189 if (s->s3->send_alert[0] == SSL3_AL_FATAL) 1269 if (s->s3->send_alert[0] == SSL3_AL_FATAL)
1190 (void)BIO_flush(s->wbio); 1270 (void)BIO_flush(s->wbio);
1191 1271
1272 if (s->msg_callback)
1273 s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg);
1274
1192 if (s->info_callback != NULL) 1275 if (s->info_callback != NULL)
1193 cb=s->info_callback; 1276 cb=s->info_callback;
1194 else if (s->ctx->info_callback != NULL) 1277 else if (s->ctx->info_callback != NULL)
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c
index 258af84867..99b6a86983 100644
--- a/src/lib/libssl/s3_srvr.c
+++ b/src/lib/libssl/s3_srvr.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#define REUSE_CIPHER_BUG 112#define REUSE_CIPHER_BUG
60#define NETSCAPE_HANG_BUG 113#define NETSCAPE_HANG_BUG
@@ -64,11 +117,12 @@
64#include <openssl/buffer.h> 117#include <openssl/buffer.h>
65#include <openssl/rand.h> 118#include <openssl/rand.h>
66#include <openssl/objects.h> 119#include <openssl/objects.h>
67#include <openssl/md5.h>
68#include <openssl/sha.h>
69#include <openssl/evp.h> 120#include <openssl/evp.h>
70#include <openssl/x509.h> 121#include <openssl/x509.h>
122#include <openssl/krb5_asn.h>
71#include "ssl_locl.h" 123#include "ssl_locl.h"
124#include "kssl_lcl.h"
125#include <openssl/md5.h>
72 126
73static SSL_METHOD *ssl3_get_server_method(int ver); 127static SSL_METHOD *ssl3_get_server_method(int ver);
74static int ssl3_get_client_hello(SSL *s); 128static int ssl3_get_client_hello(SSL *s);
@@ -110,7 +164,7 @@ int ssl3_accept(SSL *s)
110 { 164 {
111 BUF_MEM *buf; 165 BUF_MEM *buf;
112 unsigned long l,Time=time(NULL); 166 unsigned long l,Time=time(NULL);
113 void (*cb)()=NULL; 167 void (*cb)(const SSL *ssl,int type,int val)=NULL;
114 long num1; 168 long num1;
115 int ret= -1; 169 int ret= -1;
116 int new_state,state,skip=0; 170 int new_state,state,skip=0;
@@ -125,8 +179,8 @@ int ssl3_accept(SSL *s)
125 cb=s->ctx->info_callback; 179 cb=s->ctx->info_callback;
126 180
127 /* init things to blank */ 181 /* init things to blank */
128 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
129 s->in_handshake++; 182 s->in_handshake++;
183 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
130 184
131 if (s->cert == NULL) 185 if (s->cert == NULL)
132 { 186 {
@@ -154,7 +208,7 @@ int ssl3_accept(SSL *s)
154 208
155 if ((s->version>>8) != 3) 209 if ((s->version>>8) != 3)
156 { 210 {
157 SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_INTERNAL_ERROR); 211 SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
158 return -1; 212 return -1;
159 } 213 }
160 s->type=SSL_ST_ACCEPT; 214 s->type=SSL_ST_ACCEPT;
@@ -180,21 +234,23 @@ int ssl3_accept(SSL *s)
180 goto end; 234 goto end;
181 } 235 }
182 236
183 /* Ok, we now need to push on a buffering BIO so that
184 * the output is sent in a way that TCP likes :-)
185 */
186 if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }
187
188 s->init_num=0; 237 s->init_num=0;
189 238
190 if (s->state != SSL_ST_RENEGOTIATE) 239 if (s->state != SSL_ST_RENEGOTIATE)
191 { 240 {
241 /* Ok, we now need to push on a buffering BIO so that
242 * the output is sent in a way that TCP likes :-)
243 */
244 if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }
245
192 ssl3_init_finished_mac(s); 246 ssl3_init_finished_mac(s);
193 s->state=SSL3_ST_SR_CLNT_HELLO_A; 247 s->state=SSL3_ST_SR_CLNT_HELLO_A;
194 s->ctx->stats.sess_accept++; 248 s->ctx->stats.sess_accept++;
195 } 249 }
196 else 250 else
197 { 251 {
252 /* s->state == SSL_ST_RENEGOTIATE,
253 * we will just send a HelloRequest */
198 s->ctx->stats.sess_accept_renegotiate++; 254 s->ctx->stats.sess_accept_renegotiate++;
199 s->state=SSL3_ST_SW_HELLO_REQ_A; 255 s->state=SSL3_ST_SW_HELLO_REQ_A;
200 } 256 }
@@ -215,9 +271,7 @@ int ssl3_accept(SSL *s)
215 271
216 case SSL3_ST_SW_HELLO_REQ_C: 272 case SSL3_ST_SW_HELLO_REQ_C:
217 s->state=SSL_ST_OK; 273 s->state=SSL_ST_OK;
218 ret=1; 274 break;
219 goto end;
220 /* break; */
221 275
222 case SSL3_ST_SR_CLNT_HELLO_A: 276 case SSL3_ST_SR_CLNT_HELLO_A:
223 case SSL3_ST_SR_CLNT_HELLO_B: 277 case SSL3_ST_SR_CLNT_HELLO_B:
@@ -226,6 +280,7 @@ int ssl3_accept(SSL *s)
226 s->shutdown=0; 280 s->shutdown=0;
227 ret=ssl3_get_client_hello(s); 281 ret=ssl3_get_client_hello(s);
228 if (ret <= 0) goto end; 282 if (ret <= 0) goto end;
283 s->new_session = 2;
229 s->state=SSL3_ST_SW_SRVR_HELLO_A; 284 s->state=SSL3_ST_SW_SRVR_HELLO_A;
230 s->init_num=0; 285 s->init_num=0;
231 break; 286 break;
@@ -262,7 +317,15 @@ int ssl3_accept(SSL *s)
262 317
263 /* clear this, it may get reset by 318 /* clear this, it may get reset by
264 * send_server_key_exchange */ 319 * send_server_key_exchange */
265 if (s->options & SSL_OP_EPHEMERAL_RSA) 320 if ((s->options & SSL_OP_EPHEMERAL_RSA)
321#ifndef OPENSSL_NO_KRB5
322 && !(l & SSL_KRB5)
323#endif /* OPENSSL_NO_KRB5 */
324 )
325 /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key
326 * even when forbidden by protocol specs
327 * (handshake may fail as clients are not required to
328 * be able to handle this) */
266 s->s3->tmp.use_rsa_tmp=1; 329 s->s3->tmp.use_rsa_tmp=1;
267 else 330 else
268 s->s3->tmp.use_rsa_tmp=0; 331 s->s3->tmp.use_rsa_tmp=0;
@@ -304,7 +367,9 @@ int ssl3_accept(SSL *s)
304 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) && 367 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) &&
305 /* ... except when the application insists on verification 368 /* ... except when the application insists on verification
306 * (against the specs, but s3_clnt.c accepts this for SSL 3) */ 369 * (against the specs, but s3_clnt.c accepts this for SSL 3) */
307 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT))) 370 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
371 /* never request cert in Kerberos ciphersuites */
372 (s->s3->tmp.new_cipher->algorithms & SSL_aKRB5))
308 { 373 {
309 /* no cert request */ 374 /* no cert request */
310 skip=1; 375 skip=1;
@@ -456,18 +521,25 @@ int ssl3_accept(SSL *s)
456 /* remove buffering on output */ 521 /* remove buffering on output */
457 ssl_free_wbio_buffer(s); 522 ssl_free_wbio_buffer(s);
458 523
459 s->new_session=0;
460 s->init_num=0; 524 s->init_num=0;
461 525
462 ssl_update_cache(s,SSL_SESS_CACHE_SERVER); 526 if (s->new_session == 2) /* skipped if we just sent a HelloRequest */
463 527 {
464 s->ctx->stats.sess_accept_good++; 528 /* actually not necessarily a 'new' session unless
465 /* s->server=1; */ 529 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
466 s->handshake_func=ssl3_accept; 530
467 ret=1; 531 s->new_session=0;
468 532
469 if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); 533 ssl_update_cache(s,SSL_SESS_CACHE_SERVER);
470 534
535 s->ctx->stats.sess_accept_good++;
536 /* s->server=1; */
537 s->handshake_func=ssl3_accept;
538
539 if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);
540 }
541
542 ret = 1;
471 goto end; 543 goto end;
472 /* break; */ 544 /* break; */
473 545
@@ -500,9 +572,9 @@ int ssl3_accept(SSL *s)
500end: 572end:
501 /* BIO_flush(s->wbio); */ 573 /* BIO_flush(s->wbio); */
502 574
575 s->in_handshake--;
503 if (cb != NULL) 576 if (cb != NULL)
504 cb(s,SSL_CB_ACCEPT_EXIT,ret); 577 cb(s,SSL_CB_ACCEPT_EXIT,ret);
505 s->in_handshake--;
506 return(ret); 578 return(ret);
507 } 579 }
508 580
@@ -533,11 +605,13 @@ static int ssl3_check_client_hello(SSL *s)
533 int ok; 605 int ok;
534 long n; 606 long n;
535 607
608 /* this function is called when we really expect a Certificate message,
609 * so permit appropriate message length */
536 n=ssl3_get_message(s, 610 n=ssl3_get_message(s,
537 SSL3_ST_SR_CERT_A, 611 SSL3_ST_SR_CERT_A,
538 SSL3_ST_SR_CERT_B, 612 SSL3_ST_SR_CERT_B,
539 -1, 613 -1,
540 SSL3_RT_MAX_PLAIN_LENGTH, 614 s->max_cert_list,
541 &ok); 615 &ok);
542 if (!ok) return((int)n); 616 if (!ok) return((int)n);
543 s->s3->tmp.reuse_message = 1; 617 s->s3->tmp.reuse_message = 1;
@@ -547,7 +621,7 @@ static int ssl3_check_client_hello(SSL *s)
547 * which will now be aborted. (A full SSL_clear would be too much.) 621 * which will now be aborted. (A full SSL_clear would be too much.)
548 * I hope that tmp.dh is the only thing that may need to be cleared 622 * I hope that tmp.dh is the only thing that may need to be cleared
549 * when a handshake is not completed ... */ 623 * when a handshake is not completed ... */
550#ifndef NO_DH 624#ifndef OPENSSL_NO_DH
551 if (s->s3->tmp.dh != NULL) 625 if (s->s3->tmp.dh != NULL)
552 { 626 {
553 DH_free(s->s3->tmp.dh); 627 DH_free(s->s3->tmp.dh);
@@ -588,13 +662,25 @@ static int ssl3_get_client_hello(SSL *s)
588 &ok); 662 &ok);
589 663
590 if (!ok) return((int)n); 664 if (!ok) return((int)n);
591 d=p=(unsigned char *)s->init_buf->data; 665 d=p=(unsigned char *)s->init_msg;
592 666
593 /* use version from inside client hello, not from record header 667 /* use version from inside client hello, not from record header
594 * (may differ: see RFC 2246, Appendix E, second paragraph) */ 668 * (may differ: see RFC 2246, Appendix E, second paragraph) */
595 s->client_version=(((int)p[0])<<8)|(int)p[1]; 669 s->client_version=(((int)p[0])<<8)|(int)p[1];
596 p+=2; 670 p+=2;
597 671
672 if (s->client_version < s->version)
673 {
674 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
675 if ((s->client_version>>8) == SSL3_VERSION_MAJOR)
676 {
677 /* similar to ssl3_get_record, send alert using remote version number */
678 s->version = s->client_version;
679 }
680 al = SSL_AD_PROTOCOL_VERSION;
681 goto f_err;
682 }
683
598 /* load the client random */ 684 /* load the client random */
599 memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE); 685 memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE);
600 p+=SSL3_RANDOM_SIZE; 686 p+=SSL3_RANDOM_SIZE;
@@ -603,7 +689,15 @@ static int ssl3_get_client_hello(SSL *s)
603 j= *(p++); 689 j= *(p++);
604 690
605 s->hit=0; 691 s->hit=0;
606 if (j == 0) 692 /* Versions before 0.9.7 always allow session reuse during renegotiation
693 * (i.e. when s->new_session is true), option
694 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is new with 0.9.7.
695 * Maybe this optional behaviour should always have been the default,
696 * but we cannot safely change the default behaviour (or new applications
697 * might be written that become totally unsecure when compiled with
698 * an earlier library version)
699 */
700 if (j == 0 || (s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)))
607 { 701 {
608 if (!ssl_get_new_session(s,1)) 702 if (!ssl_get_new_session(s,1))
609 goto err; 703 goto err;
@@ -633,7 +727,7 @@ static int ssl3_get_client_hello(SSL *s)
633 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED); 727 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED);
634 goto f_err; 728 goto f_err;
635 } 729 }
636 if ((i+p) > (d+n)) 730 if ((p+i) >= (d+n))
637 { 731 {
638 /* not enough data */ 732 /* not enough data */
639 al=SSL_AD_DECODE_ERROR; 733 al=SSL_AD_DECODE_ERROR;
@@ -690,6 +784,13 @@ static int ssl3_get_client_hello(SSL *s)
690 784
691 /* compression */ 785 /* compression */
692 i= *(p++); 786 i= *(p++);
787 if ((p+i) > (d+n))
788 {
789 /* not enough data */
790 al=SSL_AD_DECODE_ERROR;
791 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);
792 goto f_err;
793 }
693 q=p; 794 q=p;
694 for (j=0; j<i; j++) 795 for (j=0; j<i; j++)
695 { 796 {
@@ -737,7 +838,7 @@ static int ssl3_get_client_hello(SSL *s)
737 /* TLS does not mind if there is extra stuff */ 838 /* TLS does not mind if there is extra stuff */
738 if (s->version == SSL3_VERSION) 839 if (s->version == SSL3_VERSION)
739 { 840 {
740 if (p > (d+n)) 841 if (p < (d+n))
741 { 842 {
742 /* wrong number of bytes, 843 /* wrong number of bytes,
743 * there could be more to follow */ 844 * there could be more to follow */
@@ -747,7 +848,7 @@ static int ssl3_get_client_hello(SSL *s)
747 } 848 }
748 } 849 }
749 850
750 /* Given s->session->ciphers and ssl_get_ciphers_by_id(s), we must 851 /* Given s->session->ciphers and SSL_get_ciphers, we must
751 * pick a cipher */ 852 * pick a cipher */
752 853
753 if (!s->hit) 854 if (!s->hit)
@@ -764,7 +865,7 @@ static int ssl3_get_client_hello(SSL *s)
764 } 865 }
765 ciphers=NULL; 866 ciphers=NULL;
766 c=ssl3_choose_cipher(s,s->session->ciphers, 867 c=ssl3_choose_cipher(s,s->session->ciphers,
767 ssl_get_ciphers_by_id(s)); 868 SSL_get_ciphers(s));
768 869
769 if (c == NULL) 870 if (c == NULL)
770 { 871 {
@@ -919,14 +1020,14 @@ static int ssl3_send_server_done(SSL *s)
919 1020
920static int ssl3_send_server_key_exchange(SSL *s) 1021static int ssl3_send_server_key_exchange(SSL *s)
921 { 1022 {
922#ifndef NO_RSA 1023#ifndef OPENSSL_NO_RSA
923 unsigned char *q; 1024 unsigned char *q;
924 int j,num; 1025 int j,num;
925 RSA *rsa; 1026 RSA *rsa;
926 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1027 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
927 unsigned int u; 1028 unsigned int u;
928#endif 1029#endif
929#ifndef NO_DH 1030#ifndef OPENSSL_NO_DH
930 DH *dh=NULL,*dhp; 1031 DH *dh=NULL,*dhp;
931#endif 1032#endif
932 EVP_PKEY *pkey; 1033 EVP_PKEY *pkey;
@@ -940,6 +1041,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
940 BUF_MEM *buf; 1041 BUF_MEM *buf;
941 EVP_MD_CTX md_ctx; 1042 EVP_MD_CTX md_ctx;
942 1043
1044 EVP_MD_CTX_init(&md_ctx);
943 if (s->state == SSL3_ST_SW_KEY_EXCH_A) 1045 if (s->state == SSL3_ST_SW_KEY_EXCH_A)
944 { 1046 {
945 type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK; 1047 type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK;
@@ -949,7 +1051,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
949 1051
950 r[0]=r[1]=r[2]=r[3]=NULL; 1052 r[0]=r[1]=r[2]=r[3]=NULL;
951 n=0; 1053 n=0;
952#ifndef NO_RSA 1054#ifndef OPENSSL_NO_RSA
953 if (type & SSL_kRSA) 1055 if (type & SSL_kRSA)
954 { 1056 {
955 rsa=cert->rsa_tmp; 1057 rsa=cert->rsa_tmp;
@@ -964,7 +1066,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
964 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY); 1066 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY);
965 goto f_err; 1067 goto f_err;
966 } 1068 }
967 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 1069 RSA_up_ref(rsa);
968 cert->rsa_tmp=rsa; 1070 cert->rsa_tmp=rsa;
969 } 1071 }
970 if (rsa == NULL) 1072 if (rsa == NULL)
@@ -979,7 +1081,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
979 } 1081 }
980 else 1082 else
981#endif 1083#endif
982#ifndef NO_DH 1084#ifndef OPENSSL_NO_DH
983 if (type & SSL_kEDH) 1085 if (type & SSL_kEDH)
984 { 1086 {
985 dhp=cert->dh_tmp; 1087 dhp=cert->dh_tmp;
@@ -997,7 +1099,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
997 if (s->s3->tmp.dh != NULL) 1099 if (s->s3->tmp.dh != NULL)
998 { 1100 {
999 DH_free(dh); 1101 DH_free(dh);
1000 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_INTERNAL_ERROR); 1102 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
1001 goto err; 1103 goto err;
1002 } 1104 }
1003 1105
@@ -1083,19 +1185,19 @@ static int ssl3_send_server_key_exchange(SSL *s)
1083 { 1185 {
1084 /* n is the length of the params, they start at &(d[4]) 1186 /* n is the length of the params, they start at &(d[4])
1085 * and p points to the space at the end. */ 1187 * and p points to the space at the end. */
1086#ifndef NO_RSA 1188#ifndef OPENSSL_NO_RSA
1087 if (pkey->type == EVP_PKEY_RSA) 1189 if (pkey->type == EVP_PKEY_RSA)
1088 { 1190 {
1089 q=md_buf; 1191 q=md_buf;
1090 j=0; 1192 j=0;
1091 for (num=2; num > 0; num--) 1193 for (num=2; num > 0; num--)
1092 { 1194 {
1093 EVP_DigestInit(&md_ctx,(num == 2) 1195 EVP_DigestInit_ex(&md_ctx,(num == 2)
1094 ?s->ctx->md5:s->ctx->sha1); 1196 ?s->ctx->md5:s->ctx->sha1, NULL);
1095 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1197 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1096 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1198 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1097 EVP_DigestUpdate(&md_ctx,&(d[4]),n); 1199 EVP_DigestUpdate(&md_ctx,&(d[4]),n);
1098 EVP_DigestFinal(&md_ctx,q, 1200 EVP_DigestFinal_ex(&md_ctx,q,
1099 (unsigned int *)&i); 1201 (unsigned int *)&i);
1100 q+=i; 1202 q+=i;
1101 j+=i; 1203 j+=i;
@@ -1111,11 +1213,11 @@ static int ssl3_send_server_key_exchange(SSL *s)
1111 } 1213 }
1112 else 1214 else
1113#endif 1215#endif
1114#if !defined(NO_DSA) 1216#if !defined(OPENSSL_NO_DSA)
1115 if (pkey->type == EVP_PKEY_DSA) 1217 if (pkey->type == EVP_PKEY_DSA)
1116 { 1218 {
1117 /* lets do DSS */ 1219 /* lets do DSS */
1118 EVP_SignInit(&md_ctx,EVP_dss1()); 1220 EVP_SignInit_ex(&md_ctx,EVP_dss1(), NULL);
1119 EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1221 EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1120 EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1222 EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1121 EVP_SignUpdate(&md_ctx,&(d[4]),n); 1223 EVP_SignUpdate(&md_ctx,&(d[4]),n);
@@ -1148,10 +1250,12 @@ static int ssl3_send_server_key_exchange(SSL *s)
1148 } 1250 }
1149 1251
1150 s->state = SSL3_ST_SW_KEY_EXCH_B; 1252 s->state = SSL3_ST_SW_KEY_EXCH_B;
1253 EVP_MD_CTX_cleanup(&md_ctx);
1151 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 1254 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
1152f_err: 1255f_err:
1153 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1256 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1154err: 1257err:
1258 EVP_MD_CTX_cleanup(&md_ctx);
1155 return(-1); 1259 return(-1);
1156 } 1260 }
1157 1261
@@ -1249,28 +1353,31 @@ static int ssl3_get_client_key_exchange(SSL *s)
1249 long n; 1353 long n;
1250 unsigned long l; 1354 unsigned long l;
1251 unsigned char *p; 1355 unsigned char *p;
1252#ifndef NO_RSA 1356#ifndef OPENSSL_NO_RSA
1253 RSA *rsa=NULL; 1357 RSA *rsa=NULL;
1254 EVP_PKEY *pkey=NULL; 1358 EVP_PKEY *pkey=NULL;
1255#endif 1359#endif
1256#ifndef NO_DH 1360#ifndef OPENSSL_NO_DH
1257 BIGNUM *pub=NULL; 1361 BIGNUM *pub=NULL;
1258 DH *dh_srvr; 1362 DH *dh_srvr;
1259#endif 1363#endif
1364#ifndef OPENSSL_NO_KRB5
1365 KSSL_ERR kssl_err;
1366#endif /* OPENSSL_NO_KRB5 */
1260 1367
1261 n=ssl3_get_message(s, 1368 n=ssl3_get_message(s,
1262 SSL3_ST_SR_KEY_EXCH_A, 1369 SSL3_ST_SR_KEY_EXCH_A,
1263 SSL3_ST_SR_KEY_EXCH_B, 1370 SSL3_ST_SR_KEY_EXCH_B,
1264 SSL3_MT_CLIENT_KEY_EXCHANGE, 1371 SSL3_MT_CLIENT_KEY_EXCHANGE,
1265 400, /* ???? */ 1372 2048, /* ??? */
1266 &ok); 1373 &ok);
1267 1374
1268 if (!ok) return((int)n); 1375 if (!ok) return((int)n);
1269 p=(unsigned char *)s->init_buf->data; 1376 p=(unsigned char *)s->init_msg;
1270 1377
1271 l=s->s3->tmp.new_cipher->algorithms; 1378 l=s->s3->tmp.new_cipher->algorithms;
1272 1379
1273#ifndef NO_RSA 1380#ifndef OPENSSL_NO_RSA
1274 if (l & SSL_kRSA) 1381 if (l & SSL_kRSA)
1275 { 1382 {
1276 /* FIX THIS UP EAY EAY EAY EAY */ 1383 /* FIX THIS UP EAY EAY EAY EAY */
@@ -1377,7 +1484,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
1377 } 1484 }
1378 else 1485 else
1379#endif 1486#endif
1380#ifndef NO_DH 1487#ifndef OPENSSL_NO_DH
1381 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1488 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1382 { 1489 {
1383 n2s(p,i); 1490 n2s(p,i);
@@ -1440,16 +1547,165 @@ static int ssl3_get_client_key_exchange(SSL *s)
1440 } 1547 }
1441 else 1548 else
1442#endif 1549#endif
1550#ifndef OPENSSL_NO_KRB5
1551 if (l & SSL_kKRB5)
1552 {
1553 krb5_error_code krb5rc;
1554 krb5_data enc_ticket;
1555 krb5_data authenticator;
1556 krb5_data enc_pms;
1557 KSSL_CTX *kssl_ctx = s->kssl_ctx;
1558 EVP_CIPHER_CTX ciph_ctx;
1559 EVP_CIPHER *enc = NULL;
1560 unsigned char iv[EVP_MAX_IV_LENGTH];
1561 unsigned char pms[SSL_MAX_MASTER_KEY_LENGTH
1562 + EVP_MAX_IV_LENGTH + 1];
1563 int padl, outl = sizeof(pms);
1564 krb5_timestamp authtime = 0;
1565 krb5_ticket_times ttimes;
1566
1567 EVP_CIPHER_CTX_init(&ciph_ctx);
1568
1569 if (!kssl_ctx) kssl_ctx = kssl_ctx_new();
1570
1571 n2s(p,i);
1572 enc_ticket.length = i;
1573 enc_ticket.data = (char *)p;
1574 p+=enc_ticket.length;
1575
1576 n2s(p,i);
1577 authenticator.length = i;
1578 authenticator.data = (char *)p;
1579 p+=authenticator.length;
1580
1581 n2s(p,i);
1582 enc_pms.length = i;
1583 enc_pms.data = (char *)p;
1584 p+=enc_pms.length;
1585
1586 if (n != enc_ticket.length + authenticator.length +
1587 enc_pms.length + 6)
1588 {
1589 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1590 SSL_R_DATA_LENGTH_TOO_LONG);
1591 goto err;
1592 }
1593
1594 if ((krb5rc = kssl_sget_tkt(kssl_ctx, &enc_ticket, &ttimes,
1595 &kssl_err)) != 0)
1596 {
1597#ifdef KSSL_DEBUG
1598 printf("kssl_sget_tkt rtn %d [%d]\n",
1599 krb5rc, kssl_err.reason);
1600 if (kssl_err.text)
1601 printf("kssl_err text= %s\n", kssl_err.text);
1602#endif /* KSSL_DEBUG */
1603 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1604 kssl_err.reason);
1605 goto err;
1606 }
1607
1608 /* Note: no authenticator is not considered an error,
1609 ** but will return authtime == 0.
1610 */
1611 if ((krb5rc = kssl_check_authent(kssl_ctx, &authenticator,
1612 &authtime, &kssl_err)) != 0)
1613 {
1614#ifdef KSSL_DEBUG
1615 printf("kssl_check_authent rtn %d [%d]\n",
1616 krb5rc, kssl_err.reason);
1617 if (kssl_err.text)
1618 printf("kssl_err text= %s\n", kssl_err.text);
1619#endif /* KSSL_DEBUG */
1620 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1621 kssl_err.reason);
1622 goto err;
1623 }
1624
1625 if ((krb5rc = kssl_validate_times(authtime, &ttimes)) != 0)
1626 {
1627 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, krb5rc);
1628 goto err;
1629 }
1630
1631#ifdef KSSL_DEBUG
1632 kssl_ctx_show(kssl_ctx);
1633#endif /* KSSL_DEBUG */
1634
1635 enc = kssl_map_enc(kssl_ctx->enctype);
1636 if (enc == NULL)
1637 goto err;
1638
1639 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */
1640
1641 if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv))
1642 {
1643 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1644 SSL_R_DECRYPTION_FAILED);
1645 goto err;
1646 }
1647 if (!EVP_DecryptUpdate(&ciph_ctx, pms,&outl,
1648 (unsigned char *)enc_pms.data, enc_pms.length))
1649 {
1650 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1651 SSL_R_DECRYPTION_FAILED);
1652 goto err;
1653 }
1654 if (outl > SSL_MAX_MASTER_KEY_LENGTH)
1655 {
1656 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1657 SSL_R_DATA_LENGTH_TOO_LONG);
1658 goto err;
1659 }
1660 if (!EVP_DecryptFinal_ex(&ciph_ctx,&(pms[outl]),&padl))
1661 {
1662 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1663 SSL_R_DECRYPTION_FAILED);
1664 goto err;
1665 }
1666 outl += padl;
1667 if (outl > SSL_MAX_MASTER_KEY_LENGTH)
1668 {
1669 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1670 SSL_R_DATA_LENGTH_TOO_LONG);
1671 goto err;
1672 }
1673 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
1674
1675 s->session->master_key_length=
1676 s->method->ssl3_enc->generate_master_secret(s,
1677 s->session->master_key, pms, outl);
1678
1679 if (kssl_ctx->client_princ)
1680 {
1681 int len = strlen(kssl_ctx->client_princ);
1682 if ( len < SSL_MAX_KRB5_PRINCIPAL_LENGTH )
1683 {
1684 s->session->krb5_client_princ_len = len;
1685 memcpy(s->session->krb5_client_princ,kssl_ctx->client_princ,len);
1686 }
1687 }
1688
1689
1690 /* Was doing kssl_ctx_free() here,
1691 ** but it caused problems for apache.
1692 ** kssl_ctx = kssl_ctx_free(kssl_ctx);
1693 ** if (s->kssl_ctx) s->kssl_ctx = NULL;
1694 */
1695 }
1696 else
1697#endif /* OPENSSL_NO_KRB5 */
1443 { 1698 {
1444 al=SSL_AD_HANDSHAKE_FAILURE; 1699 al=SSL_AD_HANDSHAKE_FAILURE;
1445 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_UNKNOWN_CIPHER_TYPE); 1700 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1701 SSL_R_UNKNOWN_CIPHER_TYPE);
1446 goto f_err; 1702 goto f_err;
1447 } 1703 }
1448 1704
1449 return(1); 1705 return(1);
1450f_err: 1706f_err:
1451 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1707 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1452#if !defined(NO_DH) || !defined(NO_RSA) 1708#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA)
1453err: 1709err:
1454#endif 1710#endif
1455 return(-1); 1711 return(-1);
@@ -1520,7 +1776,7 @@ static int ssl3_get_cert_verify(SSL *s)
1520 } 1776 }
1521 1777
1522 /* we now have a signature that we need to verify */ 1778 /* we now have a signature that we need to verify */
1523 p=(unsigned char *)s->init_buf->data; 1779 p=(unsigned char *)s->init_msg;
1524 n2s(p,i); 1780 n2s(p,i);
1525 n-=2; 1781 n-=2;
1526 if (i > n) 1782 if (i > n)
@@ -1538,7 +1794,7 @@ static int ssl3_get_cert_verify(SSL *s)
1538 goto f_err; 1794 goto f_err;
1539 } 1795 }
1540 1796
1541#ifndef NO_RSA 1797#ifndef OPENSSL_NO_RSA
1542 if (pkey->type == EVP_PKEY_RSA) 1798 if (pkey->type == EVP_PKEY_RSA)
1543 { 1799 {
1544 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, 1800 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
@@ -1559,7 +1815,7 @@ static int ssl3_get_cert_verify(SSL *s)
1559 } 1815 }
1560 else 1816 else
1561#endif 1817#endif
1562#ifndef NO_DSA 1818#ifndef OPENSSL_NO_DSA
1563 if (pkey->type == EVP_PKEY_DSA) 1819 if (pkey->type == EVP_PKEY_DSA)
1564 { 1820 {
1565 j=DSA_verify(pkey->save_type, 1821 j=DSA_verify(pkey->save_type,
@@ -1576,7 +1832,7 @@ static int ssl3_get_cert_verify(SSL *s)
1576 else 1832 else
1577#endif 1833#endif
1578 { 1834 {
1579 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_INTERNAL_ERROR); 1835 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,ERR_R_INTERNAL_ERROR);
1580 al=SSL_AD_UNSUPPORTED_CERTIFICATE; 1836 al=SSL_AD_UNSUPPORTED_CERTIFICATE;
1581 goto f_err; 1837 goto f_err;
1582 } 1838 }
@@ -1605,11 +1861,7 @@ static int ssl3_get_client_certificate(SSL *s)
1605 SSL3_ST_SR_CERT_A, 1861 SSL3_ST_SR_CERT_A,
1606 SSL3_ST_SR_CERT_B, 1862 SSL3_ST_SR_CERT_B,
1607 -1, 1863 -1,
1608#if defined(MSDOS) && !defined(WIN32) 1864 s->max_cert_list,
1609 1024*30, /* 30k max cert list :-) */
1610#else
1611 1024*100, /* 100k max cert list :-) */
1612#endif
1613 &ok); 1865 &ok);
1614 1866
1615 if (!ok) return((int)n); 1867 if (!ok) return((int)n);
@@ -1640,7 +1892,7 @@ static int ssl3_get_client_certificate(SSL *s)
1640 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE); 1892 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE);
1641 goto f_err; 1893 goto f_err;
1642 } 1894 }
1643 d=p=(unsigned char *)s->init_buf->data; 1895 d=p=(unsigned char *)s->init_msg;
1644 1896
1645 if ((sk=sk_X509_new_null()) == NULL) 1897 if ((sk=sk_X509_new_null()) == NULL)
1646 { 1898 {
@@ -1760,9 +2012,13 @@ int ssl3_send_server_certificate(SSL *s)
1760 if (s->state == SSL3_ST_SW_CERT_A) 2012 if (s->state == SSL3_ST_SW_CERT_A)
1761 { 2013 {
1762 x=ssl_get_server_send_cert(s); 2014 x=ssl_get_server_send_cert(s);
1763 if (x == NULL) 2015 if (x == NULL &&
2016 /* VRS: allow null cert if auth == KRB5 */
2017 (s->s3->tmp.new_cipher->algorithms
2018 & (SSL_MKEY_MASK|SSL_AUTH_MASK))
2019 != (SSL_aKRB5|SSL_kKRB5))
1764 { 2020 {
1765 SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,SSL_R_INTERNAL_ERROR); 2021 SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,ERR_R_INTERNAL_ERROR);
1766 return(0); 2022 return(0);
1767 } 2023 }
1768 2024
diff --git a/src/lib/libssl/src/CHANGES b/src/lib/libssl/src/CHANGES
index f88867b065..b8399a3500 100644
--- a/src/lib/libssl/src/CHANGES
+++ b/src/lib/libssl/src/CHANGES
@@ -2,6 +2,1964 @@
2 OpenSSL CHANGES 2 OpenSSL CHANGES
3 _______________ 3 _______________
4 4
5 Changes between 0.9.6d and 0.9.7 [XX xxx 2002]
6
7 *) Fix escaping of non-ASCII characters when using the -subj option
8 of the "openssl req" command line tool. (Robert Joop <joop@fokus.gmd.de>)
9 [Lutz Jaenicke]
10
11 *) Make object definitions compliant to LDAP (RFC2256): SN is the short
12 form for "surname", serialNumber has no short form.
13 Use "mail" as the short name for "rfc822Mailbox" according to RFC2798;
14 therefore remove "mail" short name for "internet 7".
15 Some more OID additions. (Michael Bell <michael.bell@rz.hu-berlin.de>)
16 [Lutz Jaenicke]
17
18 *) Add an "init" command to the ENGINE config module and auto initialize
19 ENGINEs. Without any "init" command the ENGINE will be initialized
20 after all ctrl commands have been executed on it. If init=1 the
21 ENGINE is initailized at that point (ctrls before that point are run
22 on the uninitialized ENGINE and after on the initialized one). If
23 init=0 then the ENGINE will not be iniatialized at all.
24 [Steve Henson]
25
26 *) Fix the 'app_verify_callback' interface so that the user-defined
27 argument is actually passed to the callback: In the
28 SSL_CTX_set_cert_verify_callback() prototype, the callback
29 declaration has been changed from
30 int (*cb)()
31 into
32 int (*cb)(X509_STORE_CTX *,void *);
33 in ssl_verify_cert_chain (ssl/ssl_cert.c), the call
34 i=s->ctx->app_verify_callback(&ctx)
35 has been changed into
36 i=s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg).
37
38 To update applications using SSL_CTX_set_cert_verify_callback(),
39 a dummy argument can be added to their callback functions.
40 [D. K. Smetters <smetters@parc.xerox.com>]
41
42 *) Added the '4758cca' ENGINE to support IBM 4758 cards.
43 [Maurice Gittens <maurice@gittens.nl>, touchups by Geoff Thorpe]
44
45 *) Add and OPENSSL_LOAD_CONF define which will cause
46 OpenSSL_add_all_algorithms() to load the openssl.cnf config file.
47 This allows older applications to transparently support certain
48 OpenSSL features: such as crypto acceleration and dynamic ENGINE loading.
49 Two new functions OPENSSL_add_all_algorithms_noconf() which will never
50 load the config file and OPENSSL_add_all_algorithms_conf() which will
51 always load it have also been added.
52 [Steve Henson]
53
54 *) Add the OFB, CFB and CTR (all with 128 bit feedback) to AES.
55 Adjust NIDs and EVP layer.
56 [Stephen Sprunk <stephen@sprunk.org> and Richard Levitte]
57
58 *) Config modules support in openssl utility.
59
60 Most commands now load modules from the config file,
61 though in a few (such as version) this isn't done
62 because it couldn't be used for anything.
63
64 In the case of ca and req the config file used is
65 the same as the utility itself: that is the -config
66 command line option can be used to specify an
67 alternative file.
68 [Steve Henson]
69
70 *) Move default behaviour from OPENSSL_config(). If appname is NULL
71 use "openssl_conf" if filename is NULL use default openssl config file.
72 [Steve Henson]
73
74 *) Add an argument to OPENSSL_config() to allow the use of an alternative
75 config section name. Add a new flag to tolerate a missing config file
76 and move code to CONF_modules_load_file().
77 [Steve Henson]
78
79 *) Support for crypto accelerator cards from Accelerated Encryption
80 Processing, www.aep.ie. (Use engine 'aep')
81 The support was copied from 0.9.6c [engine] and adapted/corrected
82 to work with the new engine framework.
83 [AEP Inc. and Richard Levitte]
84
85 *) Support for SureWare crypto accelerator cards from Baltimore
86 Technologies. (Use engine 'sureware')
87 The support was copied from 0.9.6c [engine] and adapted
88 to work with the new engine framework.
89 [Richard Levitte]
90
91 *) Have the CHIL engine fork-safe (as defined by nCipher) and actually
92 make the newer ENGINE framework commands for the CHIL engine work.
93 [Toomas Kiisk <vix@cyber.ee> and Richard Levitte]
94
95 *) Make it possible to produce shared libraries on ReliantUNIX.
96 [Robert Dahlem <Robert.Dahlem@ffm2.siemens.de> via Richard Levitte]
97
98 *) Add the configuration target debug-linux-ppro.
99 Make 'openssl rsa' use the general key loading routines
100 implemented in apps.c, and make those routines able to
101 handle the key format FORMAT_NETSCAPE and the variant
102 FORMAT_IISSGC.
103 [Toomas Kiisk <vix@cyber.ee> via Richard Levitte]
104
105 *) Fix a crashbug and a logic bug in hwcrhk_load_pubkey().
106 [Toomas Kiisk <vix@cyber.ee> via Richard Levitte]
107
108 *) Add -keyform to rsautl, and document -engine.
109 [Richard Levitte, inspired by Toomas Kiisk <vix@cyber.ee>]
110
111 *) Change BIO_new_file (crypto/bio/bss_file.c) to use new
112 BIO_R_NO_SUCH_FILE error code rather than the generic
113 ERR_R_SYS_LIB error code if fopen() fails with ENOENT.
114 [Ben Laurie]
115
116 *) Add new functions
117 ERR_peek_last_error
118 ERR_peek_last_error_line
119 ERR_peek_last_error_line_data.
120 These are similar to
121 ERR_peek_error
122 ERR_peek_error_line
123 ERR_peek_error_line_data,
124 but report on the latest error recorded rather than the first one
125 still in the error queue.
126 [Ben Laurie, Bodo Moeller]
127
128 *) default_algorithms option in ENGINE config module. This allows things
129 like:
130 default_algorithms = ALL
131 default_algorithms = RSA, DSA, RAND, CIPHERS, DIGESTS
132 [Steve Henson]
133
134 *) Prelminary ENGINE config module.
135 [Steve Henson]
136
137 *) New experimental application configuration code.
138 [Steve Henson]
139
140 *) Change the AES code to follow the same name structure as all other
141 symmetric ciphers, and behave the same way. Move everything to
142 the directory crypto/aes, thereby obsoleting crypto/rijndael.
143 [Stephen Sprunk <stephen@sprunk.org> and Richard Levitte]
144
145 *) SECURITY: remove unsafe setjmp/signal interaction from ui_openssl.c.
146 [Ben Laurie and Theo de Raadt]
147
148 *) Add option to output public keys in req command.
149 [Massimiliano Pala madwolf@openca.org]
150
151 *) Use wNAFs in EC_POINTs_mul() for improved efficiency
152 (up to about 10% better than before for P-192 and P-224).
153 [Bodo Moeller]
154
155 *) New functions/macros
156
157 SSL_CTX_set_msg_callback(ctx, cb)
158 SSL_CTX_set_msg_callback_arg(ctx, arg)
159 SSL_set_msg_callback(ssl, cb)
160 SSL_set_msg_callback_arg(ssl, arg)
161
162 to request calling a callback function
163
164 void cb(int write_p, int version, int content_type,
165 const void *buf, size_t len, SSL *ssl, void *arg)
166
167 whenever a protocol message has been completely received
168 (write_p == 0) or sent (write_p == 1). Here 'version' is the
169 protocol version according to which the SSL library interprets
170 the current protocol message (SSL2_VERSION, SSL3_VERSION, or
171 TLS1_VERSION). 'content_type' is 0 in the case of SSL 2.0, or
172 the content type as defined in the SSL 3.0/TLS 1.0 protocol
173 specification (change_cipher_spec(20), alert(21), handshake(22)).
174 'buf' and 'len' point to the actual message, 'ssl' to the
175 SSL object, and 'arg' is the application-defined value set by
176 SSL[_CTX]_set_msg_callback_arg().
177
178 'openssl s_client' and 'openssl s_server' have new '-msg' options
179 to enable a callback that displays all protocol messages.
180 [Bodo Moeller]
181
182 *) Change the shared library support so shared libraries are built as
183 soon as the corresponding static library is finished, and thereby get
184 openssl and the test programs linked against the shared library.
185 This still only happens when the keyword "shard" has been given to
186 the configuration scripts.
187
188 NOTE: shared library support is still an experimental thing, and
189 backward binary compatibility is still not guaranteed.
190 ["Maciej W. Rozycki" <macro@ds2.pg.gda.pl> and Richard Levitte]
191
192 *) Add support for Subject Information Access extension.
193 [Peter Sylvester <Peter.Sylvester@EdelWeb.fr>]
194
195 *) Make BUF_MEM_grow() behaviour more consistent: Initialise to zero
196 additional bytes when new memory had to be allocated, not just
197 when reusing an existing buffer.
198 [Bodo Moeller]
199
200 *) New command line and configuration option 'utf8' for the req command.
201 This allows field values to be specified as UTF8 strings.
202 [Steve Henson]
203
204 *) Add -multi and -mr options to "openssl speed" - giving multiple parallel
205 runs for the former and machine-readable output for the latter.
206 [Ben Laurie]
207
208 *) Add '-noemailDN' option to 'openssl ca'. This prevents inclusion
209 of the e-mail address in the DN (i.e., it will go into a certificate
210 extension only). The new configuration file option 'email_in_dn = no'
211 has the same effect.
212 [Massimiliano Pala madwolf@openca.org]
213
214 *) Change all functions with names starting with des_ to be starting
215 with DES_ instead. Add wrappers that are compatible with libdes,
216 but are named _ossl_old_des_*. Finally, add macros that map the
217 des_* symbols to the corresponding _ossl_old_des_* if libdes
218 compatibility is desired. If OpenSSL 0.9.6c compatibility is
219 desired, the des_* symbols will be mapped to DES_*, with one
220 exception.
221
222 Since we provide two compatibility mappings, the user needs to
223 define the macro OPENSSL_DES_LIBDES_COMPATIBILITY if libdes
224 compatibility is desired. The default (i.e., when that macro
225 isn't defined) is OpenSSL 0.9.6c compatibility.
226
227 There are also macros that enable and disable the support of old
228 des functions altogether. Those are OPENSSL_ENABLE_OLD_DES_SUPPORT
229 and OPENSSL_DISABLE_OLD_DES_SUPPORT. If none or both of those
230 are defined, the default will apply: to support the old des routines.
231
232 In either case, one must include openssl/des.h to get the correct
233 definitions. Do not try to just include openssl/des_old.h, that
234 won't work.
235
236 NOTE: This is a major break of an old API into a new one. Software
237 authors are encouraged to switch to the DES_ style functions. Some
238 time in the future, des_old.h and the libdes compatibility functions
239 will be disable (i.e. OPENSSL_DISABLE_OLD_DES_SUPPORT will be the
240 default), and then completely removed.
241 [Richard Levitte]
242
243 *) Test for certificates which contain unsupported critical extensions.
244 If such a certificate is found during a verify operation it is
245 rejected by default: this behaviour can be overridden by either
246 handling the new error X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION or
247 by setting the verify flag X509_V_FLAG_IGNORE_CRITICAL. A new function
248 X509_supported_extension() has also been added which returns 1 if a
249 particular extension is supported.
250 [Steve Henson]
251
252 *) Modify the behaviour of EVP cipher functions in similar way to digests
253 to retain compatibility with existing code.
254 [Steve Henson]
255
256 *) Modify the behaviour of EVP_DigestInit() and EVP_DigestFinal() to retain
257 compatibility with existing code. In particular the 'ctx' parameter does
258 not have to be to be initialized before the call to EVP_DigestInit() and
259 it is tidied up after a call to EVP_DigestFinal(). New function
260 EVP_DigestFinal_ex() which does not tidy up the ctx. Similarly function
261 EVP_MD_CTX_copy() changed to not require the destination to be
262 initialized valid and new function EVP_MD_CTX_copy_ex() added which
263 requires the destination to be valid.
264
265 Modify all the OpenSSL digest calls to use EVP_DigestInit_ex(),
266 EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex().
267 [Steve Henson]
268
269 *) Change ssl3_get_message (ssl/s3_both.c) and the functions using it
270 so that complete 'Handshake' protocol structures are kept in memory
271 instead of overwriting 'msg_type' and 'length' with 'body' data.
272 [Bodo Moeller]
273
274 *) Add an implementation of SSL_add_dir_cert_subjects_to_stack for Win32.
275 [Massimo Santin via Richard Levitte]
276
277 *) Major restructuring to the underlying ENGINE code. This includes
278 reduction of linker bloat, separation of pure "ENGINE" manipulation
279 (initialisation, etc) from functionality dealing with implementations
280 of specific crypto iterfaces. This change also introduces integrated
281 support for symmetric ciphers and digest implementations - so ENGINEs
282 can now accelerate these by providing EVP_CIPHER and EVP_MD
283 implementations of their own. This is detailed in crypto/engine/README
284 as it couldn't be adequately described here. However, there are a few
285 API changes worth noting - some RSA, DSA, DH, and RAND functions that
286 were changed in the original introduction of ENGINE code have now
287 reverted back - the hooking from this code to ENGINE is now a good
288 deal more passive and at run-time, operations deal directly with
289 RSA_METHODs, DSA_METHODs (etc) as they did before, rather than
290 dereferencing through an ENGINE pointer any more. Also, the ENGINE
291 functions dealing with BN_MOD_EXP[_CRT] handlers have been removed -
292 they were not being used by the framework as there is no concept of a
293 BIGNUM_METHOD and they could not be generalised to the new
294 'ENGINE_TABLE' mechanism that underlies the new code. Similarly,
295 ENGINE_cpy() has been removed as it cannot be consistently defined in
296 the new code.
297 [Geoff Thorpe]
298
299 *) Change ASN1_GENERALIZEDTIME_check() to allow fractional seconds.
300 [Steve Henson]
301
302 *) Change mkdef.pl to sort symbols that get the same entry number,
303 and make sure the automatically generated functions ERR_load_*
304 become part of libeay.num as well.
305 [Richard Levitte]
306
307 *) New function SSL_renegotiate_pending(). This returns true once
308 renegotiation has been requested (either SSL_renegotiate() call
309 or HelloRequest/ClientHello receveived from the peer) and becomes
310 false once a handshake has been completed.
311 (For servers, SSL_renegotiate() followed by SSL_do_handshake()
312 sends a HelloRequest, but does not ensure that a handshake takes
313 place. SSL_renegotiate_pending() is useful for checking if the
314 client has followed the request.)
315 [Bodo Moeller]
316
317 *) New SSL option SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION.
318 By default, clients may request session resumption even during
319 renegotiation (if session ID contexts permit); with this option,
320 session resumption is possible only in the first handshake.
321 [Bodo Moeller]
322
323 *) Add some demos for certificate and certificate request creation.
324 [Steve Henson]
325
326 *) Make maximum certificate chain size accepted from the peer application
327 settable (SSL*_get/set_max_cert_list()), as proposed by
328 "Douglas E. Engert" <deengert@anl.gov>.
329 [Lutz Jaenicke]
330
331 *) Add support for shared libraries for Unixware-7
332 (Boyd Lynn Gerber <gerberb@zenez.com>).
333 [Lutz Jaenicke]
334
335 *) Add a "destroy" handler to ENGINEs that allows structural cleanup to
336 be done prior to destruction. Use this to unload error strings from
337 ENGINEs that load their own error strings. NB: This adds two new API
338 functions to "get" and "set" this destroy handler in an ENGINE.
339 [Geoff Thorpe]
340
341 *) Alter all existing ENGINE implementations (except "openssl" and
342 "openbsd") to dynamically instantiate their own error strings. This
343 makes them more flexible to be built both as statically-linked ENGINEs
344 and self-contained shared-libraries loadable via the "dynamic" ENGINE.
345 Also, add stub code to each that makes building them as self-contained
346 shared-libraries easier (see README.ENGINE).
347 [Geoff Thorpe]
348
349 *) Add a "dynamic" ENGINE that provides a mechanism for binding ENGINE
350 implementations into applications that are completely implemented in
351 self-contained shared-libraries. The "dynamic" ENGINE exposes control
352 commands that can be used to configure what shared-library to load and
353 to control aspects of the way it is handled. Also, made an update to
354 the README.ENGINE file that brings its information up-to-date and
355 provides some information and instructions on the "dynamic" ENGINE
356 (ie. how to use it, how to build "dynamic"-loadable ENGINEs, etc).
357 [Geoff Thorpe]
358
359 *) Make it possible to unload ranges of ERR strings with a new
360 "ERR_unload_strings" function.
361 [Geoff Thorpe]
362
363 *) Add a copy() function to EVP_MD.
364 [Ben Laurie]
365
366 *) Make EVP_MD routines take a context pointer instead of just the
367 md_data void pointer.
368 [Ben Laurie]
369
370 *) Add flags to EVP_MD and EVP_MD_CTX. EVP_MD_FLAG_ONESHOT indicates
371 that the digest can only process a single chunk of data
372 (typically because it is provided by a piece of
373 hardware). EVP_MD_CTX_FLAG_ONESHOT indicates that the application
374 is only going to provide a single chunk of data, and hence the
375 framework needn't accumulate the data for oneshot drivers.
376 [Ben Laurie]
377
378 *) As with "ERR", make it possible to replace the underlying "ex_data"
379 functions. This change also alters the storage and management of global
380 ex_data state - it's now all inside ex_data.c and all "class" code (eg.
381 RSA, BIO, SSL_CTX, etc) no longer stores its own STACKS and per-class
382 index counters. The API functions that use this state have been changed
383 to take a "class_index" rather than pointers to the class's local STACK
384 and counter, and there is now an API function to dynamically create new
385 classes. This centralisation allows us to (a) plug a lot of the
386 thread-safety problems that existed, and (b) makes it possible to clean
387 up all allocated state using "CRYPTO_cleanup_all_ex_data()". W.r.t. (b)
388 such data would previously have always leaked in application code and
389 workarounds were in place to make the memory debugging turn a blind eye
390 to it. Application code that doesn't use this new function will still
391 leak as before, but their memory debugging output will announce it now
392 rather than letting it slide.
393
394 Besides the addition of CRYPTO_cleanup_all_ex_data(), another API change
395 induced by the "ex_data" overhaul is that X509_STORE_CTX_init() now
396 has a return value to indicate success or failure.
397 [Geoff Thorpe]
398
399 *) Make it possible to replace the underlying "ERR" functions such that the
400 global state (2 LHASH tables and 2 locks) is only used by the "default"
401 implementation. This change also adds two functions to "get" and "set"
402 the implementation prior to it being automatically set the first time
403 any other ERR function takes place. Ie. an application can call "get",
404 pass the return value to a module it has just loaded, and that module
405 can call its own "set" function using that value. This means the
406 module's "ERR" operations will use (and modify) the error state in the
407 application and not in its own statically linked copy of OpenSSL code.
408 [Geoff Thorpe]
409
410 *) Give DH, DSA, and RSA types their own "**_up_ref()" function to increment
411 reference counts. This performs normal REF_PRINT/REF_CHECK macros on
412 the operation, and provides a more encapsulated way for external code
413 (crypto/evp/ and ssl/) to do this. Also changed the evp and ssl code
414 to use these functions rather than manually incrementing the counts.
415
416 Also rename "DSO_up()" function to more descriptive "DSO_up_ref()".
417 [Geoff Thorpe]
418
419 *) Add EVP test program.
420 [Ben Laurie]
421
422 *) Add symmetric cipher support to ENGINE. Expect the API to change!
423 [Ben Laurie]
424
425 *) New CRL functions: X509_CRL_set_version(), X509_CRL_set_issuer_name()
426 X509_CRL_set_lastUpdate(), X509_CRL_set_nextUpdate(), X509_CRL_sort(),
427 X509_REVOKED_set_serialNumber(), and X509_REVOKED_set_revocationDate().
428 These allow a CRL to be built without having to access X509_CRL fields
429 directly. Modify 'ca' application to use new functions.
430 [Steve Henson]
431
432 *) Move SSL_OP_TLS_ROLLBACK_BUG out of the SSL_OP_ALL list of recommended
433 bug workarounds. Rollback attack detection is a security feature.
434 The problem will only arise on OpenSSL servers when TLSv1 is not
435 available (sslv3_server_method() or SSL_OP_NO_TLSv1).
436 Software authors not wanting to support TLSv1 will have special reasons
437 for their choice and can explicitly enable this option.
438 [Bodo Moeller, Lutz Jaenicke]
439
440 *) Rationalise EVP so it can be extended: don't include a union of
441 cipher/digest structures, add init/cleanup functions. This also reduces
442 the number of header dependencies.
443 Usage example:
444
445 EVP_MD_CTX md;
446
447 EVP_MD_CTX_init(&md); /* new function call */
448 EVP_DigestInit(&md, EVP_sha1());
449 EVP_DigestUpdate(&md, in, len);
450 EVP_DigestFinal(&md, out, NULL);
451 EVP_MD_CTX_cleanup(&md); /* new function call */
452
453 [Ben Laurie]
454
455 *) Make DES key schedule conform to the usual scheme, as well as
456 correcting its structure. This means that calls to DES functions
457 now have to pass a pointer to a des_key_schedule instead of a
458 plain des_key_schedule (which was actually always a pointer
459 anyway): E.g.,
460
461 des_key_schedule ks;
462
463 des_set_key_checked(..., &ks);
464 des_ncbc_encrypt(..., &ks, ...);
465
466 (Note that a later change renames 'des_...' into 'DES_...'.)
467 [Ben Laurie]
468
469 *) Initial reduction of linker bloat: the use of some functions, such as
470 PEM causes large amounts of unused functions to be linked in due to
471 poor organisation. For example pem_all.c contains every PEM function
472 which has a knock on effect of linking in large amounts of (unused)
473 ASN1 code. Grouping together similar functions and splitting unrelated
474 functions prevents this.
475 [Steve Henson]
476
477 *) Cleanup of EVP macros.
478 [Ben Laurie]
479
480 *) Change historical references to {NID,SN,LN}_des_ede and ede3 to add the
481 correct _ecb suffix.
482 [Ben Laurie]
483
484 *) Add initial OCSP responder support to ocsp application. The
485 revocation information is handled using the text based index
486 use by the ca application. The responder can either handle
487 requests generated internally, supplied in files (for example
488 via a CGI script) or using an internal minimal server.
489 [Steve Henson]
490
491 *) Add configuration choices to get zlib compression for TLS.
492 [Richard Levitte]
493
494 *) Changes to Kerberos SSL for RFC 2712 compliance:
495 1. Implemented real KerberosWrapper, instead of just using
496 KRB5 AP_REQ message. [Thanks to Simon Wilkinson <sxw@sxw.org.uk>]
497 2. Implemented optional authenticator field of KerberosWrapper.
498
499 Added openssl-style ASN.1 macros for Kerberos ticket, ap_req,
500 and authenticator structs; see crypto/krb5/.
501
502 Generalized Kerberos calls to support multiple Kerberos libraries.
503 [Vern Staats <staatsvr@asc.hpc.mil>,
504 Jeffrey Altman <jaltman@columbia.edu>
505 via Richard Levitte]
506
507 *) Cause 'openssl speed' to use fully hard-coded DSA keys as it
508 already does with RSA. testdsa.h now has 'priv_key/pub_key'
509 values for each of the key sizes rather than having just
510 parameters (and 'speed' generating keys each time).
511 [Geoff Thorpe]
512
513 *) Speed up EVP routines.
514 Before:
515encrypt
516type 8 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
517des-cbc 4408.85k 5560.51k 5778.46k 5862.20k 5825.16k
518des-cbc 4389.55k 5571.17k 5792.23k 5846.91k 5832.11k
519des-cbc 4394.32k 5575.92k 5807.44k 5848.37k 5841.30k
520decrypt
521des-cbc 3482.66k 5069.49k 5496.39k 5614.16k 5639.28k
522des-cbc 3480.74k 5068.76k 5510.34k 5609.87k 5635.52k
523des-cbc 3483.72k 5067.62k 5504.60k 5708.01k 5724.80k
524 After:
525encrypt
526des-cbc 4660.16k 5650.19k 5807.19k 5827.13k 5783.32k
527decrypt
528des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k
529 [Ben Laurie]
530
531 *) Added the OS2-EMX target.
532 ["Brian Havard" <brianh@kheldar.apana.org.au> and Richard Levitte]
533
534 *) Rewrite apps to use NCONF routines instead of the old CONF. New functions
535 to support NCONF routines in extension code. New function CONF_set_nconf()
536 to allow functions which take an NCONF to also handle the old LHASH
537 structure: this means that the old CONF compatible routines can be
538 retained (in particular wrt extensions) without having to duplicate the
539 code. New function X509V3_add_ext_nconf_sk to add extensions to a stack.
540 [Steve Henson]
541
542 *) Enhance the general user interface with mechanisms for inner control
543 and with possibilities to have yes/no kind of prompts.
544 [Richard Levitte]
545
546 *) Change all calls to low level digest routines in the library and
547 applications to use EVP. Add missing calls to HMAC_cleanup() and
548 don't assume HMAC_CTX can be copied using memcpy().
549 [Verdon Walker <VWalker@novell.com>, Steve Henson]
550
551 *) Add the possibility to control engines through control names but with
552 arbitrary arguments instead of just a string.
553 Change the key loaders to take a UI_METHOD instead of a callback
554 function pointer. NOTE: this breaks binary compatibility with earlier
555 versions of OpenSSL [engine].
556 Adapt the nCipher code for these new conditions and add a card insertion
557 callback.
558 [Richard Levitte]
559
560 *) Enhance the general user interface with mechanisms to better support
561 dialog box interfaces, application-defined prompts, the possibility
562 to use defaults (for example default passwords from somewhere else)
563 and interrupts/cancellations.
564 [Richard Levitte]
565
566 *) Tidy up PKCS#12 attribute handling. Add support for the CSP name
567 attribute in PKCS#12 files, add new -CSP option to pkcs12 utility.
568 [Steve Henson]
569
570 *) Fix a memory leak in 'sk_dup()' in the case reallocation fails. (Also
571 tidy up some unnecessarily weird code in 'sk_new()').
572 [Geoff, reported by Diego Tartara <dtartara@novamens.com>]
573
574 *) Change the key loading routines for ENGINEs to use the same kind
575 callback (pem_password_cb) as all other routines that need this
576 kind of callback.
577 [Richard Levitte]
578
579 *) Increase ENTROPY_NEEDED to 32 bytes, as Rijndael can operate with
580 256 bit (=32 byte) keys. Of course seeding with more entropy bytes
581 than this minimum value is recommended.
582 [Lutz Jaenicke]
583
584 *) New random seeder for OpenVMS, using the system process statistics
585 that are easily reachable.
586 [Richard Levitte]
587
588 *) Windows apparently can't transparently handle global
589 variables defined in DLLs. Initialisations such as:
590
591 const ASN1_ITEM *it = &ASN1_INTEGER_it;
592
593 wont compile. This is used by the any applications that need to
594 declare their own ASN1 modules. This was fixed by adding the option
595 EXPORT_VAR_AS_FN to all Win32 platforms, although this isn't strictly
596 needed for static libraries under Win32.
597 [Steve Henson]
598
599 *) New functions X509_PURPOSE_set() and X509_TRUST_set() to handle
600 setting of purpose and trust fields. New X509_STORE trust and
601 purpose functions and tidy up setting in other SSL functions.
602 [Steve Henson]
603
604 *) Add copies of X509_STORE_CTX fields and callbacks to X509_STORE
605 structure. These are inherited by X509_STORE_CTX when it is
606 initialised. This allows various defaults to be set in the
607 X509_STORE structure (such as flags for CRL checking and custom
608 purpose or trust settings) for functions which only use X509_STORE_CTX
609 internally such as S/MIME.
610
611 Modify X509_STORE_CTX_purpose_inherit() so it only sets purposes and
612 trust settings if they are not set in X509_STORE. This allows X509_STORE
613 purposes and trust (in S/MIME for example) to override any set by default.
614
615 Add command line options for CRL checking to smime, s_client and s_server
616 applications.
617 [Steve Henson]
618
619 *) Initial CRL based revocation checking. If the CRL checking flag(s)
620 are set then the CRL is looked up in the X509_STORE structure and
621 its validity and signature checked, then if the certificate is found
622 in the CRL the verify fails with a revoked error.
623
624 Various new CRL related callbacks added to X509_STORE_CTX structure.
625
626 Command line options added to 'verify' application to support this.
627
628 This needs some additional work, such as being able to handle multiple
629 CRLs with different times, extension based lookup (rather than just
630 by subject name) and ultimately more complete V2 CRL extension
631 handling.
632 [Steve Henson]
633
634 *) Add a general user interface API (crypto/ui/). This is designed
635 to replace things like des_read_password and friends (backward
636 compatibility functions using this new API are provided).
637 The purpose is to remove prompting functions from the DES code
638 section as well as provide for prompting through dialog boxes in
639 a window system and the like.
640 [Richard Levitte]
641
642 *) Add "ex_data" support to ENGINE so implementations can add state at a
643 per-structure level rather than having to store it globally.
644 [Geoff]
645
646 *) Make it possible for ENGINE structures to be copied when retrieved by
647 ENGINE_by_id() if the ENGINE specifies a new flag: ENGINE_FLAGS_BY_ID_COPY.
648 This causes the "original" ENGINE structure to act like a template,
649 analogous to the RSA vs. RSA_METHOD type of separation. Because of this
650 operational state can be localised to each ENGINE structure, despite the
651 fact they all share the same "methods". New ENGINE structures returned in
652 this case have no functional references and the return value is the single
653 structural reference. This matches the single structural reference returned
654 by ENGINE_by_id() normally, when it is incremented on the pre-existing
655 ENGINE structure.
656 [Geoff]
657
658 *) Fix ASN1 decoder when decoding type ANY and V_ASN1_OTHER: since this
659 needs to match any other type at all we need to manually clear the
660 tag cache.
661 [Steve Henson]
662
663 *) Changes to the "openssl engine" utility to include;
664 - verbosity levels ('-v', '-vv', and '-vvv') that provide information
665 about an ENGINE's available control commands.
666 - executing control commands from command line arguments using the
667 '-pre' and '-post' switches. '-post' is only used if '-t' is
668 specified and the ENGINE is successfully initialised. The syntax for
669 the individual commands are colon-separated, for example;
670 openssl engine chil -pre FORK_CHECK:0 -pre SO_PATH:/lib/test.so
671 [Geoff]
672
673 *) New dynamic control command support for ENGINEs. ENGINEs can now
674 declare their own commands (numbers), names (strings), descriptions,
675 and input types for run-time discovery by calling applications. A
676 subset of these commands are implicitly classed as "executable"
677 depending on their input type, and only these can be invoked through
678 the new string-based API function ENGINE_ctrl_cmd_string(). (Eg. this
679 can be based on user input, config files, etc). The distinction is
680 that "executable" commands cannot return anything other than a boolean
681 result and can only support numeric or string input, whereas some
682 discoverable commands may only be for direct use through
683 ENGINE_ctrl(), eg. supporting the exchange of binary data, function
684 pointers, or other custom uses. The "executable" commands are to
685 support parameterisations of ENGINE behaviour that can be
686 unambiguously defined by ENGINEs and used consistently across any
687 OpenSSL-based application. Commands have been added to all the
688 existing hardware-supporting ENGINEs, noticeably "SO_PATH" to allow
689 control over shared-library paths without source code alterations.
690 [Geoff]
691
692 *) Changed all ENGINE implementations to dynamically allocate their
693 ENGINEs rather than declaring them statically. Apart from this being
694 necessary with the removal of the ENGINE_FLAGS_MALLOCED distinction,
695 this also allows the implementations to compile without using the
696 internal engine_int.h header.
697 [Geoff]
698
699 *) Minor adjustment to "rand" code. RAND_get_rand_method() now returns a
700 'const' value. Any code that should be able to modify a RAND_METHOD
701 should already have non-const pointers to it (ie. they should only
702 modify their own ones).
703 [Geoff]
704
705 *) Made a variety of little tweaks to the ENGINE code.
706 - "atalla" and "ubsec" string definitions were moved from header files
707 to C code. "nuron" string definitions were placed in variables
708 rather than hard-coded - allowing parameterisation of these values
709 later on via ctrl() commands.
710 - Removed unused "#if 0"'d code.
711 - Fixed engine list iteration code so it uses ENGINE_free() to release
712 structural references.
713 - Constified the RAND_METHOD element of ENGINE structures.
714 - Constified various get/set functions as appropriate and added
715 missing functions (including a catch-all ENGINE_cpy that duplicates
716 all ENGINE values onto a new ENGINE except reference counts/state).
717 - Removed NULL parameter checks in get/set functions. Setting a method
718 or function to NULL is a way of cancelling out a previously set
719 value. Passing a NULL ENGINE parameter is just plain stupid anyway
720 and doesn't justify the extra error symbols and code.
721 - Deprecate the ENGINE_FLAGS_MALLOCED define and move the area for
722 flags from engine_int.h to engine.h.
723 - Changed prototypes for ENGINE handler functions (init(), finish(),
724 ctrl(), key-load functions, etc) to take an (ENGINE*) parameter.
725 [Geoff]
726
727 *) Implement binary inversion algorithm for BN_mod_inverse in addition
728 to the algorithm using long division. The binary algorithm can be
729 used only if the modulus is odd. On 32-bit systems, it is faster
730 only for relatively small moduli (roughly 20-30% for 128-bit moduli,
731 roughly 5-15% for 256-bit moduli), so we use it only for moduli
732 up to 450 bits. In 64-bit environments, the binary algorithm
733 appears to be advantageous for much longer moduli; here we use it
734 for moduli up to 2048 bits.
735 [Bodo Moeller]
736
737 *) Rewrite CHOICE field setting in ASN1_item_ex_d2i(). The old code
738 could not support the combine flag in choice fields.
739 [Steve Henson]
740
741 *) Add a 'copy_extensions' option to the 'ca' utility. This copies
742 extensions from a certificate request to the certificate.
743 [Steve Henson]
744
745 *) Allow multiple 'certopt' and 'nameopt' options to be separated
746 by commas. Add 'namopt' and 'certopt' options to the 'ca' config
747 file: this allows the display of the certificate about to be
748 signed to be customised, to allow certain fields to be included
749 or excluded and extension details. The old system didn't display
750 multicharacter strings properly, omitted fields not in the policy
751 and couldn't display additional details such as extensions.
752 [Steve Henson]
753
754 *) Function EC_POINTs_mul for multiple scalar multiplication
755 of an arbitrary number of elliptic curve points
756 \sum scalars[i]*points[i],
757 optionally including the generator defined for the EC_GROUP:
758 scalar*generator + \sum scalars[i]*points[i].
759
760 EC_POINT_mul is a simple wrapper function for the typical case
761 that the point list has just one item (besides the optional
762 generator).
763 [Bodo Moeller]
764
765 *) First EC_METHODs for curves over GF(p):
766
767 EC_GFp_simple_method() uses the basic BN_mod_mul and BN_mod_sqr
768 operations and provides various method functions that can also
769 operate with faster implementations of modular arithmetic.
770
771 EC_GFp_mont_method() reuses most functions that are part of
772 EC_GFp_simple_method, but uses Montgomery arithmetic.
773
774 [Bodo Moeller; point addition and point doubling
775 implementation directly derived from source code provided by
776 Lenka Fibikova <fibikova@exp-math.uni-essen.de>]
777
778 *) Framework for elliptic curves (crypto/ec/ec.h, crypto/ec/ec_lcl.h,
779 crypto/ec/ec_lib.c):
780
781 Curves are EC_GROUP objects (with an optional group generator)
782 based on EC_METHODs that are built into the library.
783
784 Points are EC_POINT objects based on EC_GROUP objects.
785
786 Most of the framework would be able to handle curves over arbitrary
787 finite fields, but as there are no obvious types for fields other
788 than GF(p), some functions are limited to that for now.
789 [Bodo Moeller]
790
791 *) Add the -HTTP option to s_server. It is similar to -WWW, but requires
792 that the file contains a complete HTTP response.
793 [Richard Levitte]
794
795 *) Add the ec directory to mkdef.pl and mkfiles.pl. In mkdef.pl
796 change the def and num file printf format specifier from "%-40sXXX"
797 to "%-39s XXX". The latter will always guarantee a space after the
798 field while the former will cause them to run together if the field
799 is 40 of more characters long.
800 [Steve Henson]
801
802 *) Constify the cipher and digest 'method' functions and structures
803 and modify related functions to take constant EVP_MD and EVP_CIPHER
804 pointers.
805 [Steve Henson]
806
807 *) Hide BN_CTX structure details in bn_lcl.h instead of publishing them
808 in <openssl/bn.h>. Also further increase BN_CTX_NUM to 32.
809 [Bodo Moeller]
810
811 *) Modify EVP_Digest*() routines so they now return values. Although the
812 internal software routines can never fail additional hardware versions
813 might.
814 [Steve Henson]
815
816 *) Clean up crypto/err/err.h and change some error codes to avoid conflicts:
817
818 Previously ERR_R_FATAL was too small and coincided with ERR_LIB_PKCS7
819 (= ERR_R_PKCS7_LIB); it is now 64 instead of 32.
820
821 ASN1 error codes
822 ERR_R_NESTED_ASN1_ERROR
823 ...
824 ERR_R_MISSING_ASN1_EOS
825 were 4 .. 9, conflicting with
826 ERR_LIB_RSA (= ERR_R_RSA_LIB)
827 ...
828 ERR_LIB_PEM (= ERR_R_PEM_LIB).
829 They are now 58 .. 63 (i.e., just below ERR_R_FATAL).
830
831 Add new error code 'ERR_R_INTERNAL_ERROR'.
832 [Bodo Moeller]
833
834 *) Don't overuse locks in crypto/err/err.c: For data retrieval, CRYPTO_r_lock
835 suffices.
836 [Bodo Moeller]
837
838 *) New option '-subj arg' for 'openssl req' and 'openssl ca'. This
839 sets the subject name for a new request or supersedes the
840 subject name in a given request. Formats that can be parsed are
841 'CN=Some Name, OU=myOU, C=IT'
842 and
843 'CN=Some Name/OU=myOU/C=IT'.
844
845 Add options '-batch' and '-verbose' to 'openssl req'.
846 [Massimiliano Pala <madwolf@hackmasters.net>]
847
848 *) Introduce the possibility to access global variables through
849 functions on platform were that's the best way to handle exporting
850 global variables in shared libraries. To enable this functionality,
851 one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
852 "OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
853 is normally done by Configure or something similar).
854
855 To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
856 in the source file (foo.c) like this:
857
858 OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
859 OPENSSL_IMPLEMENT_GLOBAL(double,bar);
860
861 To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
862 and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
863
864 OPENSSL_DECLARE_GLOBAL(int,foo);
865 #define foo OPENSSL_GLOBAL_REF(foo)
866 OPENSSL_DECLARE_GLOBAL(double,bar);
867 #define bar OPENSSL_GLOBAL_REF(bar)
868
869 The #defines are very important, and therefore so is including the
870 header file everywhere where the defined globals are used.
871
872 The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
873 of ASN.1 items, but that structure is a bit different.
874
875 The largest change is in util/mkdef.pl which has been enhanced with
876 better and easier to understand logic to choose which symbols should
877 go into the Windows .def files as well as a number of fixes and code
878 cleanup (among others, algorithm keywords are now sorted
879 lexicographically to avoid constant rewrites).
880 [Richard Levitte]
881
882 *) In BN_div() keep a copy of the sign of 'num' before writing the
883 result to 'rm' because if rm==num the value will be overwritten
884 and produce the wrong result if 'num' is negative: this caused
885 problems with BN_mod() and BN_nnmod().
886 [Steve Henson]
887
888 *) Function OCSP_request_verify(). This checks the signature on an
889 OCSP request and verifies the signer certificate. The signer
890 certificate is just checked for a generic purpose and OCSP request
891 trust settings.
892 [Steve Henson]
893
894 *) Add OCSP_check_validity() function to check the validity of OCSP
895 responses. OCSP responses are prepared in real time and may only
896 be a few seconds old. Simply checking that the current time lies
897 between thisUpdate and nextUpdate max reject otherwise valid responses
898 caused by either OCSP responder or client clock inaccuracy. Instead
899 we allow thisUpdate and nextUpdate to fall within a certain period of
900 the current time. The age of the response can also optionally be
901 checked. Two new options -validity_period and -status_age added to
902 ocsp utility.
903 [Steve Henson]
904
905 *) If signature or public key algorithm is unrecognized print out its
906 OID rather that just UNKNOWN.
907 [Steve Henson]
908
909 *) Change OCSP_cert_to_id() to tolerate a NULL subject certificate and
910 OCSP_cert_id_new() a NULL serialNumber. This allows a partial certificate
911 ID to be generated from the issuer certificate alone which can then be
912 passed to OCSP_id_issuer_cmp().
913 [Steve Henson]
914
915 *) New compilation option ASN1_ITEM_FUNCTIONS. This causes the new
916 ASN1 modules to export functions returning ASN1_ITEM pointers
917 instead of the ASN1_ITEM structures themselves. This adds several
918 new macros which allow the underlying ASN1 function/structure to
919 be accessed transparently. As a result code should not use ASN1_ITEM
920 references directly (such as &X509_it) but instead use the relevant
921 macros (such as ASN1_ITEM_rptr(X509)). This option is to allow
922 use of the new ASN1 code on platforms where exporting structures
923 is problematical (for example in shared libraries) but exporting
924 functions returning pointers to structures is not.
925 [Steve Henson]
926
927 *) Add support for overriding the generation of SSL/TLS session IDs.
928 These callbacks can be registered either in an SSL_CTX or per SSL.
929 The purpose of this is to allow applications to control, if they wish,
930 the arbitrary values chosen for use as session IDs, particularly as it
931 can be useful for session caching in multiple-server environments. A
932 command-line switch for testing this (and any client code that wishes
933 to use such a feature) has been added to "s_server".
934 [Geoff Thorpe, Lutz Jaenicke]
935
936 *) Modify mkdef.pl to recognise and parse preprocessor conditionals
937 of the form '#if defined(...) || defined(...) || ...' and
938 '#if !defined(...) && !defined(...) && ...'. This also avoids
939 the growing number of special cases it was previously handling.
940 [Richard Levitte]
941
942 *) Make all configuration macros available for application by making
943 sure they are available in opensslconf.h, by giving them names starting
944 with "OPENSSL_" to avoid conflicts with other packages and by making
945 sure e_os2.h will cover all platform-specific cases together with
946 opensslconf.h.
947 Additionally, it is now possible to define configuration/platform-
948 specific names (called "system identities"). In the C code, these
949 are prefixed with "OPENSSL_SYSNAME_". e_os2.h will create another
950 macro with the name beginning with "OPENSSL_SYS_", which is determined
951 from "OPENSSL_SYSNAME_*" or compiler-specific macros depending on
952 what is available.
953 [Richard Levitte]
954
955 *) New option -set_serial to 'req' and 'x509' this allows the serial
956 number to use to be specified on the command line. Previously self
957 signed certificates were hard coded with serial number 0 and the
958 CA options of 'x509' had to use a serial number in a file which was
959 auto incremented.
960 [Steve Henson]
961
962 *) New options to 'ca' utility to support V2 CRL entry extensions.
963 Currently CRL reason, invalidity date and hold instruction are
964 supported. Add new CRL extensions to V3 code and some new objects.
965 [Steve Henson]
966
967 *) New function EVP_CIPHER_CTX_set_padding() this is used to
968 disable standard block padding (aka PKCS#5 padding) in the EVP
969 API, which was previously mandatory. This means that the data is
970 not padded in any way and so the total length much be a multiple
971 of the block size, otherwise an error occurs.
972 [Steve Henson]
973
974 *) Initial (incomplete) OCSP SSL support.
975 [Steve Henson]
976
977 *) New function OCSP_parse_url(). This splits up a URL into its host,
978 port and path components: primarily to parse OCSP URLs. New -url
979 option to ocsp utility.
980 [Steve Henson]
981
982 *) New nonce behavior. The return value of OCSP_check_nonce() now
983 reflects the various checks performed. Applications can decide
984 whether to tolerate certain situations such as an absent nonce
985 in a response when one was present in a request: the ocsp application
986 just prints out a warning. New function OCSP_add1_basic_nonce()
987 this is to allow responders to include a nonce in a response even if
988 the request is nonce-less.
989 [Steve Henson]
990
991 *) Disable stdin buffering in load_cert (apps/apps.c) so that no certs are
992 skipped when using openssl x509 multiple times on a single input file,
993 e.g. "(openssl x509 -out cert1; openssl x509 -out cert2) <certs".
994 [Bodo Moeller]
995
996 *) Make ASN1_UTCTIME_set_string() and ASN1_GENERALIZEDTIME_set_string()
997 set string type: to handle setting ASN1_TIME structures. Fix ca
998 utility to correctly initialize revocation date of CRLs.
999 [Steve Henson]
1000
1001 *) New option SSL_OP_CIPHER_SERVER_PREFERENCE allows the server to override
1002 the clients preferred ciphersuites and rather use its own preferences.
1003 Should help to work around M$ SGC (Server Gated Cryptography) bug in
1004 Internet Explorer by ensuring unchanged hash method during stepup.
1005 (Also replaces the broken/deactivated SSL_OP_NON_EXPORT_FIRST option.)
1006 [Lutz Jaenicke]
1007
1008 *) Make mkdef.pl recognise all DECLARE_ASN1 macros, change rijndael
1009 to aes and add a new 'exist' option to print out symbols that don't
1010 appear to exist.
1011 [Steve Henson]
1012
1013 *) Additional options to ocsp utility to allow flags to be set and
1014 additional certificates supplied.
1015 [Steve Henson]
1016
1017 *) Add the option -VAfile to 'openssl ocsp', so the user can give the
1018 OCSP client a number of certificate to only verify the response
1019 signature against.
1020 [Richard Levitte]
1021
1022 *) Update Rijndael code to version 3.0 and change EVP AES ciphers to
1023 handle the new API. Currently only ECB, CBC modes supported. Add new
1024 AES OIDs.
1025
1026 Add TLS AES ciphersuites as described in the "AES Ciphersuites
1027 for TLS" draft-ietf-tls-ciphersuite-06.txt. As these are not yet
1028 official, they are not enabled by default and are not even part
1029 of the "ALL" ciphersuite alias; for now, they must be explicitly
1030 requested by specifying the new "AESdraft" ciphersuite alias. If
1031 you want the default ciphersuite list plus the new ciphersuites,
1032 use "DEFAULT:AESdraft:@STRENGTH".
1033 [Ben Laurie, Steve Henson, Bodo Moeller]
1034
1035 *) New function OCSP_copy_nonce() to copy nonce value (if present) from
1036 request to response.
1037 [Steve Henson]
1038
1039 *) Functions for OCSP responders. OCSP_request_onereq_count(),
1040 OCSP_request_onereq_get0(), OCSP_onereq_get0_id() and OCSP_id_get0_info()
1041 extract information from a certificate request. OCSP_response_create()
1042 creates a response and optionally adds a basic response structure.
1043 OCSP_basic_add1_status() adds a complete single response to a basic
1044 response and returns the OCSP_SINGLERESP structure just added (to allow
1045 extensions to be included for example). OCSP_basic_add1_cert() adds a
1046 certificate to a basic response and OCSP_basic_sign() signs a basic
1047 response with various flags. New helper functions ASN1_TIME_check()
1048 (checks validity of ASN1_TIME structure) and ASN1_TIME_to_generalizedtime()
1049 (converts ASN1_TIME to GeneralizedTime).
1050 [Steve Henson]
1051
1052 *) Various new functions. EVP_Digest() combines EVP_Digest{Init,Update,Final}()
1053 in a single operation. X509_get0_pubkey_bitstr() extracts the public_key
1054 structure from a certificate. X509_pubkey_digest() digests the public_key
1055 contents: this is used in various key identifiers.
1056 [Steve Henson]
1057
1058 *) Make sk_sort() tolerate a NULL argument.
1059 [Steve Henson reported by Massimiliano Pala <madwolf@comune.modena.it>]
1060
1061 *) New OCSP verify flag OCSP_TRUSTOTHER. When set the "other" certificates
1062 passed by the function are trusted implicitly. If any of them signed the
1063 response then it is assumed to be valid and is not verified.
1064 [Steve Henson]
1065
1066 *) In PKCS7_set_type() initialise content_type in PKCS7_ENC_CONTENT
1067 to data. This was previously part of the PKCS7 ASN1 code. This
1068 was causing problems with OpenSSL created PKCS#12 and PKCS#7 structures.
1069 [Steve Henson, reported by Kenneth R. Robinette
1070 <support@securenetterm.com>]
1071
1072 *) Add CRYPTO_push_info() and CRYPTO_pop_info() calls to new ASN1
1073 routines: without these tracing memory leaks is very painful.
1074 Fix leaks in PKCS12 and PKCS7 routines.
1075 [Steve Henson]
1076
1077 *) Make X509_time_adj() cope with the new behaviour of ASN1_TIME_new().
1078 Previously it initialised the 'type' argument to V_ASN1_UTCTIME which
1079 effectively meant GeneralizedTime would never be used. Now it
1080 is initialised to -1 but X509_time_adj() now has to check the value
1081 and use ASN1_TIME_set() if the value is not V_ASN1_UTCTIME or
1082 V_ASN1_GENERALIZEDTIME, without this it always uses GeneralizedTime.
1083 [Steve Henson, reported by Kenneth R. Robinette
1084 <support@securenetterm.com>]
1085
1086 *) Fixes to BN_to_ASN1_INTEGER when bn is zero. This would previously
1087 result in a zero length in the ASN1_INTEGER structure which was
1088 not consistent with the structure when d2i_ASN1_INTEGER() was used
1089 and would cause ASN1_INTEGER_cmp() to fail. Enhance s2i_ASN1_INTEGER()
1090 to cope with hex and negative integers. Fix bug in i2a_ASN1_INTEGER()
1091 where it did not print out a minus for negative ASN1_INTEGER.
1092 [Steve Henson]
1093
1094 *) Add summary printout to ocsp utility. The various functions which
1095 convert status values to strings have been renamed to:
1096 OCSP_response_status_str(), OCSP_cert_status_str() and
1097 OCSP_crl_reason_str() and are no longer static. New options
1098 to verify nonce values and to disable verification. OCSP response
1099 printout format cleaned up.
1100 [Steve Henson]
1101
1102 *) Add additional OCSP certificate checks. These are those specified
1103 in RFC2560. This consists of two separate checks: the CA of the
1104 certificate being checked must either be the OCSP signer certificate
1105 or the issuer of the OCSP signer certificate. In the latter case the
1106 OCSP signer certificate must contain the OCSP signing extended key
1107 usage. This check is performed by attempting to match the OCSP
1108 signer or the OCSP signer CA to the issuerNameHash and issuerKeyHash
1109 in the OCSP_CERTID structures of the response.
1110 [Steve Henson]
1111
1112 *) Initial OCSP certificate verification added to OCSP_basic_verify()
1113 and related routines. This uses the standard OpenSSL certificate
1114 verify routines to perform initial checks (just CA validity) and
1115 to obtain the certificate chain. Then additional checks will be
1116 performed on the chain. Currently the root CA is checked to see
1117 if it is explicitly trusted for OCSP signing. This is used to set
1118 a root CA as a global signing root: that is any certificate that
1119 chains to that CA is an acceptable OCSP signing certificate.
1120 [Steve Henson]
1121
1122 *) New '-extfile ...' option to 'openssl ca' for reading X.509v3
1123 extensions from a separate configuration file.
1124 As when reading extensions from the main configuration file,
1125 the '-extensions ...' option may be used for specifying the
1126 section to use.
1127 [Massimiliano Pala <madwolf@comune.modena.it>]
1128
1129 *) New OCSP utility. Allows OCSP requests to be generated or
1130 read. The request can be sent to a responder and the output
1131 parsed, outputed or printed in text form. Not complete yet:
1132 still needs to check the OCSP response validity.
1133 [Steve Henson]
1134
1135 *) New subcommands for 'openssl ca':
1136 'openssl ca -status <serial>' prints the status of the cert with
1137 the given serial number (according to the index file).
1138 'openssl ca -updatedb' updates the expiry status of certificates
1139 in the index file.
1140 [Massimiliano Pala <madwolf@comune.modena.it>]
1141
1142 *) New '-newreq-nodes' command option to CA.pl. This is like
1143 '-newreq', but calls 'openssl req' with the '-nodes' option
1144 so that the resulting key is not encrypted.
1145 [Damien Miller <djm@mindrot.org>]
1146
1147 *) New configuration for the GNU Hurd.
1148 [Jonathan Bartlett <johnnyb@wolfram.com> via Richard Levitte]
1149
1150 *) Initial code to implement OCSP basic response verify. This
1151 is currently incomplete. Currently just finds the signer's
1152 certificate and verifies the signature on the response.
1153 [Steve Henson]
1154
1155 *) New SSLeay_version code SSLEAY_DIR to determine the compiled-in
1156 value of OPENSSLDIR. This is available via the new '-d' option
1157 to 'openssl version', and is also included in 'openssl version -a'.
1158 [Bodo Moeller]
1159
1160 *) Allowing defining memory allocation callbacks that will be given
1161 file name and line number information in additional arguments
1162 (a const char* and an int). The basic functionality remains, as
1163 well as the original possibility to just replace malloc(),
1164 realloc() and free() by functions that do not know about these
1165 additional arguments. To register and find out the current
1166 settings for extended allocation functions, the following
1167 functions are provided:
1168
1169 CRYPTO_set_mem_ex_functions
1170 CRYPTO_set_locked_mem_ex_functions
1171 CRYPTO_get_mem_ex_functions
1172 CRYPTO_get_locked_mem_ex_functions
1173
1174 These work the same way as CRYPTO_set_mem_functions and friends.
1175 CRYPTO_get_[locked_]mem_functions now writes 0 where such an
1176 extended allocation function is enabled.
1177 Similarly, CRYPTO_get_[locked_]mem_ex_functions writes 0 where
1178 a conventional allocation function is enabled.
1179 [Richard Levitte, Bodo Moeller]
1180
1181 *) Finish off removing the remaining LHASH function pointer casts.
1182 There should no longer be any prototype-casting required when using
1183 the LHASH abstraction, and any casts that remain are "bugs". See
1184 the callback types and macros at the head of lhash.h for details
1185 (and "OBJ_cleanup" in crypto/objects/obj_dat.c as an example).
1186 [Geoff Thorpe]
1187
1188 *) Add automatic query of EGD sockets in RAND_poll() for the unix variant.
1189 If /dev/[u]random devices are not available or do not return enough
1190 entropy, EGD style sockets (served by EGD or PRNGD) will automatically
1191 be queried.
1192 The locations /var/run/egd-pool, /dev/egd-pool, /etc/egd-pool, and
1193 /etc/entropy will be queried once each in this sequence, quering stops
1194 when enough entropy was collected without querying more sockets.
1195 [Lutz Jaenicke]
1196
1197 *) Change the Unix RAND_poll() variant to be able to poll several
1198 random devices, as specified by DEVRANDOM, until a sufficient amount
1199 of data has been collected. We spend at most 10 ms on each file
1200 (select timeout) and read in non-blocking mode. DEVRANDOM now
1201 defaults to the list "/dev/urandom", "/dev/random", "/dev/srandom"
1202 (previously it was just the string "/dev/urandom"), so on typical
1203 platforms the 10 ms delay will never occur.
1204 Also separate out the Unix variant to its own file, rand_unix.c.
1205 For VMS, there's a currently-empty rand_vms.c.
1206 [Richard Levitte]
1207
1208 *) Move OCSP client related routines to ocsp_cl.c. These
1209 provide utility functions which an application needing
1210 to issue a request to an OCSP responder and analyse the
1211 response will typically need: as opposed to those which an
1212 OCSP responder itself would need which will be added later.
1213
1214 OCSP_request_sign() signs an OCSP request with an API similar
1215 to PKCS7_sign(). OCSP_response_status() returns status of OCSP
1216 response. OCSP_response_get1_basic() extracts basic response
1217 from response. OCSP_resp_find_status(): finds and extracts status
1218 information from an OCSP_CERTID structure (which will be created
1219 when the request structure is built). These are built from lower
1220 level functions which work on OCSP_SINGLERESP structures but
1221 wont normally be used unless the application wishes to examine
1222 extensions in the OCSP response for example.
1223
1224 Replace nonce routines with a pair of functions.
1225 OCSP_request_add1_nonce() adds a nonce value and optionally
1226 generates a random value. OCSP_check_nonce() checks the
1227 validity of the nonce in an OCSP response.
1228 [Steve Henson]
1229
1230 *) Change function OCSP_request_add() to OCSP_request_add0_id().
1231 This doesn't copy the supplied OCSP_CERTID and avoids the
1232 need to free up the newly created id. Change return type
1233 to OCSP_ONEREQ to return the internal OCSP_ONEREQ structure.
1234 This can then be used to add extensions to the request.
1235 Deleted OCSP_request_new(), since most of its functionality
1236 is now in OCSP_REQUEST_new() (and the case insensitive name
1237 clash) apart from the ability to set the request name which
1238 will be added elsewhere.
1239 [Steve Henson]
1240
1241 *) Update OCSP API. Remove obsolete extensions argument from
1242 various functions. Extensions are now handled using the new
1243 OCSP extension code. New simple OCSP HTTP function which
1244 can be used to send requests and parse the response.
1245 [Steve Henson]
1246
1247 *) Fix the PKCS#7 (S/MIME) code to work with new ASN1. Two new
1248 ASN1_ITEM structures help with sign and verify. PKCS7_ATTR_SIGN
1249 uses the special reorder version of SET OF to sort the attributes
1250 and reorder them to match the encoded order. This resolves a long
1251 standing problem: a verify on a PKCS7 structure just after signing
1252 it used to fail because the attribute order did not match the
1253 encoded order. PKCS7_ATTR_VERIFY does not reorder the attributes:
1254 it uses the received order. This is necessary to tolerate some broken
1255 software that does not order SET OF. This is handled by encoding
1256 as a SEQUENCE OF but using implicit tagging (with UNIVERSAL class)
1257 to produce the required SET OF.
1258 [Steve Henson]
1259
1260 *) Have mk1mf.pl generate the macros OPENSSL_BUILD_SHLIBCRYPTO and
1261 OPENSSL_BUILD_SHLIBSSL and use them appropriately in the header
1262 files to get correct declarations of the ASN.1 item variables.
1263 [Richard Levitte]
1264
1265 *) Rewrite of PKCS#12 code to use new ASN1 functionality. Replace many
1266 PKCS#12 macros with real functions. Fix two unrelated ASN1 bugs:
1267 asn1_check_tlen() would sometimes attempt to use 'ctx' when it was
1268 NULL and ASN1_TYPE was not dereferenced properly in asn1_ex_c2i().
1269 New ASN1 macro: DECLARE_ASN1_ITEM() which just declares the relevant
1270 ASN1_ITEM and no wrapper functions.
1271 [Steve Henson]
1272
1273 *) New functions or ASN1_item_d2i_fp() and ASN1_item_d2i_bio(). These
1274 replace the old function pointer based I/O routines. Change most of
1275 the *_d2i_bio() and *_d2i_fp() functions to use these.
1276 [Steve Henson]
1277
1278 *) Enhance mkdef.pl to be more accepting about spacing in C preprocessor
1279 lines, recognice more "algorithms" that can be deselected, and make
1280 it complain about algorithm deselection that isn't recognised.
1281 [Richard Levitte]
1282
1283 *) New ASN1 functions to handle dup, sign, verify, digest, pack and
1284 unpack operations in terms of ASN1_ITEM. Modify existing wrappers
1285 to use new functions. Add NO_ASN1_OLD which can be set to remove
1286 some old style ASN1 functions: this can be used to determine if old
1287 code will still work when these eventually go away.
1288 [Steve Henson]
1289
1290 *) New extension functions for OCSP structures, these follow the
1291 same conventions as certificates and CRLs.
1292 [Steve Henson]
1293
1294 *) New function X509V3_add1_i2d(). This automatically encodes and
1295 adds an extension. Its behaviour can be customised with various
1296 flags to append, replace or delete. Various wrappers added for
1297 certifcates and CRLs.
1298 [Steve Henson]
1299
1300 *) Fix to avoid calling the underlying ASN1 print routine when
1301 an extension cannot be parsed. Correct a typo in the
1302 OCSP_SERVICELOC extension. Tidy up print OCSP format.
1303 [Steve Henson]
1304
1305 *) Make mkdef.pl parse some of the ASN1 macros and add apropriate
1306 entries for variables.
1307 [Steve Henson]
1308
1309 *) Add functionality to apps/openssl.c for detecting locking
1310 problems: As the program is single-threaded, all we have
1311 to do is register a locking callback using an array for
1312 storing which locks are currently held by the program.
1313 [Bodo Moeller]
1314
1315 *) Use a lock around the call to CRYPTO_get_ex_new_index() in
1316 SSL_get_ex_data_X509_STORE_idx(), which is used in
1317 ssl_verify_cert_chain() and thus can be called at any time
1318 during TLS/SSL handshakes so that thread-safety is essential.
1319 Unfortunately, the ex_data design is not at all suited
1320 for multi-threaded use, so it probably should be abolished.
1321 [Bodo Moeller]
1322
1323 *) Added Broadcom "ubsec" ENGINE to OpenSSL.
1324 [Broadcom, tweaked and integrated by Geoff Thorpe]
1325
1326 *) Move common extension printing code to new function
1327 X509V3_print_extensions(). Reorganise OCSP print routines and
1328 implement some needed OCSP ASN1 functions. Add OCSP extensions.
1329 [Steve Henson]
1330
1331 *) New function X509_signature_print() to remove duplication in some
1332 print routines.
1333 [Steve Henson]
1334
1335 *) Add a special meaning when SET OF and SEQUENCE OF flags are both
1336 set (this was treated exactly the same as SET OF previously). This
1337 is used to reorder the STACK representing the structure to match the
1338 encoding. This will be used to get round a problem where a PKCS7
1339 structure which was signed could not be verified because the STACK
1340 order did not reflect the encoded order.
1341 [Steve Henson]
1342
1343 *) Reimplement the OCSP ASN1 module using the new code.
1344 [Steve Henson]
1345
1346 *) Update the X509V3 code to permit the use of an ASN1_ITEM structure
1347 for its ASN1 operations. The old style function pointers still exist
1348 for now but they will eventually go away.
1349 [Steve Henson]
1350
1351 *) Merge in replacement ASN1 code from the ASN1 branch. This almost
1352 completely replaces the old ASN1 functionality with a table driven
1353 encoder and decoder which interprets an ASN1_ITEM structure describing
1354 the ASN1 module. Compatibility with the existing ASN1 API (i2d,d2i) is
1355 largely maintained. Almost all of the old asn1_mac.h macro based ASN1
1356 has also been converted to the new form.
1357 [Steve Henson]
1358
1359 *) Change BN_mod_exp_recp so that negative moduli are tolerated
1360 (the sign is ignored). Similarly, ignore the sign in BN_MONT_CTX_set
1361 so that BN_mod_exp_mont and BN_mod_exp_mont_word work
1362 for negative moduli.
1363 [Bodo Moeller]
1364
1365 *) Fix BN_uadd and BN_usub: Always return non-negative results instead
1366 of not touching the result's sign bit.
1367 [Bodo Moeller]
1368
1369 *) BN_div bugfix: If the result is 0, the sign (res->neg) must not be
1370 set.
1371 [Bodo Moeller]
1372
1373 *) Changed the LHASH code to use prototypes for callbacks, and created
1374 macros to declare and implement thin (optionally static) functions
1375 that provide type-safety and avoid function pointer casting for the
1376 type-specific callbacks.
1377 [Geoff Thorpe]
1378
1379 *) Added Kerberos Cipher Suites to be used with TLS, as written in
1380 RFC 2712.
1381 [Veers Staats <staatsvr@asc.hpc.mil>,
1382 Jeffrey Altman <jaltman@columbia.edu>, via Richard Levitte]
1383
1384 *) Reformat the FAQ so the different questions and answers can be divided
1385 in sections depending on the subject.
1386 [Richard Levitte]
1387
1388 *) Have the zlib compression code load ZLIB.DLL dynamically under
1389 Windows.
1390 [Richard Levitte]
1391
1392 *) New function BN_mod_sqrt for computing square roots modulo a prime
1393 (using the probabilistic Tonelli-Shanks algorithm unless
1394 p == 3 (mod 4) or p == 5 (mod 8), which are cases that can
1395 be handled deterministically).
1396 [Lenka Fibikova <fibikova@exp-math.uni-essen.de>, Bodo Moeller]
1397
1398 *) Make BN_mod_inverse faster by explicitly handling small quotients
1399 in the Euclid loop. (Speed gain about 20% for small moduli [256 or
1400 512 bits], about 30% for larger ones [1024 or 2048 bits].)
1401 [Bodo Moeller]
1402
1403 *) New function BN_kronecker.
1404 [Bodo Moeller]
1405
1406 *) Fix BN_gcd so that it works on negative inputs; the result is
1407 positive unless both parameters are zero.
1408 Previously something reasonably close to an infinite loop was
1409 possible because numbers could be growing instead of shrinking
1410 in the implementation of Euclid's algorithm.
1411 [Bodo Moeller]
1412
1413 *) Fix BN_is_word() and BN_is_one() macros to take into account the
1414 sign of the number in question.
1415
1416 Fix BN_is_word(a,w) to work correctly for w == 0.
1417
1418 The old BN_is_word(a,w) macro is now called BN_abs_is_word(a,w)
1419 because its test if the absolute value of 'a' equals 'w'.
1420 Note that BN_abs_is_word does *not* handle w == 0 reliably;
1421 it exists mostly for use in the implementations of BN_is_zero(),
1422 BN_is_one(), and BN_is_word().
1423 [Bodo Moeller]
1424
1425 *) New function BN_swap.
1426 [Bodo Moeller]
1427
1428 *) Use BN_nnmod instead of BN_mod in crypto/bn/bn_exp.c so that
1429 the exponentiation functions are more likely to produce reasonable
1430 results on negative inputs.
1431 [Bodo Moeller]
1432
1433 *) Change BN_mod_mul so that the result is always non-negative.
1434 Previously, it could be negative if one of the factors was negative;
1435 I don't think anyone really wanted that behaviour.
1436 [Bodo Moeller]
1437
1438 *) Move BN_mod_... functions into new file crypto/bn/bn_mod.c
1439 (except for exponentiation, which stays in crypto/bn/bn_exp.c,
1440 and BN_mod_mul_reciprocal, which stays in crypto/bn/bn_recp.c)
1441 and add new functions:
1442
1443 BN_nnmod
1444 BN_mod_sqr
1445 BN_mod_add
1446 BN_mod_add_quick
1447 BN_mod_sub
1448 BN_mod_sub_quick
1449 BN_mod_lshift1
1450 BN_mod_lshift1_quick
1451 BN_mod_lshift
1452 BN_mod_lshift_quick
1453
1454 These functions always generate non-negative results.
1455
1456 BN_nnmod otherwise is like BN_mod (if BN_mod computes a remainder r
1457 such that |m| < r < 0, BN_nnmod will output rem + |m| instead).
1458
1459 BN_mod_XXX_quick(r, a, [b,] m) generates the same result as
1460 BN_mod_XXX(r, a, [b,] m, ctx), but requires that a [and b]
1461 be reduced modulo m.
1462 [Lenka Fibikova <fibikova@exp-math.uni-essen.de>, Bodo Moeller]
1463
1464 *) Remove a few calls to bn_wexpand() in BN_sqr() (the one in there
1465 was actually never needed) and in BN_mul(). The removal in BN_mul()
1466 required a small change in bn_mul_part_recursive() and the addition
1467 of the functions bn_cmp_part_words(), bn_sub_part_words() and
1468 bn_add_part_words(), which do the same thing as bn_cmp_words(),
1469 bn_sub_words() and bn_add_words() except they take arrays with
1470 differing sizes.
1471 [Richard Levitte]
1472
1473 *) In 'openssl passwd', verify passwords read from the terminal
1474 unless the '-salt' option is used (which usually means that
1475 verification would just waste user's time since the resulting
1476 hash is going to be compared with some given password hash)
1477 or the new '-noverify' option is used.
1478
1479 This is an incompatible change, but it does not affect
1480 non-interactive use of 'openssl passwd' (passwords on the command
1481 line, '-stdin' option, '-in ...' option) and thus should not
1482 cause any problems.
1483 [Bodo Moeller]
1484
1485 *) Remove all references to RSAref, since there's no more need for it.
1486 [Richard Levitte]
1487
1488 *) Make DSO load along a path given through an environment variable
1489 (SHLIB_PATH) with shl_load().
1490 [Richard Levitte]
1491
1492 *) Constify the ENGINE code as a result of BIGNUM constification.
1493 Also constify the RSA code and most things related to it. In a
1494 few places, most notable in the depth of the ASN.1 code, ugly
1495 casts back to non-const were required (to be solved at a later
1496 time)
1497 [Richard Levitte]
1498
1499 *) Make it so the openssl application has all engines loaded by default.
1500 [Richard Levitte]
1501
1502 *) Constify the BIGNUM routines a little more.
1503 [Richard Levitte]
1504
1505 *) Add the following functions:
1506
1507 ENGINE_load_cswift()
1508 ENGINE_load_chil()
1509 ENGINE_load_atalla()
1510 ENGINE_load_nuron()
1511 ENGINE_load_builtin_engines()
1512
1513 That way, an application can itself choose if external engines that
1514 are built-in in OpenSSL shall ever be used or not. The benefit is
1515 that applications won't have to be linked with libdl or other dso
1516 libraries unless it's really needed.
1517
1518 Changed 'openssl engine' to load all engines on demand.
1519 Changed the engine header files to avoid the duplication of some
1520 declarations (they differed!).
1521 [Richard Levitte]
1522
1523 *) 'openssl engine' can now list capabilities.
1524 [Richard Levitte]
1525
1526 *) Better error reporting in 'openssl engine'.
1527 [Richard Levitte]
1528
1529 *) Never call load_dh_param(NULL) in s_server.
1530 [Bodo Moeller]
1531
1532 *) Add engine application. It can currently list engines by name and
1533 identity, and test if they are actually available.
1534 [Richard Levitte]
1535
1536 *) Improve RPM specification file by forcing symbolic linking and making
1537 sure the installed documentation is also owned by root.root.
1538 [Damien Miller <djm@mindrot.org>]
1539
1540 *) Give the OpenSSL applications more possibilities to make use of
1541 keys (public as well as private) handled by engines.
1542 [Richard Levitte]
1543
1544 *) Add OCSP code that comes from CertCo.
1545 [Richard Levitte]
1546
1547 *) Add VMS support for the Rijndael code.
1548 [Richard Levitte]
1549
1550 *) Added untested support for Nuron crypto accelerator.
1551 [Ben Laurie]
1552
1553 *) Add support for external cryptographic devices. This code was
1554 previously distributed separately as the "engine" branch.
1555 [Geoff Thorpe, Richard Levitte]
1556
1557 *) Rework the filename-translation in the DSO code. It is now possible to
1558 have far greater control over how a "name" is turned into a filename
1559 depending on the operating environment and any oddities about the
1560 different shared library filenames on each system.
1561 [Geoff Thorpe]
1562
1563 *) Support threads on FreeBSD-elf in Configure.
1564 [Richard Levitte]
1565
1566 *) Fix for SHA1 assembly problem with MASM: it produces
1567 warnings about corrupt line number information when assembling
1568 with debugging information. This is caused by the overlapping
1569 of two sections.
1570 [Bernd Matthes <mainbug@celocom.de>, Steve Henson]
1571
1572 *) NCONF changes.
1573 NCONF_get_number() has no error checking at all. As a replacement,
1574 NCONF_get_number_e() is defined (_e for "error checking") and is
1575 promoted strongly. The old NCONF_get_number is kept around for
1576 binary backward compatibility.
1577 Make it possible for methods to load from something other than a BIO,
1578 by providing a function pointer that is given a name instead of a BIO.
1579 For example, this could be used to load configuration data from an
1580 LDAP server.
1581 [Richard Levitte]
1582
1583 *) Fix for non blocking accept BIOs. Added new I/O special reason
1584 BIO_RR_ACCEPT to cover this case. Previously use of accept BIOs
1585 with non blocking I/O was not possible because no retry code was
1586 implemented. Also added new SSL code SSL_WANT_ACCEPT to cover
1587 this case.
1588 [Steve Henson]
1589
1590 *) Added the beginnings of Rijndael support.
1591 [Ben Laurie]
1592
1593 *) Fix for bug in DirectoryString mask setting. Add support for
1594 X509_NAME_print_ex() in 'req' and X509_print_ex() function
1595 to allow certificate printing to more controllable, additional
1596 'certopt' option to 'x509' to allow new printing options to be
1597 set.
1598 [Steve Henson]
1599
1600 *) Clean old EAY MD5 hack from e_os.h.
1601 [Richard Levitte]
1602
1603 Changes between 0.9.6c and 0.9.6d [XX xxx 2002]
1604
1605 *) Fix crypto/asn1/a_sign.c so that 'parameters' is omitted (not
1606 encoded as NULL) with id-dsa-with-sha1.
1607 [Nils Larsch <nla@trustcenter.de>; problem pointed out by Bodo Moeller]
1608
1609 *) Check various X509_...() return values in apps/req.c.
1610 [Nils Larsch <nla@trustcenter.de>]
1611
1612 *) Fix BASE64 decode (EVP_DecodeUpdate) for data with CR/LF ended lines:
1613 an end-of-file condition would erronously be flagged, when the CRLF
1614 was just at the end of a processed block. The bug was discovered when
1615 processing data through a buffering memory BIO handing the data to a
1616 BASE64-decoding BIO. Bug fund and patch submitted by Pavel Tsekov
1617 <ptsekov@syntrex.com> and Nedelcho Stanev.
1618 [Lutz Jaenicke]
1619
1620 *) Implement a countermeasure against a vulnerability recently found
1621 in CBC ciphersuites in SSL 3.0/TLS 1.0: Send an empty fragment
1622 before application data chunks to avoid the use of known IVs
1623 with data potentially chosen by the attacker.
1624 [Bodo Moeller]
1625
1626 *) Fix length checks in ssl3_get_client_hello().
1627 [Bodo Moeller]
1628
1629 *) TLS/SSL library bugfix: use s->s3->in_read_app_data differently
1630 to prevent ssl3_read_internal() from incorrectly assuming that
1631 ssl3_read_bytes() found application data while handshake
1632 processing was enabled when in fact s->s3->in_read_app_data was
1633 merely automatically cleared during the initial handshake.
1634 [Bodo Moeller; problem pointed out by Arne Ansper <arne@ats.cyber.ee>]
1635
1636 *) Fix object definitions for Private and Enterprise: they were not
1637 recognized in their shortname (=lowercase) representation. Extend
1638 obj_dat.pl to issue an error when using undefined keywords instead
1639 of silently ignoring the problem (Svenning Sorensen
1640 <sss@sss.dnsalias.net>).
1641 [Lutz Jaenicke]
1642
1643 *) Fix DH_generate_parameters() so that it works for 'non-standard'
1644 generators, i.e. generators other than 2 and 5. (Previously, the
1645 code did not properly initialise the 'add' and 'rem' values to
1646 BN_generate_prime().)
1647
1648 In the new general case, we do not insist that 'generator' is
1649 actually a primitive root: This requirement is rather pointless;
1650 a generator of the order-q subgroup is just as good, if not
1651 better.
1652 [Bodo Moeller]
1653
1654 *) Map new X509 verification errors to alerts. Discovered and submitted by
1655 Tom Wu <tom@arcot.com>.
1656 [Lutz Jaenicke]
1657
1658 *) Fix ssl3_pending() (ssl/s3_lib.c) to prevent SSL_pending() from
1659 returning non-zero before the data has been completely received
1660 when using non-blocking I/O.
1661 [Bodo Moeller; problem pointed out by John Hughes]
1662
1663 *) Some of the ciphers missed the strength entry (SSL_LOW etc).
1664 [Ben Laurie, Lutz Jaenicke]
1665
1666 *) Fix bug in SSL_clear(): bad sessions were not removed (found by
1667 Yoram Zahavi <YoramZ@gilian.com>).
1668 [Lutz Jaenicke]
1669
1670 *) Add information about CygWin 1.3 and on, and preserve proper
1671 configuration for the versions before that.
1672 [Corinna Vinschen <vinschen@redhat.com> and Richard Levitte]
1673
1674 *) Make removal from session cache (SSL_CTX_remove_session()) more robust:
1675 check whether we deal with a copy of a session and do not delete from
1676 the cache in this case. Problem reported by "Izhar Shoshani Levi"
1677 <izhar@checkpoint.com>.
1678 [Lutz Jaenicke]
1679
1680 *) Do not store session data into the internal session cache, if it
1681 is never intended to be looked up (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
1682 flag is set). Proposed by Aslam <aslam@funk.com>.
1683 [Lutz Jaenicke]
1684
1685 *) Have ASN1_BIT_STRING_set_bit() really clear a bit when the requested
1686 value is 0.
1687 [Richard Levitte]
1688
1689 *) Add the configuration target linux-s390x.
1690 [Neale Ferguson <Neale.Ferguson@SoftwareAG-USA.com> via Richard Levitte]
1691
1692 *) [In 0.9.6d-engine release:]
1693 Fix a crashbug and a logic bug in hwcrhk_load_pubkey().
1694 [Toomas Kiisk <vix@cyber.ee> via Richard Levitte]
1695
1696 *) The earlier bugfix for the SSL3_ST_SW_HELLO_REQ_C case of
1697 ssl3_accept (ssl/s3_srvr.c) incorrectly used a local flag
1698 variable as an indication that a ClientHello message has been
1699 received. As the flag value will be lost between multiple
1700 invocations of ssl3_accept when using non-blocking I/O, the
1701 function may not be aware that a handshake has actually taken
1702 place, thus preventing a new session from being added to the
1703 session cache.
1704
1705 To avoid this problem, we now set s->new_session to 2 instead of
1706 using a local variable.
1707 [Lutz Jaenicke, Bodo Moeller]
1708
1709 *) Bugfix: Return -1 from ssl3_get_server_done (ssl3/s3_clnt.c)
1710 if the SSL_R_LENGTH_MISMATCH error is detected.
1711 [Geoff Thorpe, Bodo Moeller]
1712
1713 *) New 'shared_ldflag' column in Configure platform table.
1714 [Richard Levitte]
1715
1716 *) Fix EVP_CIPHER_mode macro.
1717 ["Dan S. Camper" <dan@bti.net>]
1718
1719 *) Fix ssl3_read_bytes (ssl/s3_pkt.c): To ignore messages of unknown
1720 type, we must throw them away by setting rr->length to 0.
1721 [D P Chang <dpc@qualys.com>]
1722
1723 Changes between 0.9.6b and 0.9.6c [21 dec 2001]
1724
1725 *) Fix BN_rand_range bug pointed out by Dominikus Scherkl
1726 <Dominikus.Scherkl@biodata.com>. (The previous implementation
1727 worked incorrectly for those cases where range = 10..._2 and
1728 3*range is two bits longer than range.)
1729 [Bodo Moeller]
1730
1731 *) Only add signing time to PKCS7 structures if it is not already
1732 present.
1733 [Steve Henson]
1734
1735 *) Fix crypto/objects/objects.h: "ld-ce" should be "id-ce",
1736 OBJ_ld_ce should be OBJ_id_ce.
1737 Also some ip-pda OIDs in crypto/objects/objects.txt were
1738 incorrect (cf. RFC 3039).
1739 [Matt Cooper, Frederic Giudicelli, Bodo Moeller]
1740
1741 *) Release CRYPTO_LOCK_DYNLOCK when CRYPTO_destroy_dynlockid()
1742 returns early because it has nothing to do.
1743 [Andy Schneider <andy.schneider@bjss.co.uk>]
1744
1745 *) [In 0.9.6c-engine release:]
1746 Fix mutex callback return values in crypto/engine/hw_ncipher.c.
1747 [Andy Schneider <andy.schneider@bjss.co.uk>]
1748
1749 *) [In 0.9.6c-engine release:]
1750 Add support for Cryptographic Appliance's keyserver technology.
1751 (Use engine 'keyclient')
1752 [Cryptographic Appliances and Geoff Thorpe]
1753
1754 *) Add a configuration entry for OS/390 Unix. The C compiler 'c89'
1755 is called via tools/c89.sh because arguments have to be
1756 rearranged (all '-L' options must appear before the first object
1757 modules).
1758 [Richard Shapiro <rshapiro@abinitio.com>]
1759
1760 *) [In 0.9.6c-engine release:]
1761 Add support for Broadcom crypto accelerator cards, backported
1762 from 0.9.7.
1763 [Broadcom, Nalin Dahyabhai <nalin@redhat.com>, Mark Cox]
1764
1765 *) [In 0.9.6c-engine release:]
1766 Add support for SureWare crypto accelerator cards from
1767 Baltimore Technologies. (Use engine 'sureware')
1768 [Baltimore Technologies and Mark Cox]
1769
1770 *) [In 0.9.6c-engine release:]
1771 Add support for crypto accelerator cards from Accelerated
1772 Encryption Processing, www.aep.ie. (Use engine 'aep')
1773 [AEP Inc. and Mark Cox]
1774
1775 *) Add a configuration entry for gcc on UnixWare.
1776 [Gary Benson <gbenson@redhat.com>]
1777
1778 *) Change ssl/s2_clnt.c and ssl/s2_srvr.c so that received handshake
1779 messages are stored in a single piece (fixed-length part and
1780 variable-length part combined) and fix various bugs found on the way.
1781 [Bodo Moeller]
1782
1783 *) Disable caching in BIO_gethostbyname(), directly use gethostbyname()
1784 instead. BIO_gethostbyname() does not know what timeouts are
1785 appropriate, so entries would stay in cache even when they have
1786 become invalid.
1787 [Bodo Moeller; problem pointed out by Rich Salz <rsalz@zolera.com>
1788
1789 *) Change ssl23_get_client_hello (ssl/s23_srvr.c) behaviour when
1790 faced with a pathologically small ClientHello fragment that does
1791 not contain client_version: Instead of aborting with an error,
1792 simply choose the highest available protocol version (i.e.,
1793 TLS 1.0 unless it is disabled). In practice, ClientHello
1794 messages are never sent like this, but this change gives us
1795 strictly correct behaviour at least for TLS.
1796 [Bodo Moeller]
1797
1798 *) Fix SSL handshake functions and SSL_clear() such that SSL_clear()
1799 never resets s->method to s->ctx->method when called from within
1800 one of the SSL handshake functions.
1801 [Bodo Moeller; problem pointed out by Niko Baric]
1802
1803 *) In ssl3_get_client_hello (ssl/s3_srvr.c), generate a fatal alert
1804 (sent using the client's version number) if client_version is
1805 smaller than the protocol version in use. Also change
1806 ssl23_get_client_hello (ssl/s23_srvr.c) to select TLS 1.0 if
1807 the client demanded SSL 3.0 but only TLS 1.0 is enabled; then
1808 the client will at least see that alert.
1809 [Bodo Moeller]
1810
1811 *) Fix ssl3_get_message (ssl/s3_both.c) to handle message fragmentation
1812 correctly.
1813 [Bodo Moeller]
1814
1815 *) Avoid infinite loop in ssl3_get_message (ssl/s3_both.c) if a
1816 client receives HelloRequest while in a handshake.
1817 [Bodo Moeller; bug noticed by Andy Schneider <andy.schneider@bjss.co.uk>]
1818
1819 *) Bugfix in ssl3_accept (ssl/s3_srvr.c): Case SSL3_ST_SW_HELLO_REQ_C
1820 should end in 'break', not 'goto end' which circuments various
1821 cleanups done in state SSL_ST_OK. But session related stuff
1822 must be disabled for SSL_ST_OK in the case that we just sent a
1823 HelloRequest.
1824
1825 Also avoid some overhead by not calling ssl_init_wbio_buffer()
1826 before just sending a HelloRequest.
1827 [Bodo Moeller, Eric Rescorla <ekr@rtfm.com>]
1828
1829 *) Fix ssl/s3_enc.c, ssl/t1_enc.c and ssl/s3_pkt.c so that we don't
1830 reveal whether illegal block cipher padding was found or a MAC
1831 verification error occured. (Neither SSLerr() codes nor alerts
1832 are directly visible to potential attackers, but the information
1833 may leak via logfiles.)
1834
1835 Similar changes are not required for the SSL 2.0 implementation
1836 because the number of padding bytes is sent in clear for SSL 2.0,
1837 and the extra bytes are just ignored. However ssl/s2_pkt.c
1838 failed to verify that the purported number of padding bytes is in
1839 the legal range.
1840 [Bodo Moeller]
1841
1842 *) Add OpenUNIX-8 support including shared libraries
1843 (Boyd Lynn Gerber <gerberb@zenez.com>).
1844 [Lutz Jaenicke]
1845
1846 *) Improve RSA_padding_check_PKCS1_OAEP() check again to avoid
1847 'wristwatch attack' using huge encoding parameters (cf.
1848 James H. Manger's CRYPTO 2001 paper). Note that the
1849 RSA_PKCS1_OAEP_PADDING case of RSA_private_decrypt() does not use
1850 encoding parameters and hence was not vulnerable.
1851 [Bodo Moeller]
1852
1853 *) BN_sqr() bug fix.
1854 [Ulf Möller, reported by Jim Ellis <jim.ellis@cavium.com>]
1855
1856 *) Rabin-Miller test analyses assume uniformly distributed witnesses,
1857 so use BN_pseudo_rand_range() instead of using BN_pseudo_rand()
1858 followed by modular reduction.
1859 [Bodo Moeller; pointed out by Adam Young <AYoung1@NCSUS.JNJ.COM>]
1860
1861 *) Add BN_pseudo_rand_range() with obvious functionality: BN_rand_range()
1862 equivalent based on BN_pseudo_rand() instead of BN_rand().
1863 [Bodo Moeller]
1864
1865 *) s3_srvr.c: allow sending of large client certificate lists (> 16 kB).
1866 This function was broken, as the check for a new client hello message
1867 to handle SGC did not allow these large messages.
1868 (Tracked down by "Douglas E. Engert" <deengert@anl.gov>.)
1869 [Lutz Jaenicke]
1870
1871 *) Add alert descriptions for TLSv1 to SSL_alert_desc_string[_long]().
1872 [Lutz Jaenicke]
1873
1874 *) Fix buggy behaviour of BIO_get_num_renegotiates() and BIO_ctrl()
1875 for BIO_C_GET_WRITE_BUF_SIZE ("Stephen Hinton" <shinton@netopia.com>).
1876 [Lutz Jaenicke]
1877
1878 *) Rework the configuration and shared library support for Tru64 Unix.
1879 The configuration part makes use of modern compiler features and
1880 still retains old compiler behavior for those that run older versions
1881 of the OS. The shared library support part includes a variant that
1882 uses the RPATH feature, and is available through the special
1883 configuration target "alpha-cc-rpath", which will never be selected
1884 automatically.
1885 [Tim Mooney <mooney@dogbert.cc.ndsu.NoDak.edu> via Richard Levitte]
1886
1887 *) In ssl3_get_key_exchange (ssl/s3_clnt.c), call ssl3_get_message()
1888 with the same message size as in ssl3_get_certificate_request().
1889 Otherwise, if no ServerKeyExchange message occurs, CertificateRequest
1890 messages might inadvertently be reject as too long.
1891 [Petr Lampa <lampa@fee.vutbr.cz>]
1892
1893 *) Enhanced support for IA-64 Unix platforms (well, Linux and HP-UX).
1894 [Andy Polyakov]
1895
1896 *) Modified SSL library such that the verify_callback that has been set
1897 specificly for an SSL object with SSL_set_verify() is actually being
1898 used. Before the change, a verify_callback set with this function was
1899 ignored and the verify_callback() set in the SSL_CTX at the time of
1900 the call was used. New function X509_STORE_CTX_set_verify_cb() introduced
1901 to allow the necessary settings.
1902 [Lutz Jaenicke]
1903
1904 *) Initialize static variable in crypto/dsa/dsa_lib.c and crypto/dh/dh_lib.c
1905 explicitly to NULL, as at least on Solaris 8 this seems not always to be
1906 done automatically (in contradiction to the requirements of the C
1907 standard). This made problems when used from OpenSSH.
1908 [Lutz Jaenicke]
1909
1910 *) In OpenSSL 0.9.6a and 0.9.6b, crypto/dh/dh_key.c ignored
1911 dh->length and always used
1912
1913 BN_rand_range(priv_key, dh->p).
1914
1915 BN_rand_range() is not necessary for Diffie-Hellman, and this
1916 specific range makes Diffie-Hellman unnecessarily inefficient if
1917 dh->length (recommended exponent length) is much smaller than the
1918 length of dh->p. We could use BN_rand_range() if the order of
1919 the subgroup was stored in the DH structure, but we only have
1920 dh->length.
1921
1922 So switch back to
1923
1924 BN_rand(priv_key, l, ...)
1925
1926 where 'l' is dh->length if this is defined, or BN_num_bits(dh->p)-1
1927 otherwise.
1928 [Bodo Moeller]
1929
1930 *) In
1931
1932 RSA_eay_public_encrypt
1933 RSA_eay_private_decrypt
1934 RSA_eay_private_encrypt (signing)
1935 RSA_eay_public_decrypt (signature verification)
1936
1937 (default implementations for RSA_public_encrypt,
1938 RSA_private_decrypt, RSA_private_encrypt, RSA_public_decrypt),
1939 always reject numbers >= n.
1940 [Bodo Moeller]
1941
1942 *) In crypto/rand/md_rand.c, use a new short-time lock CRYPTO_LOCK_RAND2
1943 to synchronize access to 'locking_thread'. This is necessary on
1944 systems where access to 'locking_thread' (an 'unsigned long'
1945 variable) is not atomic.
1946 [Bodo Moeller]
1947
1948 *) In crypto/rand/md_rand.c, set 'locking_thread' to current thread's ID
1949 *before* setting the 'crypto_lock_rand' flag. The previous code had
1950 a race condition if 0 is a valid thread ID.
1951 [Travis Vitek <vitek@roguewave.com>]
1952
1953 *) Add support for shared libraries under Irix.
1954 [Albert Chin-A-Young <china@thewrittenword.com>]
1955
1956 *) Add configuration option to build on Linux on both big-endian and
1957 little-endian MIPS.
1958 [Ralf Baechle <ralf@uni-koblenz.de>]
1959
1960 *) Add the possibility to create shared libraries on HP-UX.
1961 [Richard Levitte]
1962
5 Changes between 0.9.6a and 0.9.6b [9 Jul 2001] 1963 Changes between 0.9.6a and 0.9.6b [9 Jul 2001]
6 1964
7 *) Change ssleay_rand_bytes (crypto/rand/md_rand.c) 1965 *) Change ssleay_rand_bytes (crypto/rand/md_rand.c)
@@ -56,7 +2014,7 @@
56 [Ulf Möller, Bodo Möller] 2014 [Ulf Möller, Bodo Möller]
57 2015
58 *) The countermeasure against Bleichbacher's attack on PKCS #1 v1.5 2016 *) The countermeasure against Bleichbacher's attack on PKCS #1 v1.5
59 RSA encryption was accidentily removed in s3_srvr.c in OpenSSL 0.9.5 2017 RSA encryption was accidentally removed in s3_srvr.c in OpenSSL 0.9.5
60 when fixing the server behaviour for backwards-compatible 'client 2018 when fixing the server behaviour for backwards-compatible 'client
61 hello' messages. (Note that the attack is impractical against 2019 hello' messages. (Note that the attack is impractical against
62 SSL 3.0 and TLS 1.0 anyway because length and version checking 2020 SSL 3.0 and TLS 1.0 anyway because length and version checking
@@ -106,7 +2064,7 @@
106 combination of a flag and a thread ID variable. 2064 combination of a flag and a thread ID variable.
107 Otherwise while one thread is in ssleay_rand_bytes (which sets the 2065 Otherwise while one thread is in ssleay_rand_bytes (which sets the
108 flag), *other* threads can enter ssleay_add_bytes without obeying 2066 flag), *other* threads can enter ssleay_add_bytes without obeying
109 the CRYPTO_LOCK_RAND lock (and may even illegaly release the lock 2067 the CRYPTO_LOCK_RAND lock (and may even illegally release the lock
110 that they do not hold after the first thread unsets add_do_not_lock). 2068 that they do not hold after the first thread unsets add_do_not_lock).
111 [Bodo Moeller] 2069 [Bodo Moeller]
112 2070
@@ -748,7 +2706,7 @@
748 default is static libraries only, and the OpenSSL programs 2706 default is static libraries only, and the OpenSSL programs
749 are always statically linked for now, but there are 2707 are always statically linked for now, but there are
750 preparations for dynamic linking in place. 2708 preparations for dynamic linking in place.
751 This has been tested on Linux and True64. 2709 This has been tested on Linux and Tru64.
752 [Richard Levitte] 2710 [Richard Levitte]
753 2711
754 *) Randomness polling function for Win9x, as described in: 2712 *) Randomness polling function for Win9x, as described in:
diff --git a/src/lib/libssl/src/Configure b/src/lib/libssl/src/Configure
index 49665153fa..1ffe1ac856 100644
--- a/src/lib/libssl/src/Configure
+++ b/src/lib/libssl/src/Configure
@@ -10,7 +10,7 @@ use strict;
10 10
11# see INSTALL for instructions. 11# see INSTALL for instructions.
12 12
13my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [rsaref] [no-threads] [no-asm] [no-dso] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] os/compiler[:flags]\n"; 13my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]\n";
14 14
15# Options: 15# Options:
16# 16#
@@ -23,23 +23,37 @@ my $usage="Usage: Configure [no-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-
23# default). This needn't be set in advance, you can 23# default). This needn't be set in advance, you can
24# just as well use "make INSTALL_PREFIX=/whatever install". 24# just as well use "make INSTALL_PREFIX=/whatever install".
25# 25#
26# --with-krb5-dir Declare where Kerberos 5 lives. The libraries are expected
27# to live in the subdirectory lib/ and the header files in
28# include/. A value is required.
29# --with-krb5-lib Declare where the Kerberos 5 libraries live. A value is
30# required.
31# (Default: KRB5_DIR/lib)
32# --with-krb5-include Declare where the Kerberos 5 header files live. A
33# value is required.
34# (Default: KRB5_DIR/include)
35# --with-krb5-flavor Declare what flavor of Kerberos 5 is used. Currently
36# supported values are "MIT" and "Heimdal". A value is required.
37#
38# --test-sanity Make a number of sanity checks on the data in this file.
39# This is a debugging tool for OpenSSL developers.
40#
26# no-hw-xxx do not compile support for specific crypto hardware. 41# no-hw-xxx do not compile support for specific crypto hardware.
27# Generic OpenSSL-style methods relating to this support 42# Generic OpenSSL-style methods relating to this support
28# are always compiled but return NULL if the hardware 43# are always compiled but return NULL if the hardware
29# support isn't compiled. 44# support isn't compiled.
30# no-hw do not compile support for any crypto hardware. 45# no-hw do not compile support for any crypto hardware.
31# rsaref use RSAref
32# [no-]threads [don't] try to create a library that is suitable for 46# [no-]threads [don't] try to create a library that is suitable for
33# multithreaded applications (default is "threads" if we 47# multithreaded applications (default is "threads" if we
34# know how to do it) 48# know how to do it)
35# [no-]shared [don't] try to create shared libraries when supported. 49# [no-]shared [don't] try to create shared libraries when supported.
36# IT IS NOT RECOMMENDED TO USE "shared"! Since this is a
37# development branch, the positions of the ENGINE symbols
38# in the transfer vector are constantly moving, so binary
39# backward compatibility can't be guaranteed in any way.
40# no-asm do not use assembler 50# no-asm do not use assembler
41# no-dso do not compile in any native shared-library methods. This 51# no-dso do not compile in any native shared-library methods. This
42# will ensure that all methods just return NULL. 52# will ensure that all methods just return NULL.
53# no-krb5 do not compile in any KRB5 library or code.
54# [no-]zlib [don't] compile support for zlib compression.
55# zlib-dynamic Like "zlib", but the zlib library is expected to be a shared
56# library and will be loaded in run-time by the OpenSSL library.
43# 386 generate 80386 code 57# 386 generate 80386 code
44# no-<cipher> build without specified algorithm (rsa, idea, rc5, ...) 58# no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
45# -<xxx> +<xxx> compiler options are passed through 59# -<xxx> +<xxx> compiler options are passed through
@@ -106,7 +120,7 @@ my $alpha_asm="::::::::";
106# -DB_ENDIAN slows things down on a sparc for md5, but helps sha1. 120# -DB_ENDIAN slows things down on a sparc for md5, but helps sha1.
107# So the md5_locl.h file has an undef B_ENDIAN if sun is defined 121# So the md5_locl.h file has an undef B_ENDIAN if sun is defined
108 122
109#config-string $cc : $cflags : $unistd : $thread_cflag : $lflags : $bn_ops : $bn_obj : $des_obj : $bf_obj : $md5_obj : $sha1_obj : $cast_obj : $rc4_obj : $rmd160_obj : $rc5_obj : $dso_scheme : $shared_target : $shared_cflag 123#config-string $cc : $cflags : $unistd : $thread_cflag : $sys_id : $lflags : $bn_ops : $bn_obj : $des_obj : $bf_obj : $md5_obj : $sha1_obj : $cast_obj : $rc4_obj : $rmd160_obj : $rc5_obj : $dso_scheme : $shared_target : $shared_cflag : $shared_ldflag : $shared_extension : $ranlib
110 124
111my %table=( 125my %table=(
112# File 'TABLE' (created by 'make TABLE') contains the data from this list, 126# File 'TABLE' (created by 'make TABLE') contains the data from this list,
@@ -119,87 +133,93 @@ my %table=(
119#"b2-is-ri-dp", "${tcc}:${tflags}::${tlib}:${bits2}IDEA_SHORT RC4_INDEX DES_PTR:${tbn_mul}::", 133#"b2-is-ri-dp", "${tcc}:${tflags}::${tlib}:${bits2}IDEA_SHORT RC4_INDEX DES_PTR:${tbn_mul}::",
120 134
121# Our development configs 135# Our development configs
122"purify", "purify gcc:-g -DPURIFY -Wall::(unknown):-lsocket -lnsl::::", 136"purify", "purify gcc:-g -DPURIFY -Wall::(unknown)::-lsocket -lnsl::::",
123"debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown):-lefence::::", 137"debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror::(unknown)::-lefence::::",
124"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::", 138"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::asm/bn86-elf.o asm/co86-elf.o",
125"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::", 139"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
126"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown):::::", 140"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
127"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 141"debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::::",
128"debug-bodo", "gcc:-DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DBIO_PAIR_DEBUG -g -m486 -pedantic -Wshadow -Wall::-D_REENTRANT::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 142"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
129"debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 143"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
130"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -O2 -m486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 144"debug-bodo", "gcc:-DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DBIO_PAIR_DEBUG -DPEDANTIC -g -m486 -pedantic -Wshadow -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
131"debug-levitte-linux-elf","gcc:-DUSE_ALLOCATING_PRINT -DRL_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DNO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -ggdb -g3 -m486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -pipe::-D_REENTRANT:-ldl:::::::::::dlfcn", 145"debug-ulf", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT:::${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
132"dist", "cc:-O::(unknown):::::", 146"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
147"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
148"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -Wno-long-long -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
149"dist", "cc:-O::(unknown)::::::",
133 150
134# Basic configs that should work on any (32 and less bit) box 151# Basic configs that should work on any (32 and less bit) box
135"gcc", "gcc:-O3::(unknown)::BN_LLONG:::", 152"gcc", "gcc:-O3::(unknown):::BN_LLONG:::",
136"cc", "cc:-O::(unknown):::::", 153"cc", "cc:-O::(unknown)::::::",
137 154
138#### Solaris x86 setups 155#### Solaris x86 with GNU C setups
139# -DNO_INLINE_ASM switches off inline assembler. We have to do it 156# -DOPENSSL_NO_INLINE_ASM switches off inline assembler. We have to do it
140# here because whenever GNU C instantiates an assembler template it 157# here because whenever GNU C instantiates an assembler template it
141# surrounds it with #APP #NO_APP comment pair which (at least Solaris 158# surrounds it with #APP #NO_APP comment pair which (at least Solaris
142# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic" 159# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic"
143# error message. 160# error message.
144"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DNO_INLINE_ASM::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_sol_asm}:dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 161"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_sol_asm}:dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
145 162
146#### Solaris x86 with Sun C setups 163#### Solaris x86 with Sun C setups
147"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 164"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
148 165
149#### SPARC Solaris with GNU C setups 166#### SPARC Solaris with GNU C setups
150"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 167"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
151"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 168"solaris-sparcv8-gcc","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
152"solaris-sparcv9-gcc","gcc:-mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 169# -m32 should be safe to add as long as driver recognizes -mcpu=ultrasparc
170"solaris-sparcv9-gcc","gcc:-m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
153# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8 171# gcc pre-2.8 doesn't understand -mcpu=ultrasparc, so fall down to -mv8
154# but keep the assembler modules. 172# but keep the assembler modules.
155"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 173"solaris-sparcv9-gcc27","gcc:-mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus-gcc27.o:::asm/md5-sparcv8plus-gcc27.o::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
174"solaris64-sparcv9-gcc","gcc:-m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
175
156#### 176####
157"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 177"debug-solaris-sparcv8-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
158"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::::::::dlfcn:gnu-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 178"debug-solaris-sparcv9-gcc","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::::::::dlfcn:solaris-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
159 179
160#### SPARC Solaris with Sun C setups 180#### SPARC Solaris with Sun C setups
161# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests 181# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests
162"solaris-sparc-sc3","cc:-fast -O -Xa -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 182"solaris-sparc-sc3","cc:-fast -O -Xa -DB_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
163# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2. 183# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2.
164# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8 184# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
165# SC5.0 note: Compiler common patch 107357-01 or later is required! 185# SC5.0 note: Compiler common patch 107357-01 or later is required!
166"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 186"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
167"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 187"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
168"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 188"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
169"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs", 189"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::asm/md5-sparcv9.o::::::dlfcn:solaris-shared:-KPIC:-xarch=v9:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs",
170#### 190####
171"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 191"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8.o:::::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
172"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 192"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:solaris-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
173 193
174#### SPARC Linux setups 194#### SPARC Linux setups
175"linux-sparcv7","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::", 195"linux-sparcv7","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::",
176# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently 196# Ray Miller <ray.miller@computing-services.oxford.ac.uk> has patiently
177# assisted with debugging of following two configs. 197# assisted with debugging of following two configs.
178"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o::::", 198"linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT:::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o::::",
179# it's a real mess with -mcpu=ultrasparc option under Linux, but 199# it's a real mess with -mcpu=ultrasparc option under Linux, but
180# -Wa,-Av8plus should do the trick no matter what. 200# -Wa,-Av8plus should do the trick no matter what.
181"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o:", 201"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W::-D_REENTRANT:ULTRASPARC::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
182# !!!Folowing can't be even tested yet!!! 202# !!!Folowing can't be even tested yet!!!
183# We have to wait till 64-bit glibc for SPARC is operational!!! 203# We have to wait till 64-bit glibc for SPARC is operational!!!
184#"linux64-sparcv9","sparc64-linux-gcc:-m64 -mcpu=v9 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:", 204#"linux64-sparcv9","sparc64-linux-gcc:-m64 -mcpu=v9 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT:ULTRASPARC::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:",
185 205
186# Sunos configs, assuming sparc for the gcc one. 206# Sunos configs, assuming sparc for the gcc one.
187##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown)::DES_UNROLL:::", 207##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::(unknown):::DES_UNROLL:::",
188"sunos-gcc","gcc:-O3 -mv8 -Dssize_t=int::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:::", 208"sunos-gcc","gcc:-O3 -mv8 -Dssize_t=int::(unknown):::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1:::",
189 209
190#### IRIX 5.x configs 210#### IRIX 5.x configs
191# -mips2 flag is added by ./config when appropriate. 211# -mips2 flag is added by ./config when appropriate.
192"irix-gcc","gcc:-O3 -DTERMIOS -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK DES_UNROLL DES_RISC2 DES_PTR BF_PTR:::", 212"irix-gcc","gcc:-O3 -DTERMIOS -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK DES_UNROLL DES_RISC2 DES_PTR BF_PTR::::::::::dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
193"irix-cc", "cc:-O2 -use_readonly_const -DTERMIOS -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC2 DES_UNROLL BF_PTR:::", 213"irix-cc", "cc:-O2 -use_readonly_const -DTERMIOS -DB_ENDIAN::(unknown):::BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC2 DES_UNROLL BF_PTR::::::::::dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
194#### IRIX 6.x configs 214#### IRIX 6.x configs
195# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke 215# Only N32 and N64 ABIs are supported. If you need O32 ABI build, invoke
196# './Configure irix-[g]cc' manually. 216# './Configure irix-[g]cc' manually.
197# -mips4 flag is added by ./config when appropriate. 217# -mips4 flag is added by ./config when appropriate.
198"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}", 218"irix-mips3-gcc","gcc:-mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
199"irix-mips3-cc", "cc:-n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}", 219"irix-mips3-cc", "cc:-n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
200# N64 ABI builds. 220# N64 ABI builds.
201"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}", 221"irix64-mips4-gcc","gcc:-mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
202"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}", 222"irix64-mips4-cc", "cc:-64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W::-D_SGI_MP_SOURCE:::RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG:${mips3_irix_asm}:dlfcn:irix-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
203 223
204#### Unified HP-UX ANSI C configs. 224#### Unified HP-UX ANSI C configs.
205# Special notes: 225# Special notes:
@@ -217,7 +237,7 @@ my %table=(
217# - Keep in mind that the HP compiler by default generates code 237# - Keep in mind that the HP compiler by default generates code
218# suitable for execution on the host you're currently compiling at. 238# suitable for execution on the host you're currently compiling at.
219# If the toolkit is ment to be used on various PA-RISC processors 239# If the toolkit is ment to be used on various PA-RISC processors
220# consider './config +Dportable'. 240# consider './config +DAportable'.
221# - +DD64 is chosen in favour of +DA2.0W because it's ment to be 241# - +DD64 is chosen in favour of +DA2.0W because it's ment to be
222# compatible with *future* releases. 242# compatible with *future* releases.
223# - If you run ./Configure hpux-parisc-[g]cc manually don't forget to 243# - If you run ./Configure hpux-parisc-[g]cc manually don't forget to
@@ -229,60 +249,102 @@ my %table=(
229# crypto/sha/sha_lcl.h. 249# crypto/sha/sha_lcl.h.
230# <appro@fy.chalmers.se> 250# <appro@fy.chalmers.se>
231# 251#
232#!#"hpux-parisc-cc","cc:-Ae +O3 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY:::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 252#!#"hpux-parisc-cc","cc:-Ae +O3 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl",
233# Since there is mention of this in shlib/hpux10-cc.sh 253# Since there is mention of this in shlib/hpux10-cc.sh
234"hpux-parisc-cc-o4","cc:-Ae +O4 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY:::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 254"hpux-parisc-cc-o4","cc:-Ae +O4 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
235"hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W:::-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 255"hpux-parisc-gcc","gcc:-O3 -DB_ENDIAN -DBN_DIV2W::::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:-fPIC::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
236"hpux64-parisc-cc","cc:-Ae +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT:-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dlfcn", 256"hpux64-parisc-cc","cc:-Ae +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
257
258# IA-64 targets
259# I have no idea if this one actually works, feedback needed. <appro>
260"hpux-ia64-cc","cc:-Ae +DD32 +O3 +ESlit -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
261# Frank Geurts <frank.geurts@nl.abnamro.com> has patiently assisted with
262# with debugging of the following config.
263"hpux64-ia64-cc","cc:-Ae +DD64 +O3 +ESlit -z -DB_ENDIAN::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/ia64-cpp.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
237 264
238# More attempts at unified 10.X and 11.X targets for HP C compiler. 265# More attempts at unified 10.X and 11.X targets for HP C compiler.
239# 266#
240# Chris Ruemmler <ruemmler@cup.hp.com> 267# Chris Ruemmler <ruemmler@cup.hp.com>
241# Kevin Steves <ks@hp.se> 268# Kevin Steves <ks@hp.se>
242"hpux-parisc-cc","cc:+O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT:-ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl", 269"hpux-parisc-cc","cc:+O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
243"hpux-parisc2-cc","cc:+DA2.0 +DS2.0 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT:-ldld:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2.o:::::::::dl", 270"hpux-parisc2-cc","cc:+DA2.0 +DS2.0 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2.o:::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
244"hpux64-parisc2-cc","cc:+DD64 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT:-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2W.o:::::::::dlfcn", 271"hpux64-parisc2-cc","cc:+DD64 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT:asm/pa-risc2W.o:::::::::dlfcn:hpux64-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
245"hpux-parisc1_1-cc","cc:+DA1.1 +DS1.1 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT:-ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl", 272# Isn't the line below meaningless? HP-UX cc optimizes for host by default.
273# hpux-parisc1_0-cc with +DAportable flag would make more sense. <appro>
274"hpux-parisc1_1-cc","cc:+DA1.1 +DS1.1 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY::-D_REENTRANT::-Wl,+s -ldld:MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
246 275
247# HPUX 9.X config. 276# HPUX 9.X config.
248# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or 277# Don't use the bundled cc. It is broken. Use HP ANSI C if possible, or
249# egcs. gcc 2.8.1 is also broken. 278# egcs. gcc 2.8.1 is also broken.
250 279
251"hpux-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::(unknown):-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 280"hpux-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::(unknown)::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
252# If hpux-cc fails (e.g. during "make test"), try the next one; otherwise, 281# If hpux-cc fails (e.g. during "make test"), try the next one; otherwise,
253# please report your OS and compiler version to the openssl-bugs@openssl.org 282# please report your OS and compiler version to the openssl-bugs@openssl.org
254# mailing list. 283# mailing list.
255"hpux-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::(unknown):-ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 284"hpux-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::(unknown)::-Wl,+s -ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
256 285
257"hpux-gcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown):-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 286"hpux-gcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown)::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:-fPIC::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
258# If hpux-gcc fails, try this one: 287# If hpux-gcc fails, try this one:
259"hpux-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown):-ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 288"hpux-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown)::-Wl,+s -ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:-fPIC::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
289
290# HPUX 9.X on Motorola 68k platforms with gcc
291"hpux-m68k-gcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::(unknown):::BN_LLONG DES_PTR DES_UNROLL:::::::::::::",
260 292
261# HPUX 10.X config. Supports threads. 293# HPUX 10.X config. Supports threads.
262"hpux10-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::-D_REENTRANT:-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 294"hpux10-cc", "cc:-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
263# If hpux10-cc fails, try this one (if still fails, try deleting BN_LLONG): 295# If hpux10-cc fails, try this one (if still fails, try deleting BN_LLONG):
264"hpux10-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::-D_REENTRANT:-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 296"hpux10-brokencc", "cc:-DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:+Z::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
265 297
266"hpux10-gcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::-D_REENTRANT:-ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 298"hpux10-gcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::-D_REENTRANT::-Wl,+s -ldld:BN_LLONG DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:-fPIC::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
267# If hpux10-gcc fails, try this one: 299# If hpux10-gcc fails, try this one:
268"hpux10-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::-D_REENTRANT:-ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl", 300"hpux10-brokengcc", "gcc:-DB_ENDIAN -DBN_DIV2W -O3::-D_REENTRANT::-Wl,+s -ldld:DES_PTR DES_UNROLL DES_RISC1::::::::::dl:hpux-shared:-fPIC::.sl.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
269 301
270# HPUX 11.X from www.globus.org. 302# HPUX 11.X from www.globus.org.
271# Only works on PA-RISC 2.0 cpus, and not optimized. Why? 303# Only works on PA-RISC 2.0 cpus, and not optimized. Why?
272#"hpux11-32bit-cc","cc:+DA2.0 -DB_ENDIAN -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT::DES_PTR DES_UNROLL DES_RISC1:::", 304#"hpux11-32bit-cc","cc:+DA2.0 -DB_ENDIAN -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT:::DES_PTR DES_UNROLL DES_RISC1:::",
273#"hpux11-64bit-cc","cc:+DA2.0W -g -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT::SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT :::", 305#"hpux11-64bit-cc","cc:+DA2.0W -g -D_HPUX_SOURCE -Aa -Ae +ESlit::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT :::",
274# Use unified settings above instead. 306# Use unified settings above instead.
275 307
276#### HP MPE/iX http://jazz.external.hp.com/src/openssl/ 308#### HP MPE/iX http://jazz.external.hp.com/src/openssl/
277"MPE/iX-gcc", "gcc:-D_ENDIAN -DBN_DIV2W -O3 -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB::(unknown):-L/SYSLOG/PUB -lsyslog -lsocket -lcurses:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::", 309"MPE/iX-gcc", "gcc:-D_ENDIAN -DBN_DIV2W -O3 -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB::(unknown):MPE:-L/SYSLOG/PUB -lsyslog -lsocket -lcurses:BN_LLONG DES_PTR DES_UNROLL DES_RISC1:::",
310
311#### PARISC Linux setups
312"linux-parisc","gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT:::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::",
278 313
279# Dec Alpha, OSF/1 - the alpha164-cc is the flags for a 21164A with 314# Dec Alpha, OSF/1 - the alpha164-cc is historical, for the conversion
280# the new compiler 315# from the older DEC C Compiler to the newer compiler. It's now the
316# same as the preferred entry, alpha-cc. If you are still using the
317# older compiler (you're at 3.x or earlier, or perhaps very early 4.x)
318# you should use `alphaold-cc'.
319#
320# "What's in a name? That which we call a rose
321# By any other word would smell as sweet."
322#
323# - William Shakespeare, "Romeo & Juliet", Act II, scene II.
324#
325# For OSF/1 3.2b and earlier, and Digital UNIX 3.2c - 3.2g, with the
326# vendor compiler, use alphaold-cc.
327# For Digital UNIX 4.0 - 4.0e, with the vendor compiler, use alpha-cc.
328# For Tru64 UNIX 4.f - current, with the vendor compiler, use alpha-cc.
329#
330# There's also an alternate target available (which `config' will never
331# select) called alpha-cc-rpath. This target builds an RPATH into the
332# shared libraries, which is very convenient on Tru64 since binaries
333# linked against that shared library will automatically inherit that RPATH,
334# and hence know where to look for the openssl libraries, even if they're in
335# an odd place.
336#
281# For gcc, the following gave a %50 speedup on a 164 over the 'DES_INT' version 337# For gcc, the following gave a %50 speedup on a 164 over the 'DES_INT' version
282"alpha-gcc","gcc:-O3::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_RISC1:${alpha_asm}:dlfcn:tru64-shared::.so", 338#
283"alpha-cc", "cc:-std1 -tune host -O4 -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:tru64-shared::.so", 339"alpha-gcc","gcc:-O3::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_RISC1:${alpha_asm}:dlfcn:alpha-osf1-shared:::.so",
284"alpha164-cc", "cc:-std1 -tune host -fast -readonly_strings::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:tru64-shared::.so", 340"alphaold-cc", "cc:-std1 -tune host -O4 -readonly_strings::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:alpha-osf1-shared:::.so",
285"FreeBSD-alpha","gcc:-DTERMIOS -O -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 341"alpha164-cc", "cc:-std1 -tune host -fast -readonly_strings::-pthread:::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:tru64-shared:::.so",
342"alpha-cc", "cc:-std1 -tune host -fast -readonly_strings::-pthread:::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:tru64-shared:::.so",
343"alpha-cc-rpath", "cc:-std1 -tune host -fast -readonly_strings::-pthread:::SIXTY_FOUR_BIT_LONG RC4_CHUNK:${alpha_asm}:dlfcn:tru64-shared-rpath:::.so",
344#
345# This probably belongs in a different section.
346#
347"FreeBSD-alpha","gcc:-DTERMIOS -O -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
286 348
287#### Alpha Linux with GNU C and Compaq C setups 349#### Alpha Linux with GNU C and Compaq C setups
288# Special notes: 350# Special notes:
@@ -297,65 +359,80 @@ my %table=(
297# 359#
298# <appro@fy.chalmers.se> 360# <appro@fy.chalmers.se>
299# 361#
300"linux-alpha-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::-D_REENTRANT:-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 362"linux-alpha-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
301"linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::-D_REENTRANT:-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 363"linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${alpha_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
302"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", 364"linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
303"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", 365"linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
304
305# assembler versions -- currently defunct:
306##"OpenBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2:${alpha_asm}",
307 366
308# The intel boxes :-), It would be worth seeing if bsdi-gcc can use the 367# The intel boxes :-), It would be worth seeing if bsdi-gcc can use the
309# bn86-elf.o file file since it is hand tweaked assembler. 368# bn86-elf.o file file since it is hand tweaked assembler.
310"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT:-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 369"linux-elf", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
311"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", 370"linux-pentium", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
312"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn", 371"linux-ppro", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
313"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", 372"linux-k6", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=k6 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
314"linux-mips", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::BN_LLONG:::", 373"debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
315"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG::", 374"debug-linux-ppro","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentiumpro -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
316"linux-m68k", "gcc:-DB_ENDIAN -DTERMIO -O2 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG::", 375"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
317"linux-s390", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG::", 376"debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
318"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::SIXTY_FOUR_BIT_LONG::", 377"linux-aout", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
319"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 378"linux-mipsel", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown):::BN_LLONG:::",
320"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown)::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 379"linux-mips", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown):::BN_LLONG:::",
321"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 380"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
322"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 381"linux-m68k", "gcc:-DB_ENDIAN -DTERMIO -O2 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::",
323"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}", 382"linux-s390", "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::",
324"bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown)::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}", 383"linux-s390x", "gcc:-DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG:::::::::::linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
325"bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 384"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR:asm/ia64.o:::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
326"nextstep", "cc:-O -Wall:<libc.h>:(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", 385"NetBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
327"nextstep3.3", "cc:-O3 -Wall:<libc.h>:(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", 386"NetBSD-m68", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
387"NetBSD-x86", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
388"FreeBSD-elf", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::-pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
389"FreeBSD", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
390"bsdi-gcc", "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::(unknown):::RSA_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_bsdi_asm}",
391"bsdi-elf-gcc", "gcc:-DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown)::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
392"nextstep", "cc:-O -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
393"nextstep3.3", "cc:-O3 -Wall:<libc.h>:(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::",
394
328# NCR MP-RAS UNIX ver 02.03.01 395# NCR MP-RAS UNIX ver 02.03.01
329"ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw::(unknown):-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:::", 396"ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw::(unknown)::-lsocket -lnsl:${x86_gcc_des} ${x86_gcc_opts}:::",
330 397
331# QNX 4 398# QNX 4
332"qnx4", "cc:-DL_ENDIAN -DTERMIO::(unknown)::${x86_gcc_des} ${x86_gcc_opts}:", 399"qnx4", "cc:-DL_ENDIAN -DTERMIO::(unknown):::${x86_gcc_des} ${x86_gcc_opts}:",
400
401# QNX 6
402"qnx6", "cc:-DL_ENDIAN -DTERMIOS::(unknown)::-lsocket:${x86_gcc_des} ${x86_gcc_opts}:",
333 403
334# Linux on ARM 404# Linux on ARM
335"linux-elf-arm","gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::BN_LLONG::::::::::dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 405"linux-elf-arm","gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT:::BN_LLONG::::::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
336 406
337# UnixWare 2.0x fails destest with -O 407# UnixWare 2.0x fails destest with -O
338"unixware-2.0","cc:-DFILIO_H::-Kthread:-lsocket -lnsl -lx:${x86_gcc_des} ${x86_gcc_opts}:::", 408"unixware-2.0","cc:-DFILIO_H::-Kthread::-lsocket -lnsl -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
339"unixware-2.0-pentium","cc:-DFILIO_H -Kpentium::-Kthread:-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 409"unixware-2.0-pentium","cc:-DFILIO_H -Kpentium::-Kthread::-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
340 410
341# UnixWare 2.1 411# UnixWare 2.1
342"unixware-2.1","cc:-O -DFILIO_H::-Kthread:-lsocket -lnsl -lx:${x86_gcc_des} ${x86_gcc_opts}:::", 412"unixware-2.1","cc:-O -DFILIO_H::-Kthread::-lsocket -lnsl -lx:${x86_gcc_des} ${x86_gcc_opts}:::",
343"unixware-2.1-pentium","cc:-O -DFILIO_H -Kpentium::-Kthread:-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 413"unixware-2.1-pentium","cc:-O -DFILIO_H -Kpentium::-Kthread::-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
344"unixware-2.1-p6","cc:-O -DFILIO_H -Kp6::-Kthread:-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 414"unixware-2.1-p6","cc:-O -DFILIO_H -Kp6::-Kthread::-lsocket -lnsl -lx:MD2_CHAR RC4_INDEX ${x86_gcc_des}::",
345 415
346# UnixWare 7 416# UnixWare 7
347"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread:-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 417"unixware-7","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
348"unixware-7-pentium","cc:-O -DFILIO_H -Kalloca -Kpentium::-Kthread:-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 418"unixware-7-pentium","cc:-O -DFILIO_H -Kalloca -Kpentium::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
349"unixware-7-pentium_pro","cc:-O -DFILIO_H -Kalloca -Kpentium_pro::-Kthread:-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::", 419"unixware-7-pentium_pro","cc:-O -DFILIO_H -Kalloca -Kpentium_pro::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
420"unixware-7-gcc","gcc:-DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-lsocket -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:gnu-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
421
422# OpenUNIX 8
423"OpenUNIX-8","cc:-O -DFILIO_H -Kalloca::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
424"OpenUNIX-8-gcc","gcc:-O -DFILIO_H -fomit-frame-pointer::-pthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
425"OpenUNIX-8-pentium","cc:-O -DFILIO_H -Kalloca -Kpentium::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
426"OpenUNIX-8-pentium_pro","cc:-O -DFILIO_H -Kalloca -Kpentium_pro::-Kthread::-lsocket -lnsl:BN_LLONG MD2_CHAR RC4_INDEX ${x86_gcc_des}::::::::::dlfcn:svr5-shared:-Kpic::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
350 427
351# IBM's AIX. 428# IBM's AIX.
352"aix-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384::(unknown)::BN_LLONG RC4_CHAR:::", 429"aix-cc", "cc:-O -DB_ENDIAN -qmaxmem=16384::(unknown):AIX::BN_LLONG RC4_CHAR:::",
353"aix-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR:::", 430"aix-gcc", "gcc:-O3 -DB_ENDIAN::(unknown):AIX::BN_LLONG RC4_CHAR:::",
354"aix43-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384::(unknown)::BN_LLONG RC4_CHAR::::::::::dlfcn:", 431"aix43-cc", "cc:-O -DAIX -DB_ENDIAN -qmaxmem=16384::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:",
355"aix43-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR::::::::::dlfcn:", 432"aix43-gcc", "gcc:-O3 -DAIX -DB_ENDIAN::(unknown):::BN_LLONG RC4_CHAR::::::::::dlfcn:",
356 433
357# 434#
358# Cray T90 (SDSC) 435# Cray T90 and similar (SDSC)
359# It's Big-endian, but the algorithms work properly when B_ENDIAN is NOT 436# It's Big-endian, but the algorithms work properly when B_ENDIAN is NOT
360# defined. The T90 ints and longs are 8 bytes long, and apparently the 437# defined. The T90 ints and longs are 8 bytes long, and apparently the
361# B_ENDIAN code assumes 4 byte ints. Fortunately, the non-B_ENDIAN and 438# B_ENDIAN code assumes 4 byte ints. Fortunately, the non-B_ENDIAN and
@@ -365,7 +442,10 @@ my %table=(
365#'Taking the address of a bit field is not allowed. ' 442#'Taking the address of a bit field is not allowed. '
366#'An expression with bit field exists as the operand of "sizeof" ' 443#'An expression with bit field exists as the operand of "sizeof" '
367# (written by Wayne Schroeder <schroede@SDSC.EDU>) 444# (written by Wayne Schroeder <schroede@SDSC.EDU>)
368"cray-t90-cc", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown)::SIXTY_FOUR_BIT_LONG DES_INT:::", 445#
446# j90 is considered the base machine type for unicos machines,
447# so this configuration is now called "cray-j90" ...
448"cray-j90", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown):CRAY::SIXTY_FOUR_BIT_LONG DES_INT:::",
369 449
370# 450#
371# Cray T3E (Research Center Juelich, beckman@acl.lanl.gov) 451# Cray T3E (Research Center Juelich, beckman@acl.lanl.gov)
@@ -375,80 +455,123 @@ my %table=(
375# for some st_addr stuff, and then sizeof and address-of fails 455# for some st_addr stuff, and then sizeof and address-of fails
376# I could not use the ams/alpha.o option because the Cray assembler, 'cam' 456# I could not use the ams/alpha.o option because the Cray assembler, 'cam'
377# did not like it. 457# did not like it.
378"cray-t3e", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:::", 458"cray-t3e", "cc: -DBIT_FIELD_LIMITS -DTERMIOS::(unknown):CRAY::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:::",
379 459
380# DGUX, 88100. 460# DGUX, 88100.
381"dgux-R3-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::RC4_INDEX DES_UNROLL:::", 461"dgux-R3-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown):::RC4_INDEX DES_UNROLL:::",
382"dgux-R4-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown):-lnsl -lsocket:RC4_INDEX DES_UNROLL:::", 462"dgux-R4-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lnsl -lsocket:RC4_INDEX DES_UNROLL:::",
383"dgux-R4-x86-gcc", "gcc:-O3 -fomit-frame-pointer -DL_ENDIAN::(unknown):-lnsl -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}", 463"dgux-R4-x86-gcc", "gcc:-O3 -fomit-frame-pointer -DL_ENDIAN::(unknown)::-lnsl -lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
384 464
385# SCO 3 - Tim Rice <tim@multitalents.net> 465# SCO 3 - Tim Rice <tim@multitalents.net>
386"sco3-gcc", "gcc:-O3 -fomit-frame-pointer -Dssize_t=int -DNO_SYS_UN_H::(unknown):-lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", # the SCO assembler doesn't seem to like our assembler files ... 466"sco3-gcc", "gcc:-O3 -fomit-frame-pointer -Dssize_t=int -DNO_SYS_UN_H::(unknown)::-lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", # the SCO assembler doesn't seem to like our assembler files ...
387 467
388# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the 468# SCO 5 - Ben Laurie <ben@algroup.co.uk> says the -O breaks the
389# SCO cc. 469# SCO cc.
390"sco5-cc", "cc:::(unknown):-lsocket:${x86_gcc_des} ${x86_gcc_opts}:::", # des options? 470"sco5-cc", "cc:-belf::(unknown)::-lsocket -lresolv -lnsl:${x86_gcc_des} ${x86_gcc_opts}::::::::::dlfcn:svr3-shared:-Kpic", # des options?
391"sco5-cc-pentium", "cc:-Kpentium::(unknown):-lsocket:${x86_gcc_des} ${x86_gcc_opts}:::", # des options? 471"sco5-cc-pentium", "cc:-Kpentium::(unknown)::-lsocket:${x86_gcc_des} ${x86_gcc_opts}:::", # des options?
392"sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown):-lsocket:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:::", # the SCO assembler doesn't seem to like our assembler files ... 472"sco5-gcc", "gcc:-O3 -fomit-frame-pointer::(unknown)::-lsocket -lresolv -lnsl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:svr3-shared:-fPIC", # the SCO assembler doesn't seem to like our assembler files ...
393 473
394# Sinix/ReliantUNIX RM400 474# Sinix/ReliantUNIX RM400
395# NOTE: The CDS++ Compiler up to V2.0Bsomething has the IRIX_CC_BUG optimizer problem. Better use -g */ 475# NOTE: The CDS++ Compiler up to V2.0Bsomething has the IRIX_CC_BUG optimizer problem. Better use -g */
396"ReliantUNIX","cc:-KPIC -g -DSNI -DTERMIOS -DB_ENDIAN::-Kthread:-lsocket -lnsl -lc -L/usr/ucblib -lucb:BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR:::", 476"ReliantUNIX","cc:-KPIC -g -DTERMIOS -DB_ENDIAN::-Kthread:SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR::::::::::dlfcn:reliantunix-shared::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
397"SINIX","cc:-O -DSNI::(unknown):-lsocket -lnsl -lc -L/usr/ucblib -lucb:RC4_INDEX RC4_CHAR:::", 477"SINIX","cc:-O::(unknown):SNI:-lsocket -lnsl -lc -L/usr/ucblib -lucb:RC4_INDEX RC4_CHAR:::",
398"SINIX-N","/usr/ucb/cc:-O2 -misaligned::(unknown):-lucb:RC4_INDEX RC4_CHAR:::", 478"SINIX-N","/usr/ucb/cc:-O2 -misaligned::(unknown)::-lucb:RC4_INDEX RC4_CHAR:::",
399 479
400# SIEMENS BS2000/OSD: an EBCDIC-based mainframe 480# SIEMENS BS2000/OSD: an EBCDIC-based mainframe
401"BS2000-OSD","c89:-O -XLLML -XLLMK -XL -DB_ENDIAN -DTERMIOS -DCHARSET_EBCDIC::(unknown):-lsocket -lnsl:THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::", 481"BS2000-OSD","c89:-O -XLLML -XLLMK -XL -DB_ENDIAN -DTERMIOS -DCHARSET_EBCDIC::(unknown)::-lsocket -lnsl:THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
482
483# OS/390 Unix an EBCDIC-based Unix system on IBM mainframe
484# You need to compile using the c89.sh wrapper in the tools directory, because the
485# IBM compiler does not like the -L switch after any object modules.
486#
487"OS390-Unix","c89.sh:-O -DB_ENDIAN -DCHARSET_EBCDIC -DNO_SYS_PARAM_H -D_ALL_SOURCE::(unknown):::THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
402 488
403# Windows NT, Microsoft Visual C++ 4.0 489# Windows NT, Microsoft Visual C++ 4.0
404 490
405"VC-NT","cl:::::BN_LLONG RC4_INDEX ${x86_gcc_opts}::::::::::win32", 491"VC-NT","cl::::WINNT::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32",
406"VC-WIN32","cl:::::BN_LLONG RC4_INDEX ${x86_gcc_opts}::::::::::win32", 492"VC-WIN32","cl::::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}::::::::::win32",
407"VC-WIN16","cl:::(unknown)::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::", 493"VC-WIN16","cl:::(unknown):WIN16::MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::",
408"VC-W31-16","cl:::(unknown)::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", 494"VC-W31-16","cl:::(unknown):WIN16::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::",
409"VC-W31-32","cl:::::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::", 495"VC-W31-32","cl::::WIN16::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT:::",
410"VC-MSDOS","cl:::(unknown)::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::", 496"VC-MSDOS","cl:::(unknown):MSDOS::BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT:::",
411 497
412# Borland C++ 4.5 498# Borland C++ 4.5
413"BC-32","bcc32:::::BN_LLONG DES_PTR RC4_INDEX::::::::::win32", 499"BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX::::::::::win32",
414"BC-16","bcc:::(unknown)::BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT:::", 500"BC-16","bcc:::(unknown):WIN16::BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT:::",
415 501
416# Mingw32 502# Mingw32
417# (Note: the real CFLAGS for Windows builds are defined by util/mk1mf.pl 503# (Note: the real CFLAGS for Windows builds are defined by util/mk1mf.pl
418# and its library files in util/pl/*) 504# and its library files in util/pl/*)
419"Mingw32", "gcc:-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32", 505"Mingw32", "gcc:-DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall:::::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
420 506
421# CygWin32 507# Cygwin
422"CygWin32", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32", 508"Cygwin-pre1.3", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::(unknown):CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32",
509"Cygwin", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall:::CYGWIN32::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}::::::::::win32:cygwin-shared:::.dll",
423 510
424# Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at> 511# Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at>
425"ultrix-cc","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::(unknown)::::::", 512"ultrix-cc","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::(unknown):::::::",
426"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown)::::::", 513"ultrix-gcc","gcc:-O3 -DL_ENDIAN::(unknown):::::::",
427# K&R C is no longer supported; you need gcc on old Ultrix installations 514# K&R C is no longer supported; you need gcc on old Ultrix installations
428##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown)::::::", 515##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::",
429 516
430# Some OpenBSD from Bob Beck <beck@obtuse.com> 517# Some OpenBSD from Bob Beck <beck@obtuse.com>
431"OpenBSD", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 518"OpenBSD", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
432"OpenBSD-alpha", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 519"OpenBSD-alpha", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
433"OpenBSD-i386", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -m486::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 520"OpenBSD-i386", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
434"OpenBSD-m68k", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::RC2_CHAR RC4_INDEX DES_UNROLL:::", 521"OpenBSD-m68k", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
435"OpenBSD-m88k", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 522"OpenBSD-m88k", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
436"OpenBSD-mips", "gcc:-O2 -DL_ENDIAN::(unknown):BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR:::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 523"OpenBSD-mips", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
437"OpenBSD-powerpc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 524"OpenBSD-powerpc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
438"OpenBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", 525"OpenBSD-sparc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
439"OpenBSD-sparc64", "gcc:-mcpu=ultrasparc -O2 -fomit-frame-pointer -Wall -DB_ENDIAN -DTERMIOS -DULTRASPARC::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparcv8plus.o:::", 526"OpenBSD-sparc64", "gcc:-DB_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
440"OpenBSD-vax", "gcc:-DL_ENDIAN -DTERMIOS -O2 -fomit-frame-pointer::(unknown)::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL:::", 527"OpenBSD-vax", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
441 528"OpenBSD-hppa", "gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown):::BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL::::::::::dlfcn:bsd-gcc-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
442##### MacOS X (a.k.a. Rhapsody) setup 529
443"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::", 530##### MacOS X (a.k.a. Rhapsody or Darwin) setup
531"rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
532"darwin-ppc-cc","cc:-O3 -nostdinc -I/System/Library/Frameworks/System.framework/Headers -I/System/Library/Frameworks/System.frameworks/Headers/bsd -I/usr/include -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::::-fPIC",
533"darwin-i386-cc","cc:-O3 -nostdinc -I/System/Library/Frameworks/System.framework/Headers -I/System/Library/Frameworks/System.frameworks/Headers/bsd -I/usr/include -fomit-frame-pointer -Wall -DB_ENDIAN::(unknown):MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::::::::::-fPIC",
444 534
445##### Sony NEWS-OS 4.x 535##### Sony NEWS-OS 4.x
446"newsos4-gcc","gcc:-O -DB_ENDIAN -DNEWS4::(unknown):-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::", 536"newsos4-gcc","gcc:-O -DB_ENDIAN::(unknown):NEWS4:-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::",
537
538##### GNU Hurd
539"hurd-x86", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC",
540
541##### OS/2 EMX
542"OS2-EMX", "gcc::::::::",
543
544##### VxWorks for various targets
545"vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
447 546
448); 547);
449 548
450my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32 549my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32
451 BC-16 Mingw32); 550 BC-16 Mingw32 OS2-EMX);
551
552my $idx = 0;
553my $idx_cc = $idx++;
554my $idx_cflags = $idx++;
555my $idx_unistd = $idx++;
556my $idx_thread_cflag = $idx++;
557my $idx_sys_id = $idx++;
558my $idx_lflags = $idx++;
559my $idx_bn_ops = $idx++;
560my $idx_bn_obj = $idx++;
561my $idx_des_obj = $idx++;
562my $idx_bf_obj = $idx++;
563my $idx_md5_obj = $idx++;
564my $idx_sha1_obj = $idx++;
565my $idx_cast_obj = $idx++;
566my $idx_rc4_obj = $idx++;
567my $idx_rmd160_obj = $idx++;
568my $idx_rc5_obj = $idx++;
569my $idx_dso_scheme = $idx++;
570my $idx_shared_target = $idx++;
571my $idx_shared_cflag = $idx++;
572my $idx_shared_ldflag = $idx++;
573my $idx_shared_extension = $idx++;
574my $idx_ranlib = $idx++;
452 575
453my $prefix=""; 576my $prefix="";
454my $openssldir=""; 577my $openssldir="";
@@ -456,6 +579,8 @@ my $exe_ext="";
456my $install_prefix=""; 579my $install_prefix="";
457my $no_threads=0; 580my $no_threads=0;
458my $no_shared=1; 581my $no_shared=1;
582my $zlib=0;
583my $no_krb5=0;
459my $threads=0; 584my $threads=0;
460my $no_asm=0; 585my $no_asm=0;
461my $no_dso=0; 586my $no_dso=0;
@@ -483,6 +608,14 @@ my $processor="";
483my $default_ranlib; 608my $default_ranlib;
484my $perl; 609my $perl;
485 610
611my $no_ssl2=0;
612my $no_ssl3=0;
613my $no_tls1=0;
614my $no_md5=0;
615my $no_sha=0;
616my $no_rsa=0;
617my $no_dh=0;
618
486$default_ranlib= &which("ranlib") or $default_ranlib="true"; 619$default_ranlib= &which("ranlib") or $default_ranlib="true";
487$perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl") 620$perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
488 or $perl="perl"; 621 or $perl="perl";
@@ -493,11 +626,13 @@ my $flags;
493my $depflags; 626my $depflags;
494my $openssl_algorithm_defines; 627my $openssl_algorithm_defines;
495my $openssl_thread_defines; 628my $openssl_thread_defines;
629my $openssl_sys_defines="";
496my $openssl_other_defines; 630my $openssl_other_defines;
497my $libs; 631my $libs;
498my $target; 632my $target;
499my $options; 633my $options;
500my $symlink; 634my $symlink;
635my %withargs=();
501 636
502my @argvcopy=@ARGV; 637my @argvcopy=@ARGV;
503my $argvstring=""; 638my $argvstring="";
@@ -509,6 +644,7 @@ while($argv_unprocessed)
509 $depflags=""; 644 $depflags="";
510 $openssl_algorithm_defines=""; 645 $openssl_algorithm_defines="";
511 $openssl_thread_defines=""; 646 $openssl_thread_defines="";
647 $openssl_sys_defines="";
512 $openssl_other_defines=""; 648 $openssl_other_defines="";
513 $libs=""; 649 $libs="";
514 $target=""; 650 $target="";
@@ -522,26 +658,32 @@ PROCESS_ARGS:
522 foreach (@argvcopy) 658 foreach (@argvcopy)
523 { 659 {
524 s /^-no-/no-/; # some people just can't read the instructions 660 s /^-no-/no-/; # some people just can't read the instructions
525 if (/^no-asm$/) 661 if (/^--test-sanity$/)
662 {
663 exit(&test_sanity());
664 }
665 elsif (/^no-asm$/)
526 { 666 {
527 $no_asm=1; 667 $no_asm=1;
528 $flags .= "-DNO_ASM "; 668 $flags .= "-DOPENSSL_NO_ASM ";
529 $openssl_other_defines .= "#define NO_ASM\n"; 669 $openssl_other_defines .= "#define OPENSSL_NO_ASM\n";
530 } 670 }
531 elsif (/^no-hw-(.+)$/) 671 elsif (/^no-hw-(.+)$/)
532 { 672 {
533 my $hw=$1; 673 my $hw=$1;
534 $hw =~ tr/[a-z]/[A-Z]/; 674 $hw =~ tr/[a-z]/[A-Z]/;
535 $flags .= "-DNO_HW_$hw "; 675 $flags .= "-DOPENSSL_NO_HW_$hw ";
536 $openssl_other_defines .= "#define NO_HW_$hw\n"; 676 $openssl_other_defines .= "#define OPENSSL_NO_HW_$hw\n";
537 } 677 }
538 elsif (/^no-hw$/) 678 elsif (/^no-hw$/)
539 { 679 {
540 $flags .= "-DNO_HW "; 680 $flags .= "-DOPENSSL_NO_HW ";
541 $openssl_other_defines .= "#define NO_HW\n"; 681 $openssl_other_defines .= "#define OPENSSL_NO_HW\n";
542 } 682 }
543 elsif (/^no-dso$/) 683 elsif (/^no-dso$/)
544 { $no_dso=1; } 684 { $no_dso=1; }
685 elsif (/^no-krb5$/)
686 { $no_krb5=1; }
545 elsif (/^no-threads$/) 687 elsif (/^no-threads$/)
546 { $no_threads=1; } 688 { $no_threads=1; }
547 elsif (/^threads$/) 689 elsif (/^threads$/)
@@ -550,23 +692,59 @@ PROCESS_ARGS:
550 { $no_shared=1; } 692 { $no_shared=1; }
551 elsif (/^shared$/) 693 elsif (/^shared$/)
552 { $no_shared=0; } 694 { $no_shared=0; }
695 elsif (/^no-zlib$/)
696 { $zlib=0; }
697 elsif (/^zlib$/)
698 { $zlib=1; }
699 elsif (/^zlib-dynamic$/)
700 { $zlib=2; }
553 elsif (/^no-symlinks$/) 701 elsif (/^no-symlinks$/)
554 { $symlink=0; } 702 { $symlink=0; }
703 elsif (/^no-ssl$/)
704 { $no_ssl2 = $no_ssl3 = 1; }
705 elsif (/^no-ssl2$/)
706 { $no_ssl2 = 1; }
707 elsif (/^no-ssl3$/)
708 { $no_ssl3 = 1; }
709 elsif (/^no-tls1?$/)
710 { $no_tls1 = 1; }
555 elsif (/^no-(.+)$/) 711 elsif (/^no-(.+)$/)
556 { 712 {
557 my $algo=$1; 713 my $algo=$1;
558 push @skip,$algo; 714 push @skip,$algo;
559 $algo =~ tr/[a-z]/[A-Z]/; 715 $algo =~ tr/[a-z]/[A-Z]/;
560 $flags .= "-DNO_$algo "; 716 $flags .= "-DOPENSSL_NO_$algo ";
561 $depflags .= "-DNO_$algo "; 717 $depflags .= "-DOPENSSL_NO_$algo ";
562 $openssl_algorithm_defines .= "#define NO_$algo\n"; 718 $openssl_algorithm_defines .= "#define OPENSSL_NO_$algo\n";
719 if ($algo eq "RIJNDAEL")
720 {
721 $flags .= "-DOPENSSL_NO_AES ";
722 $depflags .= "-DOPENSSL_NO_AES ";
723 $openssl_algorithm_defines .= "#define OPENSSL_NO_AES\n";
724 }
563 if ($algo eq "DES") 725 if ($algo eq "DES")
564 { 726 {
565 push @skip, "mdc2"; 727 push @skip, "mdc2";
566 $options .= " no-mdc2"; 728 $options .= " no-mdc2";
567 $flags .= "-DNO_MDC2 "; 729 $flags .= "-DOPENSSL_NO_MDC2 ";
568 $depflags .= "-DNO_MDC2 "; 730 $depflags .= "-DOPENSSL_NO_MDC2 ";
569 $openssl_algorithm_defines .= "#define NO_MDC2\n"; 731 $openssl_algorithm_defines .= "#define OPENSSL_NO_MDC2\n";
732 }
733 if ($algo eq "MD5")
734 {
735 $no_md5 = 1;
736 }
737 if ($algo eq "SHA")
738 {
739 $no_sha = 1;
740 }
741 if ($algo eq "RSA")
742 {
743 $no_rsa = 1;
744 }
745 if ($algo eq "DH")
746 {
747 $no_dh = 1;
570 } 748 }
571 } 749 }
572 elsif (/^reconfigure/ || /^reconf/) 750 elsif (/^reconfigure/ || /^reconf/)
@@ -596,9 +774,9 @@ PROCESS_ARGS:
596 { $processor=386; } 774 { $processor=386; }
597 elsif (/^rsaref$/) 775 elsif (/^rsaref$/)
598 { 776 {
599 $libs.= "-lRSAglue -lrsaref "; 777 # No RSAref support any more since it's not needed.
600 $flags.= "-DRSAref "; 778 # The check for the option is there so scripts aren't
601 $openssl_other_defines .= "#define RSAref\n"; 779 # broken
602 } 780 }
603 elsif (/^[-+]/) 781 elsif (/^[-+]/)
604 { 782 {
@@ -622,6 +800,10 @@ PROCESS_ARGS:
622 { 800 {
623 $install_prefix=$1; 801 $install_prefix=$1;
624 } 802 }
803 elsif (/^--with-krb5-(dir|lib|include|flavor)=(.*)$/)
804 {
805 $withargs{"krb5-".$1}=$2;
806 }
625 else 807 else
626 { 808 {
627 print STDERR $usage; 809 print STDERR $usage;
@@ -648,6 +830,39 @@ PROCESS_ARGS:
648 } 830 }
649} 831}
650 832
833$no_ssl3=1 if ($no_md5 || $no_sha);
834$no_ssl3=1 if ($no_rsa && $no_dh);
835
836$no_ssl2=1 if ($no_md5);
837$no_ssl2=1 if ($no_rsa);
838
839$no_tls1=1 if ($no_md5 || $no_sha);
840$no_tls1=1 if ($no_dh);
841
842if ($no_ssl2)
843 {
844 push @skip,"SSL2";
845 $flags .= "-DOPENSSL_NO_SSL2 ";
846 $depflags .= "-DOPENSSL_NO_SSL2 ";
847 $openssl_algorithm_defines .= "#define OPENSSL_NO_SSL2\n";
848 }
849
850if ($no_ssl3)
851 {
852 push @skip,"SSL3";
853 $flags .= "-DOPENSSL_NO_SSL3 ";
854 $depflags .= "-DOPENSSL_NO_SSL3 ";
855 $openssl_algorithm_defines .= "#define OPENSSL_NO_SSL3\n";
856 }
857
858if ($no_tls1)
859 {
860 push @skip,"TLS1";
861 $flags .= "-DOPENSSL_NO_TLS1 ";
862 $depflags .= "-DOPENSSL_NO_TLS1 ";
863 $openssl_algorithm_defines .= "#define OPENSSL_NO_TLS1\n";
864 }
865
651if ($target eq "TABLE") { 866if ($target eq "TABLE") {
652 foreach $target (sort keys %table) { 867 foreach $target (sort keys %table) {
653 print_table_entry($target); 868 print_table_entry($target);
@@ -663,13 +878,17 @@ if ($target eq "LIST") {
663 exit 0; 878 exit 0;
664} 879}
665 880
881if ($target =~ m/^CygWin32(-.*)$/) {
882 $target = "Cygwin".$1;
883}
884
666print "Configuring for $target\n"; 885print "Configuring for $target\n";
667 886
668&usage if (!defined($table{$target})); 887&usage if (!defined($table{$target}));
669 888
670my $IsWindows=scalar grep /^$target$/,@WinTargets; 889my $IsWindows=scalar grep /^$target$/,@WinTargets;
671 890
672$exe_ext=".exe" if ($target eq "CygWin32"); 891$exe_ext=".exe" if ($target eq "Cygwin");
673$openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq ""); 892$openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq "");
674$prefix=$openssldir if $prefix eq ""; 893$prefix=$openssldir if $prefix eq "";
675 894
@@ -682,11 +901,85 @@ $openssldir=$prefix . "/" . $openssldir if $openssldir !~ /^\//;
682 901
683print "IsWindows=$IsWindows\n"; 902print "IsWindows=$IsWindows\n";
684 903
685(my $cc,my $cflags,my $unistd,my $thread_cflag,my $lflags,my $bn_ops,my $bn_obj,my $des_obj,my $bf_obj, 904my @fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
686 $md5_obj,$sha1_obj,my $cast_obj,my $rc4_obj,$rmd160_obj,my $rc5_obj,my $dso_scheme,my $shared_target,my $shared_cflag,my $shared_extension,my $ranlib)= 905my $cc = $fields[$idx_cc];
687 split(/\s*:\s*/,$table{$target} . ":" x 30 , -1); 906my $cflags = $fields[$idx_cflags];
907my $unistd = $fields[$idx_unistd];
908my $thread_cflag = $fields[$idx_thread_cflag];
909my $sys_id = $fields[$idx_sys_id];
910my $lflags = $fields[$idx_lflags];
911my $bn_ops = $fields[$idx_bn_ops];
912my $bn_obj = $fields[$idx_bn_obj];
913my $des_obj = $fields[$idx_des_obj];
914my $bf_obj = $fields[$idx_bf_obj];
915$md5_obj = $fields[$idx_md5_obj];
916$sha1_obj = $fields[$idx_sha1_obj];
917my $cast_obj = $fields[$idx_cast_obj];
918my $rc4_obj = $fields[$idx_rc4_obj];
919$rmd160_obj = $fields[$idx_rmd160_obj];
920my $rc5_obj = $fields[$idx_rc5_obj];
921my $dso_scheme = $fields[$idx_dso_scheme];
922my $shared_target = $fields[$idx_shared_target];
923my $shared_cflag = $fields[$idx_shared_cflag];
924my $shared_ldflag = $fields[$idx_shared_ldflag];
925my $shared_extension = $fields[$idx_shared_extension];
926my $ranlib = $fields[$idx_ranlib];
927
688$cflags="$flags$cflags" if ($flags ne ""); 928$cflags="$flags$cflags" if ($flags ne "");
689 929
930# Kerberos settings. The flavor must be provided from outside, either through
931# the script "config" or manually.
932if ($no_krb5
933 || !defined($withargs{"krb5-flavor"})
934 || $withargs{"krb5-flavor"} eq "")
935 {
936 $cflags="-DOPENSSL_NO_KRB5 $cflags";
937 $options.=" no-krb5" unless $no_krb5;
938 $openssl_algorithm_defines .= "#define OPENSSL_NO_KRB5\n";
939 }
940else
941 {
942 my ($lresolv, $lpath, $lext);
943 if ($withargs{"krb5-flavor"} =~ /^[Hh]eimdal$/)
944 {
945 $withargs{"krb5-dir"} = "/usr/heimdal"
946 if $withargs{"krb5-dir"} eq "";
947 $withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}.
948 "/lib -lgssapi -lkrb5 -lcom_err"
949 if $withargs{"krb5-lib"} eq "";
950 $cflags="-DKRB5_HEIMDAL $cflags";
951 }
952 if ($withargs{"krb5-flavor"} =~ /^[Mm][Ii][Tt]/)
953 {
954 $withargs{"krb5-dir"} = "/usr/kerberos"
955 if $withargs{"krb5-dir"} eq "";
956 $withargs{"krb5-lib"} = "-L".$withargs{"krb5-dir"}.
957 "/lib -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto"
958 if $withargs{"krb5-lib"} eq "";
959 $cflags="-DKRB5_MIT $cflags";
960 $withargs{"krb5-flavor"} =~ s/^[Mm][Ii][Tt][._-]*//;
961 if ($withargs{"krb5-flavor"} =~ /^1[._-]*[01]/)
962 {
963 $cflags="-DKRB5_MIT_OLD11 $cflags";
964 }
965 }
966 LRESOLV:
967 foreach $lpath ("/lib", "/usr/lib")
968 {
969 foreach $lext ("a", "so")
970 {
971 $lresolv = "$lpath/libresolv.$lext";
972 last LRESOLV if (-r "$lresolv");
973 $lresolv = "";
974 }
975 }
976 $withargs{"krb5-lib"} .= " -lresolv"
977 if ("$lresolv");
978 $withargs{"krb5-include"} = "-I".$withargs{"krb5-dir"}."/include"
979 if $withargs{"krb5-include"} eq "" &&
980 $withargs{"krb5-dir"} ne "";
981 }
982
690# The DSO code currently always implements all functions so that no 983# The DSO code currently always implements all functions so that no
691# applications will have to worry about that from a compilation point 984# applications will have to worry about that from a compilation point
692# of view. However, the "method"s may return zero unless that platform 985# of view. However, the "method"s may return zero unless that platform
@@ -700,18 +993,14 @@ if (!$no_dso && $dso_scheme ne "")
700 if ($dso_scheme eq "DLFCN") 993 if ($dso_scheme eq "DLFCN")
701 { 994 {
702 $dso_cflags = "-DDSO_DLFCN -DHAVE_DLFCN_H"; 995 $dso_cflags = "-DDSO_DLFCN -DHAVE_DLFCN_H";
703 $openssl_other_defines .= "#define DSO_DLFCN\n";
704 $openssl_other_defines .= "#define HAVE_DLFCN_H\n";
705 } 996 }
706 elsif ($dso_scheme eq "DLFCN_NO_H") 997 elsif ($dso_scheme eq "DLFCN_NO_H")
707 { 998 {
708 $dso_cflags = "-DDSO_DLFCN"; 999 $dso_cflags = "-DDSO_DLFCN";
709 $openssl_other_defines .= "#define DSO_DLFCN\n";
710 } 1000 }
711 else 1001 else
712 { 1002 {
713 $dso_cflags = "-DDSO_$dso_scheme"; 1003 $dso_cflags = "-DDSO_$dso_scheme";
714 $openssl_other_defines .= "#define DSO_$dso_scheme\n";
715 } 1004 }
716 $cflags = "$dso_cflags $cflags"; 1005 $cflags = "$dso_cflags $cflags";
717 } 1006 }
@@ -727,13 +1016,13 @@ if ($thread_cflag eq "(unknown)")
727 { 1016 {
728 # If the user asked for "threads", hopefully they also provided 1017 # If the user asked for "threads", hopefully they also provided
729 # any system-dependent compiler options that are necessary. 1018 # any system-dependent compiler options that are necessary.
730 $thread_cflags="-DTHREADS $cflags" ; 1019 $thread_cflags="-DOPENSSL_THREADS $cflags" ;
731 $thread_defines .= "#define THREADS\n"; 1020 $thread_defines .= "#define OPENSSL_THREADS\n";
732 } 1021 }
733else 1022else
734 { 1023 {
735 $thread_cflags="-DTHREADS $thread_cflag $cflags"; 1024 $thread_cflags="-DOPENSSL_THREADS $thread_cflag $cflags";
736 $thread_defines .= "#define THREADS\n"; 1025 $thread_defines .= "#define OPENSSL_THREADS\n";
737# my $def; 1026# my $def;
738# foreach $def (split ' ',$thread_cflag) 1027# foreach $def (split ' ',$thread_cflag)
739# { 1028# {
@@ -754,8 +1043,15 @@ if ($no_asm)
754 1043
755if ($threads) 1044if ($threads)
756 { 1045 {
757 $cflags=$thread_cflags; 1046 $cflags=$thread_cflags;
758 $openssl_thread_defines .= $thread_defines; 1047 $openssl_thread_defines .= $thread_defines;
1048 }
1049
1050if ($zlib)
1051 {
1052 $cflags = "-DZLIB $cflags";
1053 $cflags = "-DZLIB_SHARED $cflags" if $zlib == 2;
1054 $lflags = "$lflags -lz" if $zlib == 2;
759 } 1055 }
760 1056
761# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org 1057# You will find shlib_mark1 and shlib_mark2 explained in Makefile.org
@@ -776,6 +1072,12 @@ else
776 $no_shared = 1; 1072 $no_shared = 1;
777 } 1073 }
778 1074
1075if ($sys_id ne "")
1076 {
1077 $cflags="-DOPENSSL_SYSNAME_$sys_id $cflags";
1078 $openssl_sys_defines="#define OPENSSL_SYSNAME_$sys_id\n";
1079 }
1080
779if ($ranlib eq "") 1081if ($ranlib eq "")
780 { 1082 {
781 $ranlib = $default_ranlib; 1083 $ranlib = $default_ranlib;
@@ -850,7 +1152,7 @@ while (<IN>)
850 if ($sdirs) { 1152 if ($sdirs) {
851 my $dir; 1153 my $dir;
852 foreach $dir (@skip) { 1154 foreach $dir (@skip) {
853 s/$dir//; 1155 s/([ ])$dir /\1/;
854 } 1156 }
855 } 1157 }
856 $sdirs = 0 unless /\\$/; 1158 $sdirs = 0 unless /\\$/;
@@ -869,6 +1171,7 @@ while (<IN>)
869 s/^OPTIONS=.*$/OPTIONS=$options/; 1171 s/^OPTIONS=.*$/OPTIONS=$options/;
870 s/^CONFIGURE_ARGS=.*$/CONFIGURE_ARGS=$argvstring/; 1172 s/^CONFIGURE_ARGS=.*$/CONFIGURE_ARGS=$argvstring/;
871 s/^CC=.*$/CC= $cc/; 1173 s/^CC=.*$/CC= $cc/;
1174 s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc";
872 s/^CFLAG=.*$/CFLAG= $cflags/; 1175 s/^CFLAG=.*$/CFLAG= $cflags/;
873 s/^DEPFLAG=.*$/DEPFLAG= $depflags/; 1176 s/^DEPFLAG=.*$/DEPFLAG= $depflags/;
874 s/^EX_LIBS=.*$/EX_LIBS= $lflags/; 1177 s/^EX_LIBS=.*$/EX_LIBS= $lflags/;
@@ -885,10 +1188,22 @@ while (<IN>)
885 s/^PROCESSOR=.*/PROCESSOR= $processor/; 1188 s/^PROCESSOR=.*/PROCESSOR= $processor/;
886 s/^RANLIB=.*/RANLIB= $ranlib/; 1189 s/^RANLIB=.*/RANLIB= $ranlib/;
887 s/^PERL=.*/PERL= $perl/; 1190 s/^PERL=.*/PERL= $perl/;
1191 s/^KRB5_INCLUDES=.*/KRB5_INCLUDES=$withargs{"krb5-include"}/;
1192 s/^LIBKRB5=.*/LIBKRB5=$withargs{"krb5-lib"}/;
888 s/^SHLIB_TARGET=.*/SHLIB_TARGET=$shared_target/; 1193 s/^SHLIB_TARGET=.*/SHLIB_TARGET=$shared_target/;
889 s/^SHLIB_MARK=.*/SHLIB_MARK=$shared_mark/; 1194 s/^SHLIB_MARK=.*/SHLIB_MARK=$shared_mark/;
890 s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$no_shared); 1195 s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$no_shared);
891 s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.so.\$(SHLIB_MAJOR) .so/ if ($shared_extension ne "" && $shared_extension !~ /^\.s[ol]$/); 1196 if ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*$/)
1197 {
1198 my $sotmp = $1;
1199 s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp/
1200 }
1201 elsif ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*\.[^\.]*$/)
1202 {
1203 my $sotmp = $1;
1204 s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp.\$(SHLIB_MAJOR) .s$sotmp/;
1205 }
1206 s/^SHARED_LDFLAGS=.*/SHARED_LDFLAGS=$shared_ldflag/;
892 print OUT $_."\n"; 1207 print OUT $_."\n";
893 } 1208 }
894close(IN); 1209close(IN);
@@ -909,6 +1224,10 @@ print "RMD160_OBJ_ASM=$rmd160_obj\n";
909print "PROCESSOR =$processor\n"; 1224print "PROCESSOR =$processor\n";
910print "RANLIB =$ranlib\n"; 1225print "RANLIB =$ranlib\n";
911print "PERL =$perl\n"; 1226print "PERL =$perl\n";
1227print "KRB5_INCLUDES =",$withargs{"krb5-include"},"\n"
1228 if $withargs{"krb5-include"} ne "";
1229print "LIBKRB5 =",$withargs{"krb5-lib"},"\n"
1230 if $withargs{"krb5-lib"} ne "";
912 1231
913my $des_ptr=0; 1232my $des_ptr=0;
914my $des_risc1=0; 1233my $des_risc1=0;
@@ -925,6 +1244,7 @@ my $rc4_chunk=0;
925my $bf_ptr=0; 1244my $bf_ptr=0;
926my @type=("char","short","int","long"); 1245my @type=("char","short","int","long");
927my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0); 1246my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0);
1247my $export_var_as_fn=0;
928 1248
929my $des_int; 1249my $des_int;
930 1250
@@ -954,6 +1274,7 @@ foreach (sort split(/\s+/,$bn_ops))
954 ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/; 1274 ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/;
955 ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/; 1275 ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/;
956 ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/; 1276 ($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/;
1277 $export_var_as_fn=1 if /EXPORT_VAR_AS_FN/;
957 } 1278 }
958 1279
959open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n"; 1280open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
@@ -962,18 +1283,37 @@ print OUT "/* opensslconf.h */\n";
962print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n"; 1283print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
963 1284
964print OUT "/* OpenSSL was configured with the following options: */\n"; 1285print OUT "/* OpenSSL was configured with the following options: */\n";
965$openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg; 1286my $openssl_algorithm_defines_trans = $openssl_algorithm_defines;
1287$openssl_algorithm_defines_trans =~ s/^\s*#\s*define\s+OPENSSL_(.*)/# if defined(OPENSSL_$1) \&\& !defined($1)\n# define $1\n# endif/mg;
1288$openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
966$openssl_algorithm_defines = " /* no ciphers excluded */\n" if $openssl_algorithm_defines eq ""; 1289$openssl_algorithm_defines = " /* no ciphers excluded */\n" if $openssl_algorithm_defines eq "";
967$openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg; 1290$openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
968$openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n# define $1\n# endif/mg; 1291$openssl_sys_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
969print OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n$openssl_algorithm_defines#endif\n"; 1292$openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/#ifndef $1\n# define $1\n#endif/mg;
970print OUT "#ifdef OPENSSL_THREAD_DEFINES\n$openssl_thread_defines#endif\n"; 1293print OUT $openssl_sys_defines;
971print OUT "#ifdef OPENSSL_OTHER_DEFINES\n$openssl_other_defines#endif\n\n"; 1294print OUT "#ifndef OPENSSL_DOING_MAKEDEPEND\n\n";
1295print OUT $openssl_algorithm_defines;
1296print OUT "\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n";
1297print OUT $openssl_thread_defines;
1298print OUT $openssl_other_defines,"\n";
1299
1300print OUT "/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n";
1301print OUT " asks for it. This is a transient feature that is provided for those\n";
1302print OUT " who haven't had the time to do the appropriate changes in their\n";
1303print OUT " applications. */\n";
1304print OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n";
1305print OUT $openssl_algorithm_defines_trans;
1306print OUT "#endif\n\n";
972 1307
973while (<IN>) 1308while (<IN>)
974 { 1309 {
975 if (/^#define\s+OPENSSLDIR/) 1310 if (/^#define\s+OPENSSLDIR/)
976 { print OUT "#define OPENSSLDIR \"$openssldir\"\n"; } 1311 { print OUT "#define OPENSSLDIR \"$openssldir\"\n"; }
1312 elsif (/^#((define)|(undef))\s+OPENSSL_EXPORT_VAR_AS_FUNCTION/)
1313 { printf OUT "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n"
1314 if $export_var_as_fn;
1315 printf OUT "#%s OPENSSL_EXPORT_VAR_AS_FUNCTION\n",
1316 ($export_var_as_fn)?"define":"undef"; }
977 elsif (/^#define\s+OPENSSL_UNISTD/) 1317 elsif (/^#define\s+OPENSSL_UNISTD/)
978 { 1318 {
979 $unistd = "<unistd.h>" if $unistd eq ""; 1319 $unistd = "<unistd.h>" if $unistd eq "";
@@ -1172,11 +1512,11 @@ sub print_table_entry
1172 { 1512 {
1173 my $target = shift; 1513 my $target = shift;
1174 1514
1175 (my $cc,my $cflags,my $unistd,my $thread_cflag,my $lflags,my $bn_ops, 1515 (my $cc,my $cflags,my $unistd,my $thread_cflag,my $sys_id,my $lflags,
1176 my $bn_obj,my $des_obj,my $bf_obj, 1516 my $bn_ops,my $bn_obj,my $des_obj,my $bf_obj,
1177 my $md5_obj,my $sha1_obj,my $cast_obj,my $rc4_obj,my $rmd160_obj, 1517 my $md5_obj,my $sha1_obj,my $cast_obj,my $rc4_obj,my $rmd160_obj,
1178 my $rc5_obj,my $dso_scheme,my $shared_target,my $shared_cflag, 1518 my $rc5_obj,my $dso_scheme,my $shared_target,my $shared_cflag,
1179 my $shared_extension,my $ranlib)= 1519 my $shared_ldflag,my $shared_extension,my $ranlib)=
1180 split(/\s*:\s*/,$table{$target} . ":" x 30 , -1); 1520 split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
1181 1521
1182 print <<EOF 1522 print <<EOF
@@ -1186,6 +1526,7 @@ sub print_table_entry
1186\$cflags = $cflags 1526\$cflags = $cflags
1187\$unistd = $unistd 1527\$unistd = $unistd
1188\$thread_cflag = $thread_cflag 1528\$thread_cflag = $thread_cflag
1529\$sys_id = $sys_id
1189\$lflags = $lflags 1530\$lflags = $lflags
1190\$bn_ops = $bn_ops 1531\$bn_ops = $bn_ops
1191\$bn_obj = $bn_obj 1532\$bn_obj = $bn_obj
@@ -1200,7 +1541,44 @@ sub print_table_entry
1200\$dso_scheme = $dso_scheme 1541\$dso_scheme = $dso_scheme
1201\$shared_target= $shared_target 1542\$shared_target= $shared_target
1202\$shared_cflag = $shared_cflag 1543\$shared_cflag = $shared_cflag
1544\$shared_ldflag = $shared_ldflag
1203\$shared_extension = $shared_extension 1545\$shared_extension = $shared_extension
1204\$ranlib = $ranlib 1546\$ranlib = $ranlib
1205EOF 1547EOF
1206 } 1548 }
1549
1550sub test_sanity
1551 {
1552 my $errorcnt = 0;
1553
1554 print STDERR "=" x 70, "\n";
1555 print STDERR "=== SANITY TESTING!\n";
1556 print STDERR "=== No configuration will be done, all other arguments will be ignored!\n";
1557 print STDERR "=" x 70, "\n";
1558
1559 foreach $target (sort keys %table)
1560 {
1561 @fields = split(/\s*:\s*/,$table{$target} . ":" x 30 , -1);
1562
1563 if ($fields[$idx_dso_scheme-1] =~ /^(dl|dlfcn|win32|vms)$/)
1564 {
1565 $errorcnt++;
1566 print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
1567 print STDERR " in the previous field\n";
1568 }
1569 elsif ($fields[$idx_dso_scheme+1] =~ /^(dl|dlfcn|win32|vms)$/)
1570 {
1571 $errorcnt++;
1572 print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] values\n";
1573 print STDERR " in the following field\n";
1574 }
1575 elsif ($fields[$idx_dso_scheme] !~ /^(dl|dlfcn|win32|vms|)$/)
1576 {
1577 $errorcnt++;
1578 print STDERR "SANITY ERROR: '$target' has the dso_scheme [$idx_dso_scheme] field = ",$fields[$idx_dso_scheme],"\n";
1579 print STDERR " valid values are 'dl', 'dlfcn', 'win32' and 'vms'\n";
1580 }
1581 }
1582 print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
1583 return $errorcnt;
1584 }
diff --git a/src/lib/libssl/src/FAQ b/src/lib/libssl/src/FAQ
index 23e212fb4e..8b53581c5a 100644
--- a/src/lib/libssl/src/FAQ
+++ b/src/lib/libssl/src/FAQ
@@ -8,6 +8,7 @@ OpenSSL - Frequently Asked Questions
8* How can I contact the OpenSSL developers? 8* How can I contact the OpenSSL developers?
9* Where can I get a compiled version of OpenSSL? 9* Where can I get a compiled version of OpenSSL?
10* Why aren't tools like 'autoconf' and 'libtool' used? 10* Why aren't tools like 'autoconf' and 'libtool' used?
11* What is an 'engine' version?
11 12
12[LEGAL] Legal questions 13[LEGAL] Legal questions
13 14
@@ -27,13 +28,15 @@ OpenSSL - Frequently Asked Questions
27* How can I remove the passphrase on a private key? 28* How can I remove the passphrase on a private key?
28* Why can't I use OpenSSL certificates with SSL client authentication? 29* Why can't I use OpenSSL certificates with SSL client authentication?
29* Why does my browser give a warning about a mismatched hostname? 30* Why does my browser give a warning about a mismatched hostname?
31* How do I install a CA certificate into a browser?
32* Why is OpenSSL x509 DN output not conformant to RFC2253?
30 33
31[BUILD] Questions about building and testing OpenSSL 34[BUILD] Questions about building and testing OpenSSL
32 35
33* Why does the linker complain about undefined symbols? 36* Why does the linker complain about undefined symbols?
34* Why does the OpenSSL test fail with "bc: command not found"? 37* Why does the OpenSSL test fail with "bc: command not found"?
35* Why does the OpenSSL test fail with "bc: 1 no implemented"? 38* Why does the OpenSSL test fail with "bc: 1 no implemented"?
36* Why does the OpenSSL compilation fail on Alpha True64 Unix? 39* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
37* Why does the OpenSSL compilation fail with "ar: command not found"? 40* Why does the OpenSSL compilation fail with "ar: command not found"?
38* Why does the OpenSSL compilation fail on Win32 with VC++? 41* Why does the OpenSSL compilation fail on Win32 with VC++?
39 42
@@ -57,7 +60,7 @@ OpenSSL - Frequently Asked Questions
57* Which is the current version of OpenSSL? 60* Which is the current version of OpenSSL?
58 61
59The current version is available from <URL: http://www.openssl.org>. 62The current version is available from <URL: http://www.openssl.org>.
60OpenSSL 0.9.6b was released on July 9th, 2001. 63OpenSSL 0.9.6c was released on December 21st, 2001.
61 64
62In addition to the current stable release, you can also access daily 65In addition to the current stable release, you can also access daily
63snapshots of the OpenSSL development version at <URL: 66snapshots of the OpenSSL development version at <URL:
@@ -121,6 +124,12 @@ A number of Linux and *BSD distributions include OpenSSL.
121autoconf will probably be used in future OpenSSL versions. If it was 124autoconf will probably be used in future OpenSSL versions. If it was
122less Unix-centric, it might have been used much earlier. 125less Unix-centric, it might have been used much earlier.
123 126
127* What is an 'engine' version?
128
129With version 0.9.6 OpenSSL was extended to interface to external crypto
130hardware. This was realized in a special release '0.9.6-engine'. With
131version 0.9.7 (not yet released) the changes were merged into the main
132development line, so that the special release is no longer necessary.
124 133
125[LEGAL] ======================================================================= 134[LEGAL] =======================================================================
126 135
@@ -146,7 +155,7 @@ holders claim that you infringe on their rights if you use OpenSSL with
146their software on operating systems that don't normally include OpenSSL. 155their software on operating systems that don't normally include OpenSSL.
147 156
148If you develop open source software that uses OpenSSL, you may find it 157If you develop open source software that uses OpenSSL, you may find it
149useful to choose an other license than the GPL, or state explicitely that 158useful to choose an other license than the GPL, or state explicitly that
150"This program is released under the GPL with the additional exemption that 159"This program is released under the GPL with the additional exemption that
151compiling, linking, and/or using OpenSSL is allowed." If you are using 160compiling, linking, and/or using OpenSSL is allowed." If you are using
152GPL software developed by others, you may want to ask the copyright holder 161GPL software developed by others, you may want to ask the copyright holder
@@ -186,7 +195,7 @@ environment variable HOME is set, then the seeding file is $HOME/.rnd.
186If neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will 195If neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will
187use file .rnd in the current directory while OpenSSL 0.9.6a uses no 196use file .rnd in the current directory while OpenSSL 0.9.6a uses no
188default seeding file at all. OpenSSL 0.9.6b and later will behave 197default seeding file at all. OpenSSL 0.9.6b and later will behave
189similarly to 0.9.6a, but will use a default of "C:" for HOME on 198similarly to 0.9.6a, but will use a default of "C:\" for HOME on
190Windows systems if the environment variable has not been set. 199Windows systems if the environment variable has not been set.
191 200
192If the default seeding file does not exist or is too short, the "PRNG 201If the default seeding file does not exist or is too short, the "PRNG
@@ -297,7 +306,7 @@ there is little point presenting a certificate which the server will
297reject. 306reject.
298 307
299The solution is to add the relevant CA certificate to your servers "trusted 308The solution is to add the relevant CA certificate to your servers "trusted
300CA list". How you do this depends on the server sofware in uses. You can 309CA list". How you do this depends on the server software in uses. You can
301print out the servers list of acceptable CAs using the OpenSSL s_client tool: 310print out the servers list of acceptable CAs using the OpenSSL s_client tool:
302 311
303openssl s_client -connect www.some.host:443 -prexit 312openssl s_client -connect www.some.host:443 -prexit
@@ -316,6 +325,33 @@ Browsers expect the server's hostname to match the value in the commonName
316(CN) field of the certificate. If it does not then you get a warning. 325(CN) field of the certificate. If it does not then you get a warning.
317 326
318 327
328* How do I install a CA certificate into a browser?
329
330The usual way is to send the DER encoded certificate to the browser as
331MIME type application/x-x509-ca-cert, for example by clicking on an appropriate
332link. On MSIE certain extensions such as .der or .cacert may also work, or you
333can import the certificate using the certificate import wizard.
334
335You can convert a certificate to DER form using the command:
336
337openssl x509 -in ca.pem -outform DER -out ca.der
338
339Occasionally someone suggests using a command such as:
340
341openssl pkcs12 -export -out cacert.p12 -in cacert.pem -inkey cakey.pem
342
343DO NOT DO THIS! This command will give away your CAs private key and
344reduces its security to zero: allowing anyone to forge certificates in
345whatever name they choose.
346
347* Why is OpenSSL x509 DN output not conformant to RFC2253?
348
349The ways to print out the oneline format of the DN (Distinguished Name) have
350been extended in version 0.9.7 of OpenSSL. Using the new X509_NAME_print_ex()
351interface, the "-nameopt" option could be introduded. See the manual
352page of the "openssl x509" commandline tool for details. The old behaviour
353has however been left as default for the sake of compatibility.
354
319[BUILD] ======================================================================= 355[BUILD] =======================================================================
320 356
321* Why does the linker complain about undefined symbols? 357* Why does the linker complain about undefined symbols?
@@ -359,9 +395,9 @@ and compile/install it. GNU bc (see http://www.gnu.org/software/software.html
359for download instructions) can be safely used, for example. 395for download instructions) can be safely used, for example.
360 396
361 397
362* Why does the OpenSSL compilation fail on Alpha True64 Unix? 398* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
363 399
364On some Alpha installations running True64 Unix and Compaq C, the compilation 400On some Alpha installations running Tru64 Unix and Compaq C, the compilation
365of crypto/sha/sha_dgst.c fails with the message 'Fatal: Insufficient virtual 401of crypto/sha/sha_dgst.c fails with the message 'Fatal: Insufficient virtual
366memory to continue compilation.' As far as the tests have shown, this may be 402memory to continue compilation.' As far as the tests have shown, this may be
367a compiler bug. What happens is that it eats up a lot of resident memory 403a compiler bug. What happens is that it eats up a lot of resident memory
@@ -439,10 +475,43 @@ OpenSSL. This is described in the threads(3) manpage.
439 475
440* I've compiled a program under Windows and it crashes: why? 476* I've compiled a program under Windows and it crashes: why?
441 477
442This is usually because you've missed the comment in INSTALL.W32. You 478This is usually because you've missed the comment in INSTALL.W32.
443must link with the multithreaded DLL version of the VC++ runtime library 479Your application must link against the same version of the Win32
444otherwise the conflict will cause a program to crash: typically on the 480C-Runtime against which your openssl libraries were linked. The
445first BIO related read or write operation. 481default version for OpenSSL is /MD - "Multithreaded DLL".
482
483If you are using Microsoft Visual C++'s IDE (Visual Studio), in
484many cases, your new project most likely defaulted to "Debug
485Singlethreaded" - /ML. This is NOT interchangeable with /MD and your
486program will crash, typically on the first BIO related read or write
487operation.
488
489For each of the six possible link stage configurations within Win32,
490your application must link against the same by which OpenSSL was
491built. If you are using MS Visual C++ (Studio) this can be changed
492by:
493
4941. Select Settings... from the Project Menu.
4952. Select the C/C++ Tab.
4963. Select "Code Generation from the "Category" drop down list box
4974. Select the Appropriate library (see table below) from the "Use
498 run-time library" drop down list box. Perform this step for both
499 your debug and release versions of your application (look at the
500 top left of the settings panel to change between the two)
501
502 Single Threaded /ML - MS VC++ often defaults to
503 this for the release
504 version of a new project.
505 Debug Single Threaded /MLd - MS VC++ often defaults to
506 this for the debug version
507 of a new project.
508 Multithreaded /MT
509 Debug Multithreaded /MTd
510 Multithreaded DLL /MD - OpenSSL defaults to this.
511 Debug Multithreaded DLL /MDd
512
513Note that debug and release libraries are NOT interchangeable. If you
514built OpenSSL with /MD your application must use /MD and cannot use /MDd.
446 515
447 516
448* How do I read or write a DER encoded buffer using the ASN1 functions? 517* How do I read or write a DER encoded buffer using the ASN1 functions?
@@ -523,44 +592,16 @@ OpenSSL_add_all_algorithms(). See the manual page for more information.
523 592
524* Why can't the OpenSSH configure script detect OpenSSL? 593* Why can't the OpenSSH configure script detect OpenSSL?
525 594
526There is a problem with OpenSSH 1.2.2p1, in that the configure script 595Several reasons for problems with the automatic detection exist.
527can't find the installed OpenSSL libraries. The problem is actually 596OpenSSH requires at least version 0.9.5a of the OpenSSL libraries.
528a small glitch that is easily solved with the following patch to be 597Sometimes the distribution has installed an older version in the system
529applied to the OpenSSH distribution: 598locations that is detected instead of a new one installed. The OpenSSL
530 599library might have been compiled for another CPU or another mode (32/64 bits).
531----- snip:start ----- 600Permissions might be wrong.
532--- openssh-1.2.2p1/configure.in.orig Thu Mar 23 18:56:58 2000
533+++ openssh-1.2.2p1/configure.in Thu Mar 23 18:55:05 2000
534@@ -152,10 +152,10 @@
535 AC_MSG_CHECKING([for OpenSSL/SSLeay directory])
536 for ssldir in "" $tryssldir /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
537 if test ! -z "$ssldir" ; then
538- LIBS="$saved_LIBS -L$ssldir"
539+ LIBS="$saved_LIBS -L$ssldir/lib"
540 CFLAGS="$CFLAGS -I$ssldir/include"
541 if test "x$need_dash_r" = "x1" ; then
542- LIBS="$LIBS -R$ssldir"
543+ LIBS="$LIBS -R$ssldir/lib"
544 fi
545 fi
546 LIBS="$LIBS -lcrypto"
547--- openssh-1.2.2p1/configure.orig Thu Mar 23 18:55:02 2000
548+++ openssh-1.2.2p1/configure Thu Mar 23 18:57:08 2000
549@@ -1890,10 +1890,10 @@
550 echo "configure:1891: checking for OpenSSL/SSLeay directory" >&5
551 for ssldir in "" $tryssldir /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
552 if test ! -z "$ssldir" ; then
553- LIBS="$saved_LIBS -L$ssldir"
554+ LIBS="$saved_LIBS -L$ssldir/lib"
555 CFLAGS="$CFLAGS -I$ssldir/include"
556 if test "x$need_dash_r" = "x1" ; then
557- LIBS="$LIBS -R$ssldir"
558+ LIBS="$LIBS -R$ssldir/lib"
559 fi
560 fi
561 LIBS="$LIBS -lcrypto"
562----- snip:end -----
563 601
602The general answer is to check the config.log file generated when running
603the OpenSSH configure script. It should contain the detailed information
604on why the OpenSSL library was not detected or considered incompatible.
564 605
565* Can I use OpenSSL's SSL library with non-blocking I/O? 606* Can I use OpenSSL's SSL library with non-blocking I/O?
566 607
@@ -579,7 +620,7 @@ SSL_write() will try to continue any pending handshake.
579* Why doesn't my server application receive a client certificate? 620* Why doesn't my server application receive a client certificate?
580 621
581Due to the TLS protocol definition, a client will only send a certificate, 622Due to the TLS protocol definition, a client will only send a certificate,
582if explicitely asked by the server. Use the SSL_VERIFY_PEER flag of the 623if explicitly asked by the server. Use the SSL_VERIFY_PEER flag of the
583SSL_CTX_set_verify() function to enable the use of client certificates. 624SSL_CTX_set_verify() function to enable the use of client certificates.
584 625
585 626
diff --git a/src/lib/libssl/src/INSTALL b/src/lib/libssl/src/INSTALL
index 5bafcd4b5d..06aa96bcfa 100644
--- a/src/lib/libssl/src/INSTALL
+++ b/src/lib/libssl/src/INSTALL
@@ -52,14 +52,20 @@
52 This will usually require additional system-dependent options! 52 This will usually require additional system-dependent options!
53 See "Note on multi-threading" below. 53 See "Note on multi-threading" below.
54 54
55 no-zlib Don't try to build with support for zlib compression and
56 decompression.
57
58 zlib Build with support for zlib compression/decompression.
59
60 zlib-dynamic Like "zlib", but has OpenSSL load the zlib library dynamically
61 when needed. This is only supported on systems where loading
62 of shared libraries is supported. This is the default choice.
63
55 no-shared Don't try to create shared libraries. 64 no-shared Don't try to create shared libraries.
56 65
57 shared In addition to the usual static libraries, create shared 66 shared In addition to the usual static libraries, create shared
58 libraries on platforms where it's supported. See "Note on 67 libraries on platforms where it's supported. See "Note on
59 shared libraries" below. THIS IS NOT RECOMMENDED! Since 68 shared libraries" below.
60 this is a development branch, the positions of the ENGINE
61 symbols in the transfer vector are constantly moving, so
62 binary backward compatibility can't be guaranteed in any way.
63 69
64 no-asm Do not use assembler code. 70 no-asm Do not use assembler code.
65 71
@@ -271,6 +277,11 @@
271 Note on shared libraries 277 Note on shared libraries
272 ------------------------ 278 ------------------------
273 279
280 Shared library is currently an experimental feature. The only reason to
281 have them would be to conserve memory on systems where several program
282 are using OpenSSL. Binary backward compatibility can't be guaranteed
283 before OpenSSL version 1.0.
284
274 For some systems, the OpenSSL Configure script knows what is needed to 285 For some systems, the OpenSSL Configure script knows what is needed to
275 build shared libraries for libcrypto and libssl. On these systems, 286 build shared libraries for libcrypto and libssl. On these systems,
276 the shared libraries are currently not created by default, but giving 287 the shared libraries are currently not created by default, but giving
diff --git a/src/lib/libssl/src/INSTALL.MacOS b/src/lib/libssl/src/INSTALL.MacOS
index a8c4f7f1da..01c60d81f9 100644
--- a/src/lib/libssl/src/INSTALL.MacOS
+++ b/src/lib/libssl/src/INSTALL.MacOS
@@ -1,7 +1,7 @@
1OpenSSL - Port To The Macintosh 1OpenSSL - Port To The Macintosh OS 9 or Earlier
2=============================== 2===============================================
3 3
4Thanks to Roy Wood <roy@centricsystems.ca> initial support for MacOS (pre 4Thanks to Roy Wood <roy@centricsystems.ca> initial support for Mac OS (pre
5X) is now provided. "Initial" means that unlike other platforms where you 5X) is now provided. "Initial" means that unlike other platforms where you
6get an SDK and a "swiss army" openssl application, on Macintosh you only 6get an SDK and a "swiss army" openssl application, on Macintosh you only
7get one sample application which fetches a page over HTTPS(*) and dumps it 7get one sample application which fetches a page over HTTPS(*) and dumps it
@@ -32,17 +32,17 @@ Installation procedure:
32 to 42, change appropriately. 32 to 42, change appropriately.
33(**) If you use SUNtar, then it might have already unbinhexed the files 33(**) If you use SUNtar, then it might have already unbinhexed the files
34 in question. 34 in question.
35(***) The project file was saved with CW Pro 5.3. If you have earlier 35(***) The project file was saved with CW Pro 5.3. If you have an earlier
36 version and it refuses to open it, then download 36 version and it refuses to open it, then download
37 http://www.openssl.org/~appro/OpenSSL.mcp.xml and import it 37 http://www.openssl.org/~appro/OpenSSL.mcp.xml and import it
38 overwriting the original OpenSSL.mcp. 38 overwriting the original OpenSSL.mcp.
39(****) Other targets are work in progress. If you feel like giving 'em a 39(****) Other targets are works in progress. If you feel like giving 'em a
40 shot, then you should know that OpenSSL* and Lib* targets are 40 shot, then you should know that OpenSSL* and Lib* targets are
41 supposed to be built with the GUSI, MacOS library which mimics 41 supposed to be built with the GUSI, MacOS library which mimics
42 BSD sockets and some other POSIX APIs. The GUSI distribution is 42 BSD sockets and some other POSIX APIs. The GUSI distribution is
43 expected to be found in the same directory as openssl source tree, 43 expected to be found in the same directory as the openssl source tree,
44 i.e. in the parent directory to the one where this very file, 44 i.e., in the parent directory to the one where this very file,
45 namely INSTALL.MacOS. For more informations about GUSI, see 45 namely INSTALL.MacOS, resides. For more information about GUSI, see
46 http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html 46 http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html
47 47
48Finally some essential comments from our generous contributor:-) 48Finally some essential comments from our generous contributor:-)
diff --git a/src/lib/libssl/src/INSTALL.OS2 b/src/lib/libssl/src/INSTALL.OS2
new file mode 100644
index 0000000000..d4cc0e319b
--- /dev/null
+++ b/src/lib/libssl/src/INSTALL.OS2
@@ -0,0 +1,22 @@
1
2 Installation on OS/2
3 --------------------
4
5 You need to have the following tools installed:
6
7 * EMX GCC
8 * PERL
9 * GNU make
10
11
12 To build the makefile, run
13
14 > os2\os2-emx
15
16 This will configure OpenSSL and create OS2-EMX.mak which you then use to
17 build the OpenSSL libraries & programs by running
18
19 > make -f os2-emx.mak
20
21 If that finishes successfully you will find the libraries and programs in the
22 "out" directory.
diff --git a/src/lib/libssl/src/INSTALL.VMS b/src/lib/libssl/src/INSTALL.VMS
index b8ea2d0a4d..7658f64e1d 100644
--- a/src/lib/libssl/src/INSTALL.VMS
+++ b/src/lib/libssl/src/INSTALL.VMS
@@ -33,11 +33,11 @@ Checking the distribution:
33========================== 33==========================
34 34
35There have been reports of places where the distribution didn't quite get 35There have been reports of places where the distribution didn't quite get
36through, for example if you've copied the tree from a NFS-mounted unix 36through, for example if you've copied the tree from a NFS-mounted Unix
37mount point. 37mount point.
38 38
39The easiest way to check if everything got through as it should is to check 39The easiest way to check if everything got through as it should is to check
40for oen of the following files: 40for one of the following files:
41 41
42 [.CRYPTO]OPENSSLCONF.H_IN 42 [.CRYPTO]OPENSSLCONF.H_IN
43 [.CRYPTO]OPENSSLCONF_H.IN 43 [.CRYPTO]OPENSSLCONF_H.IN
@@ -69,7 +69,7 @@ for a command procedure name xxx-LIB.COM (in the library directories)
69or MAKExxx.COM (in the program directories) and read the comments at 69or MAKExxx.COM (in the program directories) and read the comments at
70the top to understand how to use them. However, if you want to 70the top to understand how to use them. However, if you want to
71compile all you can get, the simplest is to use MAKEVMS.COM in the top 71compile all you can get, the simplest is to use MAKEVMS.COM in the top
72directory. The syntax is trhe following: 72directory. The syntax is the following:
73 73
74 @MAKEVMS <option> <rsaref-p> <debug-p> [<compiler>] 74 @MAKEVMS <option> <rsaref-p> <debug-p> [<compiler>]
75 75
@@ -79,7 +79,7 @@ directory. The syntax is trhe following:
79 CONFIG Just build the "[.CRYPTO]OPENSSLCONF.H" file. 79 CONFIG Just build the "[.CRYPTO]OPENSSLCONF.H" file.
80 BUILDINF Just build the "[.INCLUDE]BUILDINF.H" file. 80 BUILDINF Just build the "[.INCLUDE]BUILDINF.H" file.
81 SOFTLINKS Just copies some files, to simulate Unix soft links. 81 SOFTLINKS Just copies some files, to simulate Unix soft links.
82 BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done. 82 BUILDALL Same as ALL, except CONFIG, BUILDINF and SOFTLINKS aren't done.
83 RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library. 83 RSAREF Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
84 CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library. 84 CRYPTO Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
85 SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library. 85 SSL Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library.
@@ -92,7 +92,7 @@ directory. The syntax is trhe following:
92 RSAREF compile using the RSAREF Library 92 RSAREF compile using the RSAREF Library
93 NORSAREF compile without using RSAREF 93 NORSAREF compile without using RSAREF
94 94
95Note 0: The RASREF library IS NO LONGER NEEDED. The RSA patent 95Note 0: The RSAREF library IS NO LONGER NEEDED. The RSA patent
96 expires September 20, 2000, and RSA Security chose to make 96 expires September 20, 2000, and RSA Security chose to make
97 the algorithm public domain two weeks before that. 97 the algorithm public domain two weeks before that.
98 98
@@ -264,7 +264,7 @@ following before you start compiling:
264The USER_CCDISABLEWARNINGS is there because otherwise, DEC C will complain 264The USER_CCDISABLEWARNINGS is there because otherwise, DEC C will complain
265that those macros have been changed. 265that those macros have been changed.
266 266
267Note: Currently, this is only usefull for library compilation. The 267Note: Currently, this is only useful for library compilation. The
268 programs will still be linked with the current version of the 268 programs will still be linked with the current version of the
269 C library shareable image, and will thus complain if they are 269 C library shareable image, and will thus complain if they are
270 faced with an older version of the same C library shareable image. 270 faced with an older version of the same C library shareable image.
diff --git a/src/lib/libssl/src/INSTALL.W32 b/src/lib/libssl/src/INSTALL.W32
index a98364f50f..da061b289e 100644
--- a/src/lib/libssl/src/INSTALL.W32
+++ b/src/lib/libssl/src/INSTALL.W32
@@ -2,16 +2,19 @@
2 INSTALLATION ON THE WIN32 PLATFORM 2 INSTALLATION ON THE WIN32 PLATFORM
3 ---------------------------------- 3 ----------------------------------
4 4
5 Heres a few comments about building OpenSSL in Windows environments. Most of 5 Heres a few comments about building OpenSSL in Windows environments. Most
6 this is tested on Win32 but it may also work in Win 3.1 with some 6 of this is tested on Win32 but it may also work in Win 3.1 with some
7 modification. 7 modification.
8 8
9 You need Perl for Win32 (available from http://www.activestate.com/ActivePerl) 9 You need Perl for Win32. Unless you will build on Cygwin, you will need
10 ActiveState Perl, available from http://www.activestate.com/ActivePerl.
11 For Cygwin users, there's more info in the Cygwin section.
12
10 and one of the following C compilers: 13 and one of the following C compilers:
11 14
12 * Visual C++ 15 * Visual C++
13 * Borland C 16 * Borland C
14 * GNU C (Mingw32 or Cygwin32) 17 * GNU C (Mingw32 or Cygwin)
15 18
16 If you want to compile in the assembly language routines with Visual C++ then 19 If you want to compile in the assembly language routines with Visual C++ then
17 you will need an assembler. This is worth doing because it will result in 20 you will need an assembler. This is worth doing because it will result in
@@ -78,7 +81,7 @@
78 81
79 There are various changes you can make to the Win32 compile environment. By 82 There are various changes you can make to the Win32 compile environment. By
80 default the library is not compiled with debugging symbols. If you add 'debug' 83 default the library is not compiled with debugging symbols. If you add 'debug'
81 to the mk1mk.pl lines in the do_* batch file then debugging symbols will be 84 to the mk1mf.pl lines in the do_* batch file then debugging symbols will be
82 compiled in. 85 compiled in.
83 86
84 The default Win32 environment is to leave out any Windows NT specific 87 The default Win32 environment is to leave out any Windows NT specific
@@ -132,28 +135,30 @@
132 > cd out 135 > cd out
133 > ..\ms\test 136 > ..\ms\test
134 137
135 GNU C (CygWin32) 138 GNU C (Cygwin)
136 --------------- 139 --------------
137 140
138 CygWin32 provides a bash shell and GNU tools environment running on 141 Cygwin provides a bash shell and GNU tools environment running on
139 NT 4.0, Windows 9x and Windows 2000. Consequently, a make of OpenSSL 142 NT 4.0, Windows 9x and Windows 2000. Consequently, a make of OpenSSL
140 with CygWin is closer to a GNU bash environment such as Linux rather 143 with Cygwin is closer to a GNU bash environment such as Linux rather
141 than other W32 makes that are based on a single makefile approach. 144 than other W32 makes that are based on a single makefile approach.
142 CygWin32 implements Posix/Unix calls through cygwin1.dll, and is 145 Cygwin implements Posix/Unix calls through cygwin1.dll, and is
143 contrasted to Mingw32 which links dynamically to msvcrt.dll or 146 contrasted to Mingw32 which links dynamically to msvcrt.dll or
144 crtdll.dll. 147 crtdll.dll.
145 148
146 To build OpenSSL using CygWin32: 149 To build OpenSSL using Cygwin:
147 150
148 * Install CygWin32 (see http://sourceware.cygnus.com/cygwin) 151 * Install Cygwin (see http://sourceware.cygnus.com/cygwin)
149 152
150 * Install Perl and ensure it is in the path 153 * Install Perl and ensure it is in the path (recent Cygwin perl
154 (version 5.6.1-2 of the latter has been reported to work) or
155 ActivePerl)
151 156
152 * Run the CygWin bash shell 157 * Run the Cygwin bash shell
153 158
154 * $ tar zxvf openssl-x.x.x.tar.gz 159 * $ tar zxvf openssl-x.x.x.tar.gz
155 $ cd openssl-x.x.x 160 $ cd openssl-x.x.x
156 $ ./Configure no-threads CygWin32 161 $ ./config
157 [...] 162 [...]
158 $ make 163 $ make
159 [...] 164 [...]
@@ -162,27 +167,28 @@
162 167
163 This will create a default install in /usr/local/ssl. 168 This will create a default install in /usr/local/ssl.
164 169
165 CygWin32 Notes: 170 Cygwin Notes:
166 171
167 "make test" and normal file operations may fail in directories 172 "make test" and normal file operations may fail in directories
168 mounted as text (i.e. mount -t c:\somewhere /home) due to CygWin 173 mounted as text (i.e. mount -t c:\somewhere /home) due to Cygwin
169 stripping of carriage returns. To avoid this ensure that a binary 174 stripping of carriage returns. To avoid this ensure that a binary
170 mount is used, e.g. mount -b c:\somewhere /home. 175 mount is used, e.g. mount -b c:\somewhere /home.
171 176
172 As of version 1.1.1 CygWin32 is relatively unstable in its handling 177 As of version 1.1.1 Cygwin is relatively unstable in its handling
173 of cr/lf issues. These make procedures succeeded with versions 1.1 and 178 of cr/lf issues. These make procedures succeeded with versions 1.1 and
174 the snapshot 20000524 (Slow!). 179 the snapshot 20000524 (Slow!).
175 180
176 "bc" is not provided in the CygWin32 distribution. This causes a 181 "bc" is not provided in the Cygwin distribution. This causes a
177 non-fatal error in "make test" but is otherwise harmless. If 182 non-fatal error in "make test" but is otherwise harmless. If
178 desired, GNU bc can be built with CygWin32 without change. 183 desired, GNU bc can be built with Cygwin without change.
179 184
180 185
181 Installation 186 Installation
182 ------------ 187 ------------
183 188
184 There's currently no real installation procedure for Win32. There are, 189 If you used the Cygwin procedure above, you have already installed and
185 however, some suggestions: 190 can skip this section. For all other procedures, there's currently no real
191 installation procedure for Win32. There are, however, some suggestions:
186 192
187 - do nothing. The include files are found in the inc32/ subdirectory, 193 - do nothing. The include files are found in the inc32/ subdirectory,
188 all binaries are found in out32dll/ or out32/ depending if you built 194 all binaries are found in out32dll/ or out32/ depending if you built
@@ -254,5 +260,5 @@
254 malloc(), free() and realloc() as the application. However there are many 260 malloc(), free() and realloc() as the application. However there are many
255 standard library functions used by OpenSSL that call malloc() internally 261 standard library functions used by OpenSSL that call malloc() internally
256 (e.g. fopen()), and OpenSSL cannot change these; so in general you cannot 262 (e.g. fopen()), and OpenSSL cannot change these; so in general you cannot
257 rely on CYRPTO_malloc_init() solving your problem, and you should 263 rely on CRYPTO_malloc_init() solving your problem, and you should
258 consistently use the multithreaded library. 264 consistently use the multithreaded library.
diff --git a/src/lib/libssl/src/LICENSE b/src/lib/libssl/src/LICENSE
index 3fd259ac32..7b93e0dbce 100644
--- a/src/lib/libssl/src/LICENSE
+++ b/src/lib/libssl/src/LICENSE
@@ -12,7 +12,7 @@
12 --------------- 12 ---------------
13 13
14/* ==================================================================== 14/* ====================================================================
15 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. 15 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
16 * 16 *
17 * Redistribution and use in source and binary forms, with or without 17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions 18 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp b/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp
index d62dc50473..3a5e3f0186 100644
--- a/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp
+++ b/src/lib/libssl/src/MacOS/GetHTTPS.src/GetHTTPS.cpp
@@ -167,7 +167,7 @@ void main(void)
167 167
168 tempString[bytesRead] = '\0'; 168 tempString[bytesRead] = '\0';
169 169
170 printf(tempString); 170 printf("%s", tempString);
171 } 171 }
172 172
173 printf("\n\n\n"); 173 printf("\n\n\n");
@@ -201,7 +201,7 @@ EXITPOINT:
201 { 201 {
202 printf("An error occurred:\n"); 202 printf("An error occurred:\n");
203 203
204 printf(GetErrorMessage()); 204 printf("%s",GetErrorMessage());
205 } 205 }
206 206
207 207
diff --git a/src/lib/libssl/src/Makefile.org b/src/lib/libssl/src/Makefile.org
index abd4df61a2..50120ff207 100644
--- a/src/lib/libssl/src/Makefile.org
+++ b/src/lib/libssl/src/Makefile.org
@@ -24,7 +24,6 @@ INSTALLTOP=/usr/local/ssl
24# Do not edit this manually. Use Configure --openssldir=DIR do change this! 24# Do not edit this manually. Use Configure --openssldir=DIR do change this!
25OPENSSLDIR=/usr/local/ssl 25OPENSSLDIR=/usr/local/ssl
26 26
27# RSAref - Define if we are to link with RSAref.
28# NO_IDEA - Define to build without the IDEA algorithm 27# NO_IDEA - Define to build without the IDEA algorithm
29# NO_RC4 - Define to build without the RC4 algorithm 28# NO_RC4 - Define to build without the RC4 algorithm
30# NO_RC2 - Define to build without the RC2 algorithm 29# NO_RC2 - Define to build without the RC2 algorithm
@@ -67,6 +66,7 @@ RANLIB= ranlib
67PERL= perl 66PERL= perl
68TAR= tar 67TAR= tar
69TARFLAGS= --no-recursion 68TARFLAGS= --no-recursion
69MAKEDEPPROG=makedepend
70 70
71# Set BN_ASM to bn_asm.o if you want to use the C version 71# Set BN_ASM to bn_asm.o if you want to use the C version
72BN_ASM= bn_asm.o 72BN_ASM= bn_asm.o
@@ -153,20 +153,28 @@ RMD160_ASM_OBJ= asm/rm86-out.o
153#RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD 153#RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD
154#RMD160_ASM_OBJ= asm/rm86bsdi.o # bsdi 154#RMD160_ASM_OBJ= asm/rm86bsdi.o # bsdi
155 155
156# KRB5 stuff
157KRB5_INCLUDES=
158LIBKRB5=
159
156# When we're prepared to use shared libraries in the programs we link here 160# When we're prepared to use shared libraries in the programs we link here
157# we might set SHLIB_MARK to '$(SHARED_LIBS)'. 161# we might set SHLIB_MARK to '$(SHARED_LIBS)'.
158SHLIB_MARK= 162SHLIB_MARK=
159 163
160DIRS= crypto ssl rsaref $(SHLIB_MARK) apps test tools 164DIRS= crypto ssl $(SHLIB_MARK) apps test tools
161SHLIBDIRS= crypto ssl 165SHLIBDIRS= crypto ssl
162 166
163# dirs in crypto to build 167# dirs in crypto to build
164SDIRS= \ 168SDIRS= \
165 md2 md4 md5 sha mdc2 hmac ripemd \ 169 md2 md4 md5 sha mdc2 hmac ripemd \
166 des rc2 rc4 rc5 idea bf cast \ 170 des rc2 rc4 rc5 idea bf cast \
167 bn rsa dsa dh dso engine \ 171 bn ec rsa dsa dh dso engine aes \
168 buffer bio stack lhash rand err objects \ 172 buffer bio stack lhash rand err objects \
169 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp 173 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
174
175# tests to perform. "alltests" is a special word indicating that all tests
176# should be performed.
177TESTS = alltests
170 178
171MAKEFILE= Makefile.ssl 179MAKEFILE= Makefile.ssl
172MAKE= make -f Makefile.ssl 180MAKE= make -f Makefile.ssl
@@ -185,35 +193,31 @@ SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
185SHARED_SSL=libssl$(SHLIB_EXT) 193SHARED_SSL=libssl$(SHLIB_EXT)
186SHARED_LIBS= 194SHARED_LIBS=
187SHARED_LIBS_LINK_EXTS= 195SHARED_LIBS_LINK_EXTS=
196SHARED_LDFLAGS=
188 197
189GENERAL= Makefile 198GENERAL= Makefile
190BASENAME= openssl 199BASENAME= openssl
191NAME= $(BASENAME)-$(VERSION) 200NAME= $(BASENAME)-$(VERSION)
192TARFILE= $(NAME).tar 201TARFILE= $(NAME).tar
193WTARFILE= $(NAME)-win.tar 202WTARFILE= $(NAME)-win.tar
194EXHEADER= e_os.h e_os2.h 203EXHEADER= e_os2.h
195HEADER= e_os.h 204HEADER= e_os.h
196 205
197# When we're prepared to use shared libraries in the programs we link here 206# When we're prepared to use shared libraries in the programs we link here
198# we might remove 'clean-shared' from the targets to perform at this stage 207# we might remove 'clean-shared' from the targets to perform at this stage
199 208
200all: clean-shared Makefile.ssl sub_all 209all: Makefile.ssl sub_all
201 210
202sub_all: 211sub_all:
203 @for i in $(DIRS); \ 212 @for i in $(DIRS); \
204 do \ 213 do \
205 if [ -d "$$i" ]; then \ 214 if [ -d "$$i" ]; then \
206 (cd $$i && echo "making all in $$i..." && \ 215 (cd $$i && echo "making all in $$i..." && \
207 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' all ) || exit 1; \ 216 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' SHARED_LIBS='${SHARED_LIBS}' SHLIB_EXT='${SHLIB_EXT}' SHLIB_TARGET='${SHLIB_TARGET}' all ) || exit 1; \
208 else \ 217 else \
209 $(MAKE) $$i; \ 218 $(MAKE) $$i; \
210 fi; \ 219 fi; \
211 done; \ 220 done;
212 if echo "$(DIRS)" | \
213 egrep '(^| )(crypto|ssl)( |$$)' > /dev/null 2>&1 && \
214 [ -n "$(SHARED_LIBS)" ]; then \
215 $(MAKE) $(SHARED_LIBS); \
216 fi
217 221
218libcrypto$(SHLIB_EXT): libcrypto.a 222libcrypto$(SHLIB_EXT): libcrypto.a
219 @if [ "$(SHLIB_TARGET)" != "" ]; then \ 223 @if [ "$(SHLIB_TARGET)" != "" ]; then \
@@ -221,6 +225,7 @@ libcrypto$(SHLIB_EXT): libcrypto.a
221 else \ 225 else \
222 echo "There's no support for shared libraries on this platform" >&2; \ 226 echo "There's no support for shared libraries on this platform" >&2; \
223 fi 227 fi
228
224libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a 229libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
225 @if [ "$(SHLIB_TARGET)" != "" ]; then \ 230 @if [ "$(SHLIB_TARGET)" != "" ]; then \
226 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \ 231 $(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
@@ -237,19 +242,22 @@ clean-shared:
237 done; \ 242 done; \
238 fi; \ 243 fi; \
239 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \ 244 ( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
245 if [ "$(PLATFORM)" = "Cygwin" ]; then \
246 ( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
247 fi; \
240 done 248 done
241 249
242link-shared: 250link-shared:
243 @for i in $(SHLIBDIRS); do \ 251 @if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
244 prev=lib$$i$(SHLIB_EXT); \ 252 tmp="$(SHARED_LIBS_LINK_EXTS)"; \
245 if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \ 253 for i in $(SHLIBDIRS); do \
246 tmp="$(SHARED_LIBS_LINK_EXTS)"; \ 254 prev=lib$$i$(SHLIB_EXT); \
247 for j in $${tmp:-x}; do \ 255 for j in $${tmp:-x}; do \
248 ( set -x; ln -f -s $$prev lib$$i$$j ); \ 256 ( set -x; ln -f -s $$prev lib$$i$$j ); \
249 prev=lib$$i$$j; \ 257 prev=lib$$i$$j; \
250 done; \ 258 done; \
251 fi; \ 259 done; \
252 done 260 fi
253 261
254build-shared: clean-shared do_$(SHLIB_TARGET) link-shared 262build-shared: clean-shared do_$(SHLIB_TARGET) link-shared
255 263
@@ -257,29 +265,252 @@ do_bsd-gcc-shared: do_gnu-shared
257do_linux-shared: do_gnu-shared 265do_linux-shared: do_gnu-shared
258do_gnu-shared: 266do_gnu-shared:
259 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 267 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
260 ( set -x; ${CC} -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 268 ( set -x; ${CC} ${SHARED_LDFLAGS} \
261 -Wl,-S,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 269 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
270 -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
271 -Wl,-Bsymbolic \
262 -Wl,--whole-archive lib$$i.a \ 272 -Wl,--whole-archive lib$$i.a \
263 -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \ 273 -Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
264 libs="$$libs -l$$i"; \ 274 libs="$$libs -l$$i"; \
265 done 275 done
266 276
267# This assumes that GNU utilities are *not* used 277DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
268do_tru64-shared: 278 collect2=`gcc -print-prog-name=collect2 2>&1` && \
279 [ -n "$$collect2" ] && \
280 my_ld=`$$collect2 --help 2>&1 | grep Usage: | sed 's/^Usage: *\([^ ][^ ]*\).*/\1/'` && \
281 [ -n "$$my_ld" ] && \
282 $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
283
284# For Darwin AKA Mac OS/X (dyld)
285do_darwin-shared:
286 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
287 ( set -x ; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \
288 lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \
289 -compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \
290 -install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \
291 libs="$$libs -l`basename $$i${SHLIB_EXT} .dylib`"; \
292 echo "" ; \
293 done
294
295do_cygwin-shared:
269 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 296 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
270 ( set -x; ${CC} -shared -no_archive -o lib$$i.so \ 297 ( set -x; ${CC} -shared -o cyg$$i.dll \
271 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \ 298 -Wl,-Bsymbolic \
272 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \ 299 -Wl,--whole-archive lib$$i.a \
300 -Wl,--out-implib,lib$$i.dll.a \
301 -Wl,--no-whole-archive $$libs ) || exit 1; \
273 libs="$$libs -l$$i"; \ 302 libs="$$libs -l$$i"; \
274 done 303 done
275 304
276# This assumes that GNU utilities are *not* used 305# This assumes that GNU utilities are *not* used
306do_alpha-osf1-shared:
307 if ${DETECT_GNU_LD}; then \
308 $(MAKE) do_gnu-shared; \
309 else \
310 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
311 ( set -x; ${CC} ${SHARED_LDFLAGS} \
312 -shared -o lib$$i.so \
313 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
314 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
315 libs="$$libs -l$$i"; \
316 done; \
317 fi
318
319# This assumes that GNU utilities are *not* used
320# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
321# option passed to the linker.
322do_tru64-shared:
323 if ${DETECT_GNU_LD}; then \
324 $(MAKE) do_gnu-shared; \
325 else \
326 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
327 ( set -x; ${CC} ${SHARED_LDFLAGS} \
328 -shared -msym -o lib$$i.so \
329 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
330 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
331 libs="$$libs -l$$i"; \
332 done; \
333 fi
334
335# This assumes that GNU utilities are *not* used
336# The difference between tru64-shared and tru64-shared-rpath is the
337# -rpath ${INSTALLTOP}/lib passed to the linker.
338do_tru64-shared-rpath:
339 if ${DETECT_GNU_LD}; then \
340 $(MAKE) do_gnu-shared; \
341 else \
342 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
343 ( set -x; ${CC} ${SHARED_LDFLAGS} \
344 -shared -msym -o lib$$i.so \
345 -rpath ${INSTALLTOP}/lib \
346 -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
347 -all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
348 libs="$$libs -l$$i"; \
349 done; \
350 fi
351
352
353# This assumes that GNU utilities are *not* used
277do_solaris-shared: 354do_solaris-shared:
355 if ${DETECT_GNU_LD}; then \
356 $(MAKE) do_gnu-shared; \
357 else \
358 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
359 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
360 set -x; ${CC} ${SHARED_LDFLAGS} \
361 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
362 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
363 -z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
364 libs="$$libs -l$$i"; \
365 done; \
366 fi
367
368# OpenServer 5 native compilers used
369do_svr3-shared:
370 if ${DETECT_GNU_LD}; then \
371 $(MAKE) do_gnu-shared; \
372 else \
373 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
374 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
375 find . -name "*.o" -print > allobjs ; \
376 OBJS= ; export OBJS ; \
377 for obj in `ar t lib$$i.a` ; do \
378 OBJS="$${OBJS} `grep $$obj allobjs`" ; \
379 done ; \
380 set -x; ${CC} -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
381 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
382 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
383 libs="$$libs -l$$i"; \
384 done; \
385 fi
386
387# UnixWare 7 and OpenUNIX 8 native compilers used
388do_svr5-shared:
389 if ${DETECT_GNU_LD}; then \
390 $(MAKE) do_gnu-shared; \
391 else \
392 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
393 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
394 find . -name "*.o" -print > allobjs ; \
395 OBJS= ; export OBJS ; \
396 for obj in `ar t lib$$i.a` ; do \
397 OBJS="$${OBJS} `grep $$obj allobjs`" ; \
398 done ; \
399 set -x; ${CC} ${SHARED_LDFLAGS} \
400 -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
401 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
402 $${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
403 libs="$$libs -l$$i"; \
404 done; \
405 fi
406
407# This assumes that GNU utilities are *not* used
408do_irix-shared:
409 if ${DETECT_GNU_LD}; then \
410 $(MAKE) do_gnu-shared; \
411 else \
412 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
413 ( set -x; ${CC} ${SHARED_LDFLAGS} \
414 -shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
415 -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
416 -all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
417 libs="$$libs -l$$i"; \
418 done; \
419 fi
420
421# This assumes that GNU utilities are *not* used
422# HP-UX includes the full pathname of libs we depend on, so we would get
423# ./libcrypto (with ./ as path information) compiled into libssl, hence
424# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
425# anyway.
426# The object modules are loaded from lib$i.a using the undocumented -Fl
427# option.
428#
429# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
430# by temporarily specifying "+s"!
431#
432do_hpux-shared:
433 for i in ${SHLIBDIRS}; do \
434 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
435 +vnocompatwarnings \
436 -b -z +s \
437 -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
438 +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
439 -Fl lib$$i.a -ldld -lc ) || exit 1; \
440 done
441
442# This assumes that GNU utilities are *not* used
443# HP-UX includes the full pathname of libs we depend on, so we would get
444# ./libcrypto (with ./ as path information) compiled into libssl, hence
445# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
446# anyway.
447#
448# HP-UX in 64bit mode has "+s" enabled by default; it will search for
449# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
450#
451do_hpux64-shared:
452 for i in ${SHLIBDIRS}; do \
453 ( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
454 -b -z \
455 -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
456 +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
457 +forceload lib$$i.a -ldl -lc ) || exit 1; \
458 done
459
460# The following method is said to work on all platforms. Tests will
461# determine if that's how it's gong to be used.
462# This assumes that for all but GNU systems, GNU utilities are *not* used.
463# ALLSYMSFLAGS would be:
464# GNU systems: --whole-archive
465# Tru64 Unix: -all
466# Solaris: -z allextract
467# Irix: -all
468# HP/UX-32bit: -Fl
469# HP/UX-64bit: +forceload
470# AIX: -bnogc
471# SHAREDFLAGS would be:
472# GNU systems: -shared -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
473# Tru64 Unix: -shared \
474# -set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}"
475# Solaris: -G -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
476# Irix: -shared -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
477# HP/UX-32bit: +vnocompatwarnings -b -z +s \
478# +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
479# HP/UX-64bit: -b -z +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
480# AIX: -G -bE:lib$$i.exp -bM:SRE
481# SHAREDCMD would be:
482# GNU systems: $(CC)
483# Tru64 Unix: $(CC)
484# Solaris: $(CC)
485# Irix: $(CC)
486# HP/UX-32bit: /usr/ccs/bin/ld
487# HP/UX-64bit: /usr/ccs/bin/ld
488# AIX: $(CC)
489ALLSYMSFLAG=-bnogc
490SHAREDFLAGS=${SHARED_LDFLAGS} -G -bE:lib$$i.exp -bM:SRE
491SHAREDCMD=$(CC)
492do_aix-shared:
493 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
494 ( set -x; \
495 ld -r -o $$i.o $(ALLSYMSFLAG) lib$$i.a && \
496 ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \
497 $(SHAREDCMD) $(SHAREDFLAG) -o lib$$i.so lib$$i.o \
498 $$libs ${EX_LIBS} ) ) \
499 || exit 1; \
500 libs="$$libs -l$$i"; \
501 done
502
503do_reliantunix-shared:
278 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \ 504 libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
279 ( PATH=/usr/ccs/bin:$$PATH ; export PATH; \ 505 tmpdir=/tmp/openssl.$$$$ ; rm -rf $$tmpdir ; \
280 set -x; ${CC} -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 506 ( set -x; \
281 -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 507 ( Opwd=`pwd` ; mkdir $$tmpdir || exit 1; \
282 -z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \ 508 cd $$tmpdir || exit 1 ; ar x $$Opwd/lib$$i.a ; \
509 ${CC} -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} *.o \
510 ) || exit 1; \
511 cp $$tmpdir/lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} . ; \
512 ) || exit 1; \
513 rm -rf $$tmpdir ; \
283 libs="$$libs -l$$i"; \ 514 libs="$$libs -l$$i"; \
284 done 515 done
285 516
@@ -329,7 +560,7 @@ links:
329 @for i in $(DIRS); do \ 560 @for i in $(DIRS); do \
330 if [ -d "$$i" ]; then \ 561 if [ -d "$$i" ]; then \
331 (cd $$i && echo "making links in $$i..." && \ 562 (cd $$i && echo "making links in $$i..." && \
332 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' links ) || exit 1; \ 563 $(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' links ) || exit 1; \
333 fi; \ 564 fi; \
334 done; 565 done;
335 566
@@ -345,15 +576,21 @@ dclean:
345 576
346rehash: rehash.time 577rehash: rehash.time
347rehash.time: certs 578rehash.time: certs
348 @(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; $(PERL) tools/c_rehash certs) 579 @(OPENSSL="`pwd`/apps/openssl"; OPENSSL_DEBUG_MEMORY=on; \
580 export OPENSSL OPENSSL_DEBUG_MEMORY; \
581 LD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
582 export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
583 $(PERL) tools/c_rehash certs)
349 touch rehash.time 584 touch rehash.time
350 585
351test: tests 586test: tests
352 587
353tests: rehash 588tests: rehash
354 @(cd test && echo "testing..." && \ 589 @(cd test && echo "testing..." && \
355 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' EXE_EXT='${EXE_EXT}' tests ); 590 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' TESTS='${TESTS}' KRB5_INCLUDES='${KRB5_INCLUDES}' LIBKRB5='${LIBKRB5}' EXE_EXT='${EXE_EXT}' OPENSSL_DEBUG_MEMORY=on tests );
356 @apps/openssl version -a 591 @LD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; LIBPATH="`pwd`"; \
592 export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
593 apps/openssl version -a
357 594
358report: 595report:
359 @$(PERL) util/selftest.pl 596 @$(PERL) util/selftest.pl
@@ -363,7 +600,7 @@ depend:
363 do \ 600 do \
364 if [ -d "$$i" ]; then \ 601 if [ -d "$$i" ]; then \
365 (cd $$i && echo "making dependencies $$i..." && \ 602 (cd $$i && echo "making dependencies $$i..." && \
366 $(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' depend ) || exit 1; \ 603 $(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' MAKEDEPPROG='${MAKEDEPPROG}' KRB5_INCLUDES='${KRB5_INCLUDES}' depend ) || exit 1; \
367 fi; \ 604 fi; \
368 done; 605 done;
369 606
@@ -386,25 +623,26 @@ tags:
386 done; 623 done;
387 624
388errors: 625errors:
389 perl util/mkerr.pl -recurse -write 626 $(PERL) util/mkerr.pl -recurse -write
627 (cd crypto/engine; $(MAKE) PERL=$(PERL) errors)
390 628
391stacks: 629stacks:
392 perl util/mkstack.pl -write 630 $(PERL) util/mkstack.pl -write
393 631
394util/libeay.num:: 632util/libeay.num::
395 perl util/mkdef.pl crypto update 633 $(PERL) util/mkdef.pl crypto update
396 634
397util/ssleay.num:: 635util/ssleay.num::
398 perl util/mkdef.pl ssl update 636 $(PERL) util/mkdef.pl ssl update
399 637
400crypto/objects/obj_dat.h: crypto/objects/obj_mac.h crypto/objects/obj_dat.pl 638crypto/objects/obj_dat.h: crypto/objects/obj_dat.pl crypto/objects/obj_mac.h
401 perl crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h 639 $(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
402crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt 640crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num
403 perl crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h 641 $(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
404 642
405TABLE: Configure 643TABLE: Configure
406 (echo 'Output of `Configure TABLE'"':"; \ 644 (echo 'Output of `Configure TABLE'"':"; \
407 perl Configure TABLE) > TABLE 645 $(PERL) Configure TABLE) > TABLE
408 646
409update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h TABLE 647update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h TABLE
410 648
@@ -417,6 +655,14 @@ tar:
417 gzip --best >../$(TARFILE).gz; \ 655 gzip --best >../$(TARFILE).gz; \
418 ls -l ../$(TARFILE).gz 656 ls -l ../$(TARFILE).gz
419 657
658tar-snap:
659 @$(TAR) $(TARFLAGS) -cvf - \
660 `find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \! -name '*test' \! -name '.#*' \! -name '*~' | sort` |\
661 tardy --user_number=0 --user_name=openssl \
662 --group_number=0 --group_name=openssl \
663 --prefix=openssl-$(VERSION) - > ../$(TARFILE);\
664 ls -l ../$(TARFILE)
665
420dist: 666dist:
421 $(PERL) Configure dist 667 $(PERL) Configure dist
422 @$(MAKE) dist_pem_h 668 @$(MAKE) dist_pem_h
@@ -453,17 +699,25 @@ install: all install_docs
453 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 699 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
454 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \ 700 $(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
455 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ 701 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
456 fi \ 702 fi; \
457 done 703 done;
458 @if [ -n "$(SHARED_LIBS)" ]; then \ 704 @if [ -n "$(SHARED_LIBS)" ]; then \
459 tmp="$(SHARED_LIBS)"; \ 705 tmp="$(SHARED_LIBS)"; \
460 for i in $${tmp:-x}; \ 706 for i in $${tmp:-x}; \
461 do \ 707 do \
462 if [ -f "$$i" ]; then \ 708 if [ -f "$$i" -o -f "$$i.a" ]; then \
463 ( echo installing $$i; \ 709 ( echo installing $$i; \
464 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 710 if [ "$(PLATFORM)" != "Cygwin" ]; then \
465 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \ 711 cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
466 fi \ 712 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
713 else \
714 c=`echo $$i | sed 's/^lib/cyg/'`; \
715 cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
716 chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
717 cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
718 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
719 fi ); \
720 fi; \
467 done; \ 721 done; \
468 ( here="`pwd`"; \ 722 ( here="`pwd`"; \
469 cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \ 723 cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
diff --git a/src/lib/libssl/src/NEWS b/src/lib/libssl/src/NEWS
index f45d8e5ced..bf8f031a29 100644
--- a/src/lib/libssl/src/NEWS
+++ b/src/lib/libssl/src/NEWS
@@ -5,7 +5,60 @@
5 This file gives a brief overview of the major changes between each OpenSSL 5 This file gives a brief overview of the major changes between each OpenSSL
6 release. For more details please read the CHANGES file. 6 release. For more details please read the CHANGES file.
7 7
8 Changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b: 8 Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.7:
9
10 o New library section OCSP.
11 o Complete rewrite of ASN1 code.
12 o CRL checking in verify code and openssl utility.
13 o Extension copying in 'ca' utility.
14 o Flexible display options in 'ca' utility.
15 o Provisional support for international characters with UTF8.
16 o Support for external crypto devices ('engine') is no longer
17 a separate distribution.
18 o New elliptic curve library section.
19 o New AES (Rijndael) library section.
20 o Change DES API to clean up the namespace (some applications link also
21 against libdes providing similar functions having the same name).
22 Provide macros for backward compatibility (will be removed in the
23 future).
24 o Unifiy handling of cryptographic algorithms (software and
25 engine) to be available via EVP routines for asymmetric and
26 symmetric ciphers.
27 o NCONF: new configuration handling routines.
28 o Change API to use more 'const' modifiers to improve error checking
29 and help optimizers.
30 o Finally remove references to RSAref.
31 o Reworked parts of the BIGNUM code.
32 o Support for new engines: Broadcom ubsec, Accelerated Encryption
33 Processing, IBM 4758.
34 o PRNG: query at more locations for a random device, automatic query for
35 EGD style random sources at several locations.
36 o SSL/TLS: allow optional cipher choice according to server's preference.
37 o SSL/TLS: allow server to explicitly set new session ids.
38 o SSL/TLS: support Kerberos cipher suites (RFC2712).
39 o SSL/TLS: allow more precise control of renegotiations and sessions.
40 o SSL/TLS: add callback to retrieve SSL/TLS messages.
41 o SSL/TLS: add draft AES ciphersuites (disabled unless explicitly requested).
42
43 Major changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d:
44
45 o Various SSL/TLS library bugfixes.
46 o Fix DH parameter generation for 'non-standard' generators.
47
48 Major changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c:
49
50 o Various SSL/TLS library bugfixes.
51 o BIGNUM library fixes.
52 o RSA OAEP and random number generation fixes.
53 o Object identifiers corrected and added.
54 o Add assembler BN routines for IA64.
55 o Add support for OS/390 Unix, UnixWare with gcc, OpenUNIX 8,
56 MIPS Linux; shared library support for Irix, HP-UX.
57 o Add crypto accelerator support for AEP, Baltimore SureWare,
58 Broadcom and Cryptographic Appliance's keyserver
59 [in 0.9.6c-engine release].
60
61 Major changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b:
9 62
10 o Security fix: PRNG improvements. 63 o Security fix: PRNG improvements.
11 o Security fix: RSA OAEP check. 64 o Security fix: RSA OAEP check.
diff --git a/src/lib/libssl/src/README b/src/lib/libssl/src/README
index a2ede5f391..cd96ae2d40 100644
--- a/src/lib/libssl/src/README
+++ b/src/lib/libssl/src/README
@@ -1,8 +1,7 @@
1 1
2 OpenSSL 0.9.6b [engine] 9 Jul 2001 2 OpenSSL 0.9.7-dev XX xxx XXXX
3 3
4 4 Copyright (c) 1998-2002 The OpenSSL Project
5 Copyright (c) 1998-2001 The OpenSSL Project
6 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson 5 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
7 All rights reserved. 6 All rights reserved.
8 7
@@ -12,9 +11,10 @@
12 The OpenSSL Project is a collaborative effort to develop a robust, 11 The OpenSSL Project is a collaborative effort to develop a robust,
13 commercial-grade, fully featured, and Open Source toolkit implementing the 12 commercial-grade, fully featured, and Open Source toolkit implementing the
14 Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) 13 Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1)
15 protocols with full-strength cryptography world-wide. The project is managed 14 protocols as well as a full-strength general purpose cryptography library.
16 by a worldwide community of volunteers that use the Internet to communicate, 15 The project is managed by a worldwide community of volunteers that use the
17 plan, and develop the OpenSSL toolkit and its related documentation. 16 Internet to communicate, plan, and develop the OpenSSL toolkit and its
17 related documentation.
18 18
19 OpenSSL is based on the excellent SSLeay library developed from Eric A. Young 19 OpenSSL is based on the excellent SSLeay library developed from Eric A. Young
20 and Tim J. Hudson. The OpenSSL toolkit is licensed under a dual-license (the 20 and Tim J. Hudson. The OpenSSL toolkit is licensed under a dual-license (the
@@ -62,7 +62,7 @@
62 62
63 X.509v3 certificates 63 X.509v3 certificates
64 X509 encoding/decoding into/from binary ASN1 and a PEM 64 X509 encoding/decoding into/from binary ASN1 and a PEM
65 based ascii-binary encoding which supports encryption with a 65 based ASCII-binary encoding which supports encryption with a
66 private key. Program to generate RSA and DSA certificate 66 private key. Program to generate RSA and DSA certificate
67 requests and to generate RSA and DSA certificates. 67 requests and to generate RSA and DSA certificates.
68 68
@@ -97,7 +97,7 @@
97 locations around the world. _YOU_ are responsible for ensuring that your use 97 locations around the world. _YOU_ are responsible for ensuring that your use
98 of any algorithms is legal by checking if there are any patents in your 98 of any algorithms is legal by checking if there are any patents in your
99 country. The file contains some of the patents that we know about or are 99 country. The file contains some of the patents that we know about or are
100 rumoured to exist. This is not a definitive list. 100 rumored to exist. This is not a definitive list.
101 101
102 RSA Security holds software patents on the RC5 algorithm. If you 102 RSA Security holds software patents on the RC5 algorithm. If you
103 intend to use this cipher, you must contact RSA Security for 103 intend to use this cipher, you must contact RSA Security for
@@ -107,8 +107,8 @@
107 only be used with RSA Security's permission. 107 only be used with RSA Security's permission.
108 108
109 The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy, 109 The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy,
110 Japan, Netherlands, Spain, Sweden, Switzerland, UK and the USA. They should 110 Japan, the Netherlands, Spain, Sweden, Switzerland, UK and the USA. They
111 be contacted if that algorithm is to be used, their web page is 111 should be contacted if that algorithm is to be used; their web page is
112 http://www.ascom.ch/. 112 http://www.ascom.ch/.
113 113
114 INSTALLATION 114 INSTALLATION
@@ -119,8 +119,8 @@
119 INSTALL.VMS. 119 INSTALL.VMS.
120 120
121 Read the documentation in the doc/ directory. It is quite rough, but it 121 Read the documentation in the doc/ directory. It is quite rough, but it
122 lists the functions, you will probably have to look at the code to work out 122 lists the functions; you will probably have to look at the code to work out
123 how to used them. Look at the example programs. 123 how to use them. Look at the example programs.
124 124
125 SUPPORT 125 SUPPORT
126 ------- 126 -------
diff --git a/src/lib/libssl/src/README.ASN1 b/src/lib/libssl/src/README.ASN1
new file mode 100644
index 0000000000..11bcfaf4dd
--- /dev/null
+++ b/src/lib/libssl/src/README.ASN1
@@ -0,0 +1,187 @@
1
2OpenSSL ASN1 Revision
3=====================
4
5This document describes some of the issues relating to the new ASN1 code.
6
7Previous OpenSSL ASN1 problems
8=============================
9
10OK why did the OpenSSL ASN1 code need revising in the first place? Well
11there are lots of reasons some of which are included below...
12
131. The code is difficult to read and write. For every single ASN1 structure
14(e.g. SEQUENCE) four functions need to be written for new, free, encode and
15decode operations. This is a very painful and error prone operation. Very few
16people have ever written any OpenSSL ASN1 and those that have usually wish
17they hadn't.
18
192. Partly because of 1. the code is bloated and takes up a disproportionate
20amount of space. The SEQUENCE encoder is particularly bad: it essentially
21contains two copies of the same operation, one to compute the SEQUENCE length
22and the other to encode it.
23
243. The code is memory based: that is it expects to be able to read the whole
25structure from memory. This is fine for small structures but if you have a
26(say) 1Gb PKCS#7 signedData structure it isn't such a good idea...
27
284. The code for the ASN1 IMPLICIT tag is evil. It is handled by temporarily
29changing the tag to the expected one, attempting to read it, then changing it
30back again. This means that decode buffers have to be writable even though they
31are ultimately unchanged. This gets in the way of constification.
32
335. The handling of EXPLICIT isn't much better. It adds a chunk of code into
34the decoder and encoder for every EXPLICIT tag.
35
366. APPLICATION and PRIVATE tags aren't even supported at all.
37
387. Even IMPLICIT isn't complete: there is no support for implicitly tagged
39types that are not OPTIONAL.
40
418. Much of the code assumes that a tag will fit in a single octet. This is
42only true if the tag is 30 or less (mercifully tags over 30 are rare).
43
449. The ASN1 CHOICE type has to be largely handled manually, there aren't any
45macros that properly support it.
46
4710. Encoders have no concept of OPTIONAL and have no error checking. If the
48passed structure contains a NULL in a mandatory field it will not be encoded,
49resulting in an invalid structure.
50
5111. It is tricky to add ASN1 encoders and decoders to external applications.
52
53Template model
54==============
55
56One of the major problems with revision is the sheer volume of the ASN1 code.
57Attempts to change (for example) the IMPLICIT behaviour would result in a
58modification of *every* single decode function.
59
60I decided to adopt a template based approach. I'm using the term 'template'
61in a manner similar to SNACC templates: it has nothing to do with C++
62templates.
63
64A template is a description of an ASN1 module as several constant C structures.
65It describes in a machine readable way exactly how the ASN1 structure should
66behave. If this template contains enough detail then it is possible to write
67versions of new, free, encode, decode (and possibly others operations) that
68operate on templates.
69
70Instead of having to write code to handle each operation only a single
71template needs to be written. If new operations are needed (such as a 'print'
72operation) only a single new template based function needs to be written
73which will then automatically handle all existing templates.
74
75Plans for revision
76==================
77
78The revision will consist of the following steps. Other than the first two
79these can be handled in any order.
80
81o Design and write template new, free, encode and decode operations, initially
82memory based. *DONE*
83
84o Convert existing ASN1 code to template form. *IN PROGRESS*
85
86o Convert an existing ASN1 compiler (probably SNACC) to output templates
87in OpenSSL form.
88
89o Add support for BIO based ASN1 encoders and decoders to handle large
90structures, initially blocking I/O.
91
92o Add support for non blocking I/O: this is quite a bit harder than blocking
93I/O.
94
95o Add new ASN1 structures, such as OCSP, CRMF, S/MIME v3 (CMS), attribute
96certificates etc etc.
97
98Description of major changes
99============================
100
101The BOOLEAN type now takes three values. 0xff is TRUE, 0 is FALSE and -1 is
102absent. The meaning of absent depends on the context. If for example the
103boolean type is DEFAULT FALSE (as in the case of the critical flag for
104certificate extensions) then -1 is FALSE, if DEFAULT TRUE then -1 is TRUE.
105Usually the value will only ever be read via an API which will hide this from
106an application.
107
108There is an evil bug in the old ASN1 code that mishandles OPTIONAL with
109SEQUENCE OF or SET OF. These are both implemented as a STACK structure. The
110old code would omit the structure if the STACK was NULL (which is fine) or if
111it had zero elements (which is NOT OK). This causes problems because an empty
112SEQUENCE OF or SET OF will result in an empty STACK when it is decoded but when
113it is encoded it will be omitted resulting in different encodings. The new code
114only omits the encoding if the STACK is NULL, if it contains zero elements it
115is encoded and empty. There is an additional problem though: because an empty
116STACK was omitted, sometimes the corresponding *_new() function would
117initialize the STACK to empty so an application could immediately use it, if
118this is done with the new code (i.e. a NULL) it wont work. Therefore a new
119STACK should be allocated first. One instance of this is the X509_CRL list of
120revoked certificates: a helper function X509_CRL_add0_revoked() has been added
121for this purpose.
122
123The X509_ATTRIBUTE structure used to have an element called 'set' which took
124the value 1 if the attribute value was a SET OF or 0 if it was a single. Due
125to the behaviour of CHOICE in the new code this has been changed to a field
126called 'single' which is 0 for a SET OF and 1 for single. The old field has
127been deleted to deliberately break source compatibility. Since this structure
128is normally accessed via higher level functions this shouldn't break too much.
129
130The X509_REQ_INFO certificate request info structure no longer has a field
131called 'req_kludge'. This used to be set to 1 if the attributes field was
132(incorrectly) omitted. You can check to see if the field is omitted now by
133checking if the attributes field is NULL. Similarly if you need to omit
134the field then free attributes and set it to NULL.
135
136The top level 'detached' field in the PKCS7 structure is no longer set when
137a PKCS#7 structure is read in. PKCS7_is_detached() should be called instead.
138The behaviour of PKCS7_get_detached() is unaffected.
139
140The values of 'type' in the GENERAL_NAME structure have changed. This is
141because the old code use the ASN1 initial octet as the selector. The new
142code uses the index in the ASN1_CHOICE template.
143
144The DIST_POINT_NAME structure has changed to be a true CHOICE type.
145
146typedef struct DIST_POINT_NAME_st {
147int type;
148union {
149 STACK_OF(GENERAL_NAME) *fullname;
150 STACK_OF(X509_NAME_ENTRY) *relativename;
151} name;
152} DIST_POINT_NAME;
153
154This means that name.fullname or name.relativename should be set
155and type reflects the option. That is if name.fullname is set then
156type is 0 and if name.relativename is set type is 1.
157
158With the old code using the i2d functions would typically involve:
159
160unsigned char *buf, *p;
161int len;
162/* Find length of encoding */
163len = i2d_SOMETHING(x, NULL);
164/* Allocate buffer */
165buf = OPENSSL_malloc(len);
166if(buf == NULL) {
167 /* Malloc error */
168}
169/* Use temp variable because &p gets updated to point to end of
170 * encoding.
171 */
172p = buf;
173i2d_SOMETHING(x, &p);
174
175
176Using the new i2d you can also do:
177
178unsigned char *buf = NULL;
179int len;
180len = i2d_SOMETHING(x, &buf);
181if(len < 0) {
182 /* Malloc error */
183}
184
185and it will automatically allocate and populate a buffer with the
186encoding. After this call 'buf' will point to the start of the
187encoding which is len bytes long.
diff --git a/src/lib/libssl/src/README.ENGINE b/src/lib/libssl/src/README.ENGINE
index 3d88ed152f..643d0cb51f 100644
--- a/src/lib/libssl/src/README.ENGINE
+++ b/src/lib/libssl/src/README.ENGINE
@@ -1,63 +1,289 @@
1
2 ENGINE 1 ENGINE
3 ====== 2 ======
4 3
5 With OpenSSL 0.9.6, a new component has been added to support external 4 With OpenSSL 0.9.6, a new component was added to support alternative
6 crypto devices, for example accelerator cards. The component is called 5 cryptography implementations, most commonly for interfacing with external
7 ENGINE, and has still a pretty experimental status and almost no 6 crypto devices (eg. accelerator cards). This component is called ENGINE,
8 documentation. It's designed to be faily easily extensible by the 7 and its presence in OpenSSL 0.9.6 (and subsequent bug-fix releases)
9 calling programs. 8 caused a little confusion as 0.9.6** releases were rolled in two
9 versions, a "standard" and an "engine" version. In development for 0.9.7,
10 the ENGINE code has been merged into the main branch and will be present
11 in the standard releases from 0.9.7 forwards.
10 12
11 There's currently built-in support for the following crypto devices: 13 There are currently built-in ENGINE implementations for the following
14 crypto devices:
12 15
13 o CryptoSwift 16 o CryptoSwift
14 o Compaq Atalla 17 o Compaq Atalla
15 o nCipher CHIL 18 o nCipher CHIL
19 o Nuron
20 o Broadcom uBSec
21
22 In addition, dynamic binding to external ENGINE implementations is now
23 provided by a special ENGINE called "dynamic". See the "DYNAMIC ENGINE"
24 section below for details.
25
26 At this stage, a number of things are still needed and are being worked on:
27
28 1 Integration of EVP support.
29 2 Configuration support.
30 3 Documentation!
31
321 With respect to EVP, this relates to support for ciphers and digests in
33 the ENGINE model so that alternative implementations of existing
34 algorithms/modes (or previously unimplemented ones) can be provided by
35 ENGINE implementations.
16 36
17 A number of things are still needed and are being worked on: 372 Configuration support currently exists in the ENGINE API itself, in the
38 form of "control commands". These allow an application to expose to the
39 user/admin the set of commands and parameter types a given ENGINE
40 implementation supports, and for an application to directly feed string
41 based input to those ENGINEs, in the form of name-value pairs. This is an
42 extensible way for ENGINEs to define their own "configuration" mechanisms
43 that are specific to a given ENGINE (eg. for a particular hardware
44 device) but that should be consistent across *all* OpenSSL-based
45 applications when they use that ENGINE. Work is in progress (or at least
46 in planning) for supporting these control commands from the CONF (or
47 NCONF) code so that applications using OpenSSL's existing configuration
48 file format can have ENGINE settings specified in much the same way.
49 Presently however, applications must use the ENGINE API itself to provide
50 such functionality. To see first hand the types of commands available
51 with the various compiled-in ENGINEs (see further down for dynamic
52 ENGINEs), use the "engine" openssl utility with full verbosity, ie;
53 openssl engine -vvvv
18 54
19 o An openssl utility command to handle or at least check available 553 Documentation? Volunteers welcome! The source code is reasonably well
20 engines. 56 self-documenting, but some summaries and usage instructions are needed -
21 o A better way of handling the methods that are handled by the 57 moreover, they are needed in the same POD format the existing OpenSSL
22 engines. 58 documentation is provided in. Any complete or incomplete contributions
23 o Documentation! 59 would help make this happen.
60
61 STABILITY & BUG-REPORTS
62 =======================
24 63
25 What already exists is fairly stable as far as it has been tested, but 64 What already exists is fairly stable as far as it has been tested, but
26 the test base has been a bit small most of the time. 65 the test base has been a bit small most of the time. For the most part,
66 the vendors of the devices these ENGINEs support have contributed to the
67 development and/or testing of the implementations, and *usually* (with no
68 guarantees) have experience in using the ENGINE support to drive their
69 devices from common OpenSSL-based applications. Bugs and/or inexplicable
70 behaviour in using a specific ENGINE implementation should be sent to the
71 author of that implementation (if it is mentioned in the corresponding C
72 file), and in the case of implementations for commercial hardware
73 devices, also through whatever vendor support channels are available. If
74 none of this is possible, or the problem seems to be something about the
75 ENGINE API itself (ie. not necessarily specific to a particular ENGINE
76 implementation) then you should mail complete details to the relevant
77 OpenSSL mailing list. For a definition of "complete details", refer to
78 the OpenSSL "README" file. As for which list to send it to;
27 79
28 Because of this experimental status and what's lacking, the ENGINE 80 openssl-users: if you are *using* the ENGINE abstraction, either in an
29 component is not yet part of the default OpenSSL distribution. However, 81 pre-compiled application or in your own application code.
30 we have made a separate kit for those who want to try this out, to be
31 found in the same places as the default OpenSSL distribution, but with
32 "-engine-" being part of the kit file name. For example, version 0.9.6
33 is distributed in the following two files:
34 82
35 openssl-0.9.6.tar.gz 83 openssl-dev: if you are discussing problems with OpenSSL source code.
36 openssl-engine-0.9.6.tar.gz
37 84
38 NOTES 85 USAGE
39 ===== 86 =====
40 87
41 openssl-engine-0.9.6.tar.gz does not depend on openssl-0.9.6.tar, you do 88 The default "openssl" ENGINE is always chosen when performing crypto
42 not need to download both. 89 operations unless you specify otherwise. You must actively tell the
90 openssl utility commands to use anything else through a new command line
91 switch called "-engine". Also, if you want to use the ENGINE support in
92 your own code to do something similar, you must likewise explicitly
93 select the ENGINE implementation you want.
94
95 Depending on the type of hardware, system, and configuration, "settings"
96 may need to be applied to an ENGINE for it to function as expected/hoped.
97 The recommended way of doing this is for the application to support
98 ENGINE "control commands" so that each ENGINE implementation can provide
99 whatever configuration primitives it might require and the application
100 can allow the user/admin (and thus the hardware vendor's support desk
101 also) to provide any such input directly to the ENGINE implementation.
102 This way, applications do not need to know anything specific to any
103 device, they only need to provide the means to carry such user/admin
104 input through to the ENGINE in question. Ie. this connects *you* (and
105 your helpdesk) to the specific ENGINE implementation (and device), and
106 allows application authors to not get buried in hassle supporting
107 arbitrary devices they know (and care) nothing about.
108
109 A new "openssl" utility, "openssl engine", has been added in that allows
110 for testing and examination of ENGINE implementations. Basic usage
111 instructions are available by specifying the "-?" command line switch.
112
113 DYNAMIC ENGINES
114 ===============
115
116 The new "dynamic" ENGINE provides a low-overhead way to support ENGINE
117 implementations that aren't pre-compiled and linked into OpenSSL-based
118 applications. This could be because existing compiled-in implementations
119 have known problems and you wish to use a newer version with an existing
120 application. It could equally be because the application (or OpenSSL
121 library) you are using simply doesn't have support for the ENGINE you
122 wish to use, and the ENGINE provider (eg. hardware vendor) is providing
123 you with a self-contained implementation in the form of a shared-library.
124 The other use-case for "dynamic" is with applications that wish to
125 maintain the smallest foot-print possible and so do not link in various
126 ENGINE implementations from OpenSSL, but instead leaves you to provide
127 them, if you want them, in the form of "dynamic"-loadable
128 shared-libraries. It should be possible for hardware vendors to provide
129 their own shared-libraries to support arbitrary hardware to work with
130 applications based on OpenSSL 0.9.7 or later. If you're using an
131 application based on 0.9.7 (or later) and the support you desire is only
132 announced for versions later than the one you need, ask the vendor to
133 backport their ENGINE to the version you need.
134
135 How does "dynamic" work?
136 ------------------------
137 The dynamic ENGINE has a special flag in its implementation such that
138 every time application code asks for the 'dynamic' ENGINE, it in fact
139 gets its own copy of it. As such, multi-threaded code (or code that
140 multiplexes multiple uses of 'dynamic' in a single application in any
141 way at all) does not get confused by 'dynamic' being used to do many
142 independent things. Other ENGINEs typically don't do this so there is
143 only ever 1 ENGINE structure of its type (and reference counts are used
144 to keep order). The dynamic ENGINE itself provides absolutely no
145 cryptographic functionality, and any attempt to "initialise" the ENGINE
146 automatically fails. All it does provide are a few "control commands"
147 that can be used to control how it will load an external ENGINE
148 implementation from a shared-library. To see these control commands,
149 use the command-line;
150
151 openssl engine -vvvv dynamic
152
153 The "SO_PATH" control command should be used to identify the
154 shared-library that contains the ENGINE implementation, and "NO_VCHECK"
155 might possibly be useful if there is a minor version conflict and you
156 (or a vendor helpdesk) is convinced you can safely ignore it.
157 "ENGINE_ID" is probably only needed if a shared-library implements
158 multiple ENGINEs, but if you know the engine id you expect to be using,
159 it doesn't hurt to specify it (and this provides a sanity check if
160 nothing else). "LIST_ADD" is only required if you actually wish the
161 loaded ENGINE to be discoverable by application code later on using the
162 ENGINE's "id". For most applications, this isn't necessary - but some
163 application authors may have nifty reasons for using it. The "LOAD"
164 command is the only one that takes no parameters and is the command
165 that uses the settings from any previous commands to actually *load*
166 the shared-library ENGINE implementation. If this command succeeds, the
167 (copy of the) 'dynamic' ENGINE will magically morph into the ENGINE
168 that has been loaded from the shared-library. As such, any control
169 commands supported by the loaded ENGINE could then be executed as per
170 normal. Eg. if ENGINE "foo" is implemented in the shared-library
171 "libfoo.so" and it supports some special control command "CMD_FOO", the
172 following code would load and use it (NB: obviously this code has no
173 error checking);
174
175 ENGINE *e = ENGINE_by_id("dynamic");
176 ENGINE_ctrl_cmd_string(e, "SO_PATH", "/lib/libfoo.so", 0);
177 ENGINE_ctrl_cmd_string(e, "ENGINE_ID", "foo", 0);
178 ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
179 ENGINE_ctrl_cmd_string(e, "CMD_FOO", "some input data", 0);
180
181 For testing, the "openssl engine" utility can be useful for this sort
182 of thing. For example the above code excerpt would achieve much the
183 same result as;
184
185 openssl engine dynamic \
186 -pre SO_PATH:/lib/libfoo.so \
187 -pre ENGINE_ID:foo \
188 -pre LOAD \
189 -pre "CMD_FOO:some input data"
190
191 Or to simply see the list of commands supported by the "foo" ENGINE;
192
193 openssl engine -vvvv dynamic \
194 -pre SO_PATH:/lib/libfoo.so \
195 -pre ENGINE_ID:foo \
196 -pre LOAD
197
198 Applications that support the ENGINE API and more specifically, the
199 "control commands" mechanism, will provide some way for you to pass
200 such commands through to ENGINEs. As such, you would select "dynamic"
201 as the ENGINE to use, and the parameters/commands you pass would
202 control the *actual* ENGINE used. Each command is actually a name-value
203 pair and the value can sometimes be omitted (eg. the "LOAD" command).
204 Whilst the syntax demonstrated in "openssl engine" uses a colon to
205 separate the command name from the value, applications may provide
206 their own syntax for making that separation (eg. a win32 registry
207 key-value pair may be used by some applications). The reason for the
208 "-pre" syntax in the "openssl engine" utility is that some commands
209 might be issued to an ENGINE *after* it has been initialised for use.
210 Eg. if an ENGINE implementation requires a smart-card to be inserted
211 during initialisation (or a PIN to be typed, or whatever), there may be
212 a control command you can issue afterwards to "forget" the smart-card
213 so that additional initialisation is no longer possible. In
214 applications such as web-servers, where potentially volatile code may
215 run on the same host system, this may provide some arguable security
216 value. In such a case, the command would be passed to the ENGINE after
217 it has been initialised for use, and so the "-post" switch would be
218 used instead. Applications may provide a different syntax for
219 supporting this distinction, and some may simply not provide it at all
220 ("-pre" is almost always what you're after, in reality).
43 221
44 openssl-engine-0.9.6.tar.gz is usable even if you don't have an external 222 How do I build a "dynamic" ENGINE?
45 crypto device. The internal OpenSSL functions are contained in the 223 ----------------------------------
46 engine "openssl", and will be used by default. 224 This question is trickier - currently OpenSSL bundles various ENGINE
225 implementations that are statically built in, and any application that
226 calls the "ENGINE_load_builtin_engines()" function will automatically
227 have all such ENGINEs available (and occupying memory). Applications
228 that don't call that function have no ENGINEs available like that and
229 would have to use "dynamic" to load any such ENGINE - but on the other
230 hand such applications would only have the memory footprint of any
231 ENGINEs explicitly loaded using user/admin provided control commands.
232 The main advantage of not statically linking ENGINEs and only using
233 "dynamic" for hardware support is that any installation using no
234 "external" ENGINE suffers no unnecessary memory footprint from unused
235 ENGINEs. Likewise, installations that do require an ENGINE incur the
236 overheads from only *that* ENGINE once it has been loaded.
47 237
48 No external crypto device is chosen unless you say so. You have actively 238 Sounds good? Maybe, but currently building an ENGINE implementation as
49 tell the openssl utility commands to use it through a new command line 239 a shared-library that can be loaded by "dynamic" isn't automated in
50 switch called "-engine". And if you want to use the ENGINE library to 240 OpenSSL's build process. It can be done manually quite easily however.
51 do something similar, you must also explicitely choose an external crypto 241 Such a shared-library can either be built with any OpenSSL code it
52 device, or the built-in crypto routines will be used, just as in the 242 needs statically linked in, or it can link dynamically against OpenSSL
53 default OpenSSL distribution. 243 if OpenSSL itself is built as a shared library. The instructions are
244 the same in each case, but in the former (statically linked any
245 dependencies on OpenSSL) you must ensure OpenSSL is built with
246 position-independent code ("PIC"). The default OpenSSL compilation may
247 already specify the relevant flags to do this, but you should consult
248 with your compiler documentation if you are in any doubt.
54 249
250 This example will show building the "atalla" ENGINE in the
251 crypto/engine/ directory as a shared-library for use via the "dynamic"
252 ENGINE.
253 1) "cd" to the crypto/engine/ directory of a pre-compiled OpenSSL
254 source tree.
255 2) Recompile at least one source file so you can see all the compiler
256 flags (and syntax) being used to build normally. Eg;
257 touch hw_atalla.c ; make
258 will rebuild "hw_atalla.o" using all such flags.
259 3) Manually enter the same compilation line to compile the
260 "hw_atalla.c" file but with the following two changes;
261 (a) add "-DENGINE_DYNAMIC_SUPPORT" to the command line switches,
262 (b) change the output file from "hw_atalla.o" to something new,
263 eg. "tmp_atalla.o"
264 4) Link "tmp_atalla.o" into a shared-library using the top-level
265 OpenSSL libraries to resolve any dependencies. The syntax for doing
266 this depends heavily on your system/compiler and is a nightmare
267 known well to anyone who has worked with shared-library portability
268 before. 'gcc' on Linux, for example, would use the following syntax;
269 gcc -shared -o dyn_atalla.so tmp_atalla.o -L../.. -lcrypto
270 5) Test your shared library using "openssl engine" as explained in the
271 previous section. Eg. from the top-level directory, you might try;
272 apps/openssl engine -vvvv dynamic \
273 -pre SO_PATH:./crypto/engine/dyn_atalla.so -pre LOAD
274 If the shared-library loads successfully, you will see both "-pre"
275 commands marked as "SUCCESS" and the list of control commands
276 displayed (because of "-vvvv") will be the control commands for the
277 *atalla* ENGINE (ie. *not* the 'dynamic' ENGINE). You can also add
278 the "-t" switch to the utility if you want it to try and initialise
279 the atalla ENGINE for use to test any possible hardware/driver
280 issues.
55 281
56 PROBLEMS 282 PROBLEMS
57 ======== 283 ========
58 284
59 It seems like the ENGINE part doesn't work too well with Cryptoswift on 285 It seems like the ENGINE part doesn't work too well with CryptoSwift on Win32.
60 Win32. A quick test done right before the release showed that trying 286 A quick test done right before the release showed that trying "openssl speed
61 "openssl speed -engine cswift" generated errors. If the DSO gets enabled, 287 -engine cswift" generated errors. If the DSO gets enabled, an attempt is made
62 an attempt is made to write at memory address 0x00000002. 288 to write at memory address 0x00000002.
63 289
diff --git a/src/lib/libssl/src/STATUS b/src/lib/libssl/src/STATUS
new file mode 100644
index 0000000000..3438215ee7
--- /dev/null
+++ b/src/lib/libssl/src/STATUS
@@ -0,0 +1,114 @@
1
2 OpenSSL STATUS Last modified at
3 ______________ $Date: 2002/05/15 02:29:08 $
4
5 DEVELOPMENT STATE
6
7 o OpenSSL 0.9.7: Under development...
8 o OpenSSL 0.9.6c: Released on December 21st, 2001
9 o OpenSSL 0.9.6b: Released on July 9th, 2001
10 o OpenSSL 0.9.6a: Released on April 5th, 2001
11 o OpenSSL 0.9.6: Released on September 24th, 2000
12 o OpenSSL 0.9.5a: Released on April 1st, 2000
13 o OpenSSL 0.9.5: Released on February 28th, 2000
14 o OpenSSL 0.9.4: Released on August 09th, 1999
15 o OpenSSL 0.9.3a: Released on May 29th, 1999
16 o OpenSSL 0.9.3: Released on May 25th, 1999
17 o OpenSSL 0.9.2b: Released on March 22th, 1999
18 o OpenSSL 0.9.1c: Released on December 23th, 1998
19
20 RELEASE SHOWSTOPPERS
21
22 o BIGNUM library failures on 64-bit platforms (0.9.7-dev):
23 - BN_mod_mul verificiation (bc) fails for solaris64-sparcv9-cc
24 and other 64-bit platforms
25
26 Checked on Result
27 alpha-cc (Tru64 version 4.0) works
28 linux-alpha+bwx-gcc doesn't work. Reported by
29 Sean O'Riordain <seanpor@acm.org>
30 OpenBSD-sparc64 doesn't work. BN_mod_mul breaks.
31
32 Needs checked on
33 [add platforms here]
34
35 - BN_mod_mul verification fails for mips3-sgi-irix
36 unless configured with no-asm
37
38 AVAILABLE PATCHES
39
40 o
41
42 IN PROGRESS
43
44 o Steve is currently working on (in no particular order):
45 ASN1 code redesign, butchery, replacement.
46 OCSP
47 EVP cipher enhancement.
48 Enhanced certificate chain verification.
49 Private key, certificate and CRL API and implementation.
50 Developing and bugfixing PKCS#7 (S/MIME code).
51 Various X509 issues: character sets, certificate request extensions.
52 o Geoff and Richard are currently working on:
53 ENGINE (the new code that gives hardware support among others).
54 o Richard is currently working on:
55 UI (User Interface)
56 UTIL (a new set of library functions to support some higher level
57 functionality that is currently missing).
58 Shared library support for VMS.
59 Kerberos 5 authentication
60 Constification
61 OCSP
62
63 NEEDS PATCH
64
65 o apps/ca.c: "Sign the certificate?" - "n" creates empty certificate file
66
67 o "OpenSSL STATUS" is never up-to-date.
68
69 OPEN ISSUES
70
71 o Do we want the EVP API changes in 0.9.7?
72 Can compatibility be improved?
73
74 o The Makefile hierarchy and build mechanism is still not a round thing:
75
76 1. The config vs. Configure scripts
77 It's the same nasty situation as for Apache with APACI vs.
78 src/Configure. It confuses.
79 Suggestion: Merge Configure and config into a single configure
80 script with a Autoconf style interface ;-) and remove
81 Configure and config. Or even let us use GNU Autoconf
82 itself. Then we can avoid a lot of those platform checks
83 which are currently in Configure.
84
85 o Support for Shared Libraries has to be added at least
86 for the major Unix platforms. The details we can rip from the stuff
87 Ralf has done for the Apache src/Configure script. Ben wants the
88 solution to be really simple.
89
90 Status: Ralf will look how we can easily incorporate the
91 compiler PIC and linker DSO flags from Apache
92 into the OpenSSL Configure script.
93
94 Ulf: +1 for using GNU autoconf and libtool (but not automake,
95 which apparently is not flexible enough to generate
96 libcrypto)
97
98 WISHES
99
100 o Add variants of DH_generate_parameters() and BN_generate_prime() [etc?]
101 where the callback function can request that the function be aborted.
102 [Gregory Stark <ghstark@pobox.com>, <rayyang2000@yahoo.com>]
103
104 o SRP in TLS.
105 [wished by:
106 Dj <derek@yo.net>, Tom Wu <tom@arcot.com>,
107 Tom Holroyd <tomh@po.crl.go.jp>]
108
109 See http://search.ietf.org/internet-drafts/draft-ietf-tls-srp-00.txt
110 as well as http://www-cs-students.stanford.edu/~tjw/srp/.
111
112 Tom Holroyd tells us there is a SRP patch for OpenSSH at
113 http://members.tripod.com/professor_tom/archives/, that could
114 be useful.
diff --git a/src/lib/libssl/src/TABLE b/src/lib/libssl/src/TABLE
new file mode 100644
index 0000000000..8ca5309e4d
--- /dev/null
+++ b/src/lib/libssl/src/TABLE
@@ -0,0 +1,3912 @@
1
2*** BC-16
3$cc = bcc
4$cflags =
5$unistd =
6$thread_cflag = (unknown)
7$sys_id = WIN16
8$lflags =
9$bn_ops = BN_LLONG DES_PTR RC4_INDEX SIXTEEN_BIT
10$bn_obj =
11$des_obj =
12$bf_obj =
13$md5_obj =
14$sha1_obj =
15$cast_obj =
16$rc4_obj =
17$rmd160_obj =
18$rc5_obj =
19$dso_scheme =
20$shared_target=
21$shared_cflag =
22$shared_ldflag =
23$shared_extension =
24$ranlib =
25
26*** BC-32
27$cc = bcc32
28$cflags =
29$unistd =
30$thread_cflag =
31$sys_id = WIN32
32$lflags =
33$bn_ops = BN_LLONG DES_PTR RC4_INDEX
34$bn_obj =
35$des_obj =
36$bf_obj =
37$md5_obj =
38$sha1_obj =
39$cast_obj =
40$rc4_obj =
41$rmd160_obj =
42$rc5_obj =
43$dso_scheme = win32
44$shared_target=
45$shared_cflag =
46$shared_ldflag =
47$shared_extension =
48$ranlib =
49
50*** BS2000-OSD
51$cc = c89
52$cflags = -O -XLLML -XLLMK -XL -DB_ENDIAN -DTERMIOS -DCHARSET_EBCDIC
53$unistd =
54$thread_cflag = (unknown)
55$sys_id =
56$lflags = -lsocket -lnsl
57$bn_ops = THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR
58$bn_obj =
59$des_obj =
60$bf_obj =
61$md5_obj =
62$sha1_obj =
63$cast_obj =
64$rc4_obj =
65$rmd160_obj =
66$rc5_obj =
67$dso_scheme =
68$shared_target=
69$shared_cflag =
70$shared_ldflag =
71$shared_extension =
72$ranlib =
73
74*** Cygwin
75$cc = gcc
76$cflags = -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
77$unistd =
78$thread_cflag =
79$sys_id = CYGWIN32
80$lflags =
81$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
82$bn_obj =
83$des_obj =
84$bf_obj =
85$md5_obj =
86$sha1_obj =
87$cast_obj =
88$rc4_obj =
89$rmd160_obj =
90$rc5_obj =
91$dso_scheme = win32
92$shared_target= cygwin-shared
93$shared_cflag =
94$shared_ldflag =
95$shared_extension = .dll
96$ranlib =
97
98*** Cygwin-pre1.3
99$cc = gcc
100$cflags = -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
101$unistd =
102$thread_cflag = (unknown)
103$sys_id = CYGWIN32
104$lflags =
105$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
106$bn_obj =
107$des_obj =
108$bf_obj =
109$md5_obj =
110$sha1_obj =
111$cast_obj =
112$rc4_obj =
113$rmd160_obj =
114$rc5_obj =
115$dso_scheme = win32
116$shared_target=
117$shared_cflag =
118$shared_ldflag =
119$shared_extension =
120$ranlib =
121
122*** FreeBSD
123$cc = gcc
124$cflags = -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
125$unistd =
126$thread_cflag = (unknown)
127$sys_id =
128$lflags =
129$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
130$bn_obj = asm/bn86-out.o asm/co86-out.o
131$des_obj = asm/dx86-out.o asm/yx86-out.o
132$bf_obj = asm/bx86-out.o
133$md5_obj = asm/mx86-out.o
134$sha1_obj = asm/sx86-out.o
135$cast_obj = asm/cx86-out.o
136$rc4_obj = asm/rx86-out.o
137$rmd160_obj = asm/rm86-out.o
138$rc5_obj = asm/r586-out.o
139$dso_scheme =
140$shared_target=
141$shared_cflag =
142$shared_ldflag =
143$shared_extension =
144$ranlib =
145
146*** FreeBSD-alpha
147$cc = gcc
148$cflags = -DTERMIOS -O -fomit-frame-pointer
149$unistd =
150$thread_cflag = (unknown)
151$sys_id =
152$lflags =
153$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2
154$bn_obj =
155$des_obj =
156$bf_obj =
157$md5_obj =
158$sha1_obj =
159$cast_obj =
160$rc4_obj =
161$rmd160_obj =
162$rc5_obj =
163$dso_scheme = dlfcn
164$shared_target= bsd-gcc-shared
165$shared_cflag = -fPIC
166$shared_ldflag =
167$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
168$ranlib =
169
170*** FreeBSD-elf
171$cc = gcc
172$cflags = -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
173$unistd =
174$thread_cflag = -pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE
175$sys_id =
176$lflags =
177$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
178$bn_obj = asm/bn86-elf.o asm/co86-elf.o
179$des_obj = asm/dx86-elf.o asm/yx86-elf.o
180$bf_obj = asm/bx86-elf.o
181$md5_obj = asm/mx86-elf.o
182$sha1_obj = asm/sx86-elf.o
183$cast_obj = asm/cx86-elf.o
184$rc4_obj = asm/rx86-elf.o
185$rmd160_obj = asm/rm86-elf.o
186$rc5_obj = asm/r586-elf.o
187$dso_scheme = dlfcn
188$shared_target= bsd-gcc-shared
189$shared_cflag = -fPIC
190$shared_ldflag =
191$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
192$ranlib =
193
194*** MPE/iX-gcc
195$cc = gcc
196$cflags = -D_ENDIAN -DBN_DIV2W -O3 -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB
197$unistd =
198$thread_cflag = (unknown)
199$sys_id = MPE
200$lflags = -L/SYSLOG/PUB -lsyslog -lsocket -lcurses
201$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
202$bn_obj =
203$des_obj =
204$bf_obj =
205$md5_obj =
206$sha1_obj =
207$cast_obj =
208$rc4_obj =
209$rmd160_obj =
210$rc5_obj =
211$dso_scheme =
212$shared_target=
213$shared_cflag =
214$shared_ldflag =
215$shared_extension =
216$ranlib =
217
218*** Mingw32
219$cc = gcc
220$cflags = -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
221$unistd =
222$thread_cflag =
223$sys_id =
224$lflags =
225$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
226$bn_obj =
227$des_obj =
228$bf_obj =
229$md5_obj =
230$sha1_obj =
231$cast_obj =
232$rc4_obj =
233$rmd160_obj =
234$rc5_obj =
235$dso_scheme = win32
236$shared_target=
237$shared_cflag =
238$shared_ldflag =
239$shared_extension =
240$ranlib =
241
242*** NetBSD-m68
243$cc = gcc
244$cflags = -DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN
245$unistd =
246$thread_cflag = (unknown)
247$sys_id =
248$lflags =
249$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL
250$bn_obj =
251$des_obj =
252$bf_obj =
253$md5_obj =
254$sha1_obj =
255$cast_obj =
256$rc4_obj =
257$rmd160_obj =
258$rc5_obj =
259$dso_scheme = dlfcn
260$shared_target= bsd-gcc-shared
261$shared_cflag = -fPIC
262$shared_ldflag =
263$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
264$ranlib =
265
266*** NetBSD-sparc
267$cc = gcc
268$cflags = -DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN
269$unistd =
270$thread_cflag = (unknown)
271$sys_id =
272$lflags =
273$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL
274$bn_obj =
275$des_obj =
276$bf_obj =
277$md5_obj =
278$sha1_obj =
279$cast_obj =
280$rc4_obj =
281$rmd160_obj =
282$rc5_obj =
283$dso_scheme = dlfcn
284$shared_target= bsd-gcc-shared
285$shared_cflag = -fPIC
286$shared_ldflag =
287$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
288$ranlib =
289
290*** NetBSD-x86
291$cc = gcc
292$cflags = -DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall
293$unistd =
294$thread_cflag = (unknown)
295$sys_id =
296$lflags =
297$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
298$bn_obj =
299$des_obj =
300$bf_obj =
301$md5_obj =
302$sha1_obj =
303$cast_obj =
304$rc4_obj =
305$rmd160_obj =
306$rc5_obj =
307$dso_scheme = dlfcn
308$shared_target= bsd-gcc-shared
309$shared_cflag = -fPIC
310$shared_ldflag =
311$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
312$ranlib =
313
314*** OS2-EMX
315$cc = gcc
316$cflags =
317$unistd =
318$thread_cflag =
319$sys_id =
320$lflags =
321$bn_ops =
322$bn_obj =
323$des_obj =
324$bf_obj =
325$md5_obj =
326$sha1_obj =
327$cast_obj =
328$rc4_obj =
329$rmd160_obj =
330$rc5_obj =
331$dso_scheme =
332$shared_target=
333$shared_cflag =
334$shared_ldflag =
335$shared_extension =
336$ranlib =
337
338*** OS390-Unix
339$cc = c89.sh
340$cflags = -O -DB_ENDIAN -DCHARSET_EBCDIC -DNO_SYS_PARAM_H -D_ALL_SOURCE
341$unistd =
342$thread_cflag = (unknown)
343$sys_id =
344$lflags =
345$bn_ops = THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR
346$bn_obj =
347$des_obj =
348$bf_obj =
349$md5_obj =
350$sha1_obj =
351$cast_obj =
352$rc4_obj =
353$rmd160_obj =
354$rc5_obj =
355$dso_scheme =
356$shared_target=
357$shared_cflag =
358$shared_ldflag =
359$shared_extension =
360$ranlib =
361
362*** OpenBSD
363$cc = gcc
364$cflags = -DTERMIOS -O3 -fomit-frame-pointer
365$unistd =
366$thread_cflag = (unknown)
367$sys_id =
368$lflags =
369$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
370$bn_obj =
371$des_obj =
372$bf_obj =
373$md5_obj =
374$sha1_obj =
375$cast_obj =
376$rc4_obj =
377$rmd160_obj =
378$rc5_obj =
379$dso_scheme = dlfcn
380$shared_target= bsd-gcc-shared
381$shared_cflag = -fPIC
382$shared_ldflag =
383$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
384$ranlib =
385
386*** OpenBSD-alpha
387$cc = gcc
388$cflags = -DTERMIOS -O3 -fomit-frame-pointer
389$unistd =
390$thread_cflag = (unknown)
391$sys_id =
392$lflags =
393$bn_ops = SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2
394$bn_obj =
395$des_obj =
396$bf_obj =
397$md5_obj =
398$sha1_obj =
399$cast_obj =
400$rc4_obj =
401$rmd160_obj =
402$rc5_obj =
403$dso_scheme = dlfcn
404$shared_target= bsd-gcc-shared
405$shared_cflag = -fPIC
406$shared_ldflag =
407$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
408$ranlib =
409
410*** OpenBSD-hppa
411$cc = gcc
412$cflags = -DTERMIOS -O3 -fomit-frame-pointer
413$unistd =
414$thread_cflag = (unknown)
415$sys_id =
416$lflags =
417$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_UNROLL
418$bn_obj =
419$des_obj =
420$bf_obj =
421$md5_obj =
422$sha1_obj =
423$cast_obj =
424$rc4_obj =
425$rmd160_obj =
426$rc5_obj =
427$dso_scheme = dlfcn
428$shared_target= bsd-gcc-shared
429$shared_cflag = -fPIC
430$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
431$shared_extension =
432$ranlib =
433
434*** OpenBSD-i386
435$cc = gcc
436$cflags = -DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer
437$unistd =
438$thread_cflag = (unknown)
439$sys_id =
440$lflags =
441$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
442$bn_obj = asm/bn86-out.o asm/co86-out.o
443$des_obj = asm/dx86-out.o asm/yx86-out.o
444$bf_obj = asm/bx86-out.o
445$md5_obj = asm/mx86-out.o
446$sha1_obj = asm/sx86-out.o
447$cast_obj = asm/cx86-out.o
448$rc4_obj = asm/rx86-out.o
449$rmd160_obj = asm/rm86-out.o
450$rc5_obj = asm/r586-out.o
451$dso_scheme = dlfcn
452$shared_target= bsd-gcc-shared
453$shared_cflag = -fPIC
454$shared_ldflag =
455$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
456$ranlib =
457
458*** OpenBSD-m68k
459$cc = gcc
460$cflags = -DTERMIOS -O3 -fomit-frame-pointer
461$unistd =
462$thread_cflag = (unknown)
463$sys_id =
464$lflags =
465$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
466$bn_obj =
467$des_obj =
468$bf_obj =
469$md5_obj =
470$sha1_obj =
471$cast_obj =
472$rc4_obj =
473$rmd160_obj =
474$rc5_obj =
475$dso_scheme = dlfcn
476$shared_target= bsd-gcc-shared
477$shared_cflag = -fPIC
478$shared_ldflag =
479$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
480$ranlib =
481
482*** OpenBSD-m88k
483$cc = gcc
484$cflags = -DTERMIOS -O3 -fomit-frame-pointer
485$unistd =
486$thread_cflag = (unknown)
487$sys_id =
488$lflags =
489$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
490$bn_obj =
491$des_obj =
492$bf_obj =
493$md5_obj =
494$sha1_obj =
495$cast_obj =
496$rc4_obj =
497$rmd160_obj =
498$rc5_obj =
499$dso_scheme = dlfcn
500$shared_target= bsd-gcc-shared
501$shared_cflag = -fPIC
502$shared_ldflag =
503$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
504$ranlib =
505
506*** OpenBSD-mips
507$cc = gcc
508$cflags = -DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer
509$unistd =
510$thread_cflag = (unknown)
511$sys_id =
512$lflags =
513$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL DES_RISC2
514$bn_obj =
515$des_obj =
516$bf_obj =
517$md5_obj =
518$sha1_obj =
519$cast_obj =
520$rc4_obj =
521$rmd160_obj =
522$rc5_obj =
523$dso_scheme = dlfcn
524$shared_target= bsd-gcc-shared
525$shared_cflag = -fPIC
526$shared_ldflag =
527$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
528$ranlib =
529
530*** OpenBSD-powerpc
531$cc = gcc
532$cflags = -DTERMIOS -O3 -fomit-frame-pointer
533$unistd =
534$thread_cflag = (unknown)
535$sys_id =
536$lflags =
537$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
538$bn_obj =
539$des_obj =
540$bf_obj =
541$md5_obj =
542$sha1_obj =
543$cast_obj =
544$rc4_obj =
545$rmd160_obj =
546$rc5_obj =
547$dso_scheme = dlfcn
548$shared_target= bsd-gcc-shared
549$shared_cflag = -fPIC
550$shared_ldflag =
551$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
552$ranlib =
553
554*** OpenBSD-sparc
555$cc = gcc
556$cflags = -DTERMIOS -O3 -fomit-frame-pointer
557$unistd =
558$thread_cflag = (unknown)
559$sys_id =
560$lflags =
561$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
562$bn_obj =
563$des_obj =
564$bf_obj =
565$md5_obj =
566$sha1_obj =
567$cast_obj =
568$rc4_obj =
569$rmd160_obj =
570$rc5_obj =
571$dso_scheme = dlfcn
572$shared_target= bsd-gcc-shared
573$shared_cflag = -fPIC
574$shared_ldflag =
575$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
576$ranlib =
577
578*** OpenBSD-sparc64
579$cc = gcc
580$cflags = -DB_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer
581$unistd =
582$thread_cflag = (unknown)
583$sys_id =
584$lflags =
585$bn_ops = SIXTY_FOUR_BIT_LONG DES_INT DES_PTR DES_RISC2 BF_PTR
586$bn_obj =
587$des_obj =
588$bf_obj =
589$md5_obj =
590$sha1_obj =
591$cast_obj =
592$rc4_obj =
593$rmd160_obj =
594$rc5_obj =
595$dso_scheme = dlfcn
596$shared_target= bsd-gcc-shared
597$shared_cflag = -fPIC
598$shared_ldflag =
599$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
600$ranlib =
601
602*** OpenBSD-vax
603$cc = gcc
604$cflags = -DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer
605$unistd =
606$thread_cflag = (unknown)
607$sys_id =
608$lflags =
609$bn_ops = BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL
610$bn_obj =
611$des_obj =
612$bf_obj =
613$md5_obj =
614$sha1_obj =
615$cast_obj =
616$rc4_obj =
617$rmd160_obj =
618$rc5_obj =
619$dso_scheme = dlfcn
620$shared_target= bsd-gcc-shared
621$shared_cflag = -fPIC
622$shared_ldflag =
623$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
624$ranlib =
625
626*** OpenUNIX-8
627$cc = cc
628$cflags = -O -DFILIO_H -Kalloca
629$unistd =
630$thread_cflag = -Kthread
631$sys_id =
632$lflags = -lsocket -lnsl
633$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
634$bn_obj =
635$des_obj =
636$bf_obj =
637$md5_obj =
638$sha1_obj =
639$cast_obj =
640$rc4_obj =
641$rmd160_obj =
642$rc5_obj =
643$dso_scheme = dlfcn
644$shared_target= svr5-shared
645$shared_cflag = -Kpic
646$shared_ldflag =
647$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
648$ranlib =
649
650*** OpenUNIX-8-gcc
651$cc = gcc
652$cflags = -O -DFILIO_H -fomit-frame-pointer
653$unistd =
654$thread_cflag = -pthread
655$sys_id =
656$lflags = -lsocket -lnsl
657$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
658$bn_obj =
659$des_obj =
660$bf_obj =
661$md5_obj =
662$sha1_obj =
663$cast_obj =
664$rc4_obj =
665$rmd160_obj =
666$rc5_obj =
667$dso_scheme = dlfcn
668$shared_target= svr5-shared
669$shared_cflag = -fPIC
670$shared_ldflag =
671$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
672$ranlib =
673
674*** OpenUNIX-8-pentium
675$cc = cc
676$cflags = -O -DFILIO_H -Kalloca -Kpentium
677$unistd =
678$thread_cflag = -Kthread
679$sys_id =
680$lflags = -lsocket -lnsl
681$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
682$bn_obj =
683$des_obj =
684$bf_obj =
685$md5_obj =
686$sha1_obj =
687$cast_obj =
688$rc4_obj =
689$rmd160_obj =
690$rc5_obj =
691$dso_scheme = dlfcn
692$shared_target= svr5-shared
693$shared_cflag = -Kpic
694$shared_ldflag =
695$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
696$ranlib =
697
698*** OpenUNIX-8-pentium_pro
699$cc = cc
700$cflags = -O -DFILIO_H -Kalloca -Kpentium_pro
701$unistd =
702$thread_cflag = -Kthread
703$sys_id =
704$lflags = -lsocket -lnsl
705$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
706$bn_obj =
707$des_obj =
708$bf_obj =
709$md5_obj =
710$sha1_obj =
711$cast_obj =
712$rc4_obj =
713$rmd160_obj =
714$rc5_obj =
715$dso_scheme = dlfcn
716$shared_target= svr5-shared
717$shared_cflag = -Kpic
718$shared_ldflag =
719$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
720$ranlib =
721
722*** ReliantUNIX
723$cc = cc
724$cflags = -KPIC -g -DTERMIOS -DB_ENDIAN
725$unistd =
726$thread_cflag = -Kthread
727$sys_id = SNI
728$lflags = -lsocket -lnsl -lc -L/usr/ucblib -lucb
729$bn_ops = BN_LLONG DES_PTR DES_RISC2 DES_UNROLL BF_PTR
730$bn_obj =
731$des_obj =
732$bf_obj =
733$md5_obj =
734$sha1_obj =
735$cast_obj =
736$rc4_obj =
737$rmd160_obj =
738$rc5_obj =
739$dso_scheme = dlfcn
740$shared_target= reliantunix-shared
741$shared_cflag =
742$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
743$shared_extension =
744$ranlib =
745
746*** SINIX
747$cc = cc
748$cflags = -O
749$unistd =
750$thread_cflag = (unknown)
751$sys_id = SNI
752$lflags = -lsocket -lnsl -lc -L/usr/ucblib -lucb
753$bn_ops = RC4_INDEX RC4_CHAR
754$bn_obj =
755$des_obj =
756$bf_obj =
757$md5_obj =
758$sha1_obj =
759$cast_obj =
760$rc4_obj =
761$rmd160_obj =
762$rc5_obj =
763$dso_scheme =
764$shared_target=
765$shared_cflag =
766$shared_ldflag =
767$shared_extension =
768$ranlib =
769
770*** SINIX-N
771$cc = /usr/ucb/cc
772$cflags = -O2 -misaligned
773$unistd =
774$thread_cflag = (unknown)
775$sys_id =
776$lflags = -lucb
777$bn_ops = RC4_INDEX RC4_CHAR
778$bn_obj =
779$des_obj =
780$bf_obj =
781$md5_obj =
782$sha1_obj =
783$cast_obj =
784$rc4_obj =
785$rmd160_obj =
786$rc5_obj =
787$dso_scheme =
788$shared_target=
789$shared_cflag =
790$shared_ldflag =
791$shared_extension =
792$ranlib =
793
794*** VC-MSDOS
795$cc = cl
796$cflags =
797$unistd =
798$thread_cflag = (unknown)
799$sys_id = MSDOS
800$lflags =
801$bn_ops = BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT
802$bn_obj =
803$des_obj =
804$bf_obj =
805$md5_obj =
806$sha1_obj =
807$cast_obj =
808$rc4_obj =
809$rmd160_obj =
810$rc5_obj =
811$dso_scheme =
812$shared_target=
813$shared_cflag =
814$shared_ldflag =
815$shared_extension =
816$ranlib =
817
818*** VC-NT
819$cc = cl
820$cflags =
821$unistd =
822$thread_cflag =
823$sys_id = WINNT
824$lflags =
825$bn_ops = BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN RC4_INDEX MD2_INT
826$bn_obj =
827$des_obj =
828$bf_obj =
829$md5_obj =
830$sha1_obj =
831$cast_obj =
832$rc4_obj =
833$rmd160_obj =
834$rc5_obj =
835$dso_scheme = win32
836$shared_target=
837$shared_cflag =
838$shared_ldflag =
839$shared_extension =
840$ranlib =
841
842*** VC-W31-16
843$cc = cl
844$cflags =
845$unistd =
846$thread_cflag = (unknown)
847$sys_id = WIN16
848$lflags =
849$bn_ops = BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX SIXTEEN_BIT
850$bn_obj =
851$des_obj =
852$bf_obj =
853$md5_obj =
854$sha1_obj =
855$cast_obj =
856$rc4_obj =
857$rmd160_obj =
858$rc5_obj =
859$dso_scheme =
860$shared_target=
861$shared_cflag =
862$shared_ldflag =
863$shared_extension =
864$ranlib =
865
866*** VC-W31-32
867$cc = cl
868$cflags =
869$unistd =
870$thread_cflag =
871$sys_id = WIN16
872$lflags =
873$bn_ops = BN_LLONG MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT
874$bn_obj =
875$des_obj =
876$bf_obj =
877$md5_obj =
878$sha1_obj =
879$cast_obj =
880$rc4_obj =
881$rmd160_obj =
882$rc5_obj =
883$dso_scheme =
884$shared_target=
885$shared_cflag =
886$shared_ldflag =
887$shared_extension =
888$ranlib =
889
890*** VC-WIN16
891$cc = cl
892$cflags =
893$unistd =
894$thread_cflag = (unknown)
895$sys_id = WIN16
896$lflags =
897$bn_ops = MD2_CHAR DES_UNROLL DES_PTR RC4_INDEX THIRTY_TWO_BIT
898$bn_obj =
899$des_obj =
900$bf_obj =
901$md5_obj =
902$sha1_obj =
903$cast_obj =
904$rc4_obj =
905$rmd160_obj =
906$rc5_obj =
907$dso_scheme =
908$shared_target=
909$shared_cflag =
910$shared_ldflag =
911$shared_extension =
912$ranlib =
913
914*** VC-WIN32
915$cc = cl
916$cflags =
917$unistd =
918$thread_cflag =
919$sys_id = WIN32
920$lflags =
921$bn_ops = BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN RC4_INDEX MD2_INT
922$bn_obj =
923$des_obj =
924$bf_obj =
925$md5_obj =
926$sha1_obj =
927$cast_obj =
928$rc4_obj =
929$rmd160_obj =
930$rc5_obj =
931$dso_scheme = win32
932$shared_target=
933$shared_cflag =
934$shared_ldflag =
935$shared_extension =
936$ranlib =
937
938*** aix-cc
939$cc = cc
940$cflags = -O -DB_ENDIAN -qmaxmem=16384
941$unistd =
942$thread_cflag = (unknown)
943$sys_id = AIX
944$lflags =
945$bn_ops = BN_LLONG RC4_CHAR
946$bn_obj =
947$des_obj =
948$bf_obj =
949$md5_obj =
950$sha1_obj =
951$cast_obj =
952$rc4_obj =
953$rmd160_obj =
954$rc5_obj =
955$dso_scheme =
956$shared_target=
957$shared_cflag =
958$shared_ldflag =
959$shared_extension =
960$ranlib =
961
962*** aix-gcc
963$cc = gcc
964$cflags = -O3 -DB_ENDIAN
965$unistd =
966$thread_cflag = (unknown)
967$sys_id = AIX
968$lflags =
969$bn_ops = BN_LLONG RC4_CHAR
970$bn_obj =
971$des_obj =
972$bf_obj =
973$md5_obj =
974$sha1_obj =
975$cast_obj =
976$rc4_obj =
977$rmd160_obj =
978$rc5_obj =
979$dso_scheme =
980$shared_target=
981$shared_cflag =
982$shared_ldflag =
983$shared_extension =
984$ranlib =
985
986*** aix43-cc
987$cc = cc
988$cflags = -O -DAIX -DB_ENDIAN -qmaxmem=16384
989$unistd =
990$thread_cflag = (unknown)
991$sys_id =
992$lflags =
993$bn_ops = BN_LLONG RC4_CHAR
994$bn_obj =
995$des_obj =
996$bf_obj =
997$md5_obj =
998$sha1_obj =
999$cast_obj =
1000$rc4_obj =
1001$rmd160_obj =
1002$rc5_obj =
1003$dso_scheme = dlfcn
1004$shared_target=
1005$shared_cflag =
1006$shared_ldflag =
1007$shared_extension =
1008$ranlib =
1009
1010*** aix43-gcc
1011$cc = gcc
1012$cflags = -O3 -DAIX -DB_ENDIAN
1013$unistd =
1014$thread_cflag = (unknown)
1015$sys_id =
1016$lflags =
1017$bn_ops = BN_LLONG RC4_CHAR
1018$bn_obj =
1019$des_obj =
1020$bf_obj =
1021$md5_obj =
1022$sha1_obj =
1023$cast_obj =
1024$rc4_obj =
1025$rmd160_obj =
1026$rc5_obj =
1027$dso_scheme = dlfcn
1028$shared_target=
1029$shared_cflag =
1030$shared_ldflag =
1031$shared_extension =
1032$ranlib =
1033
1034*** alpha-cc
1035$cc = cc
1036$cflags = -std1 -tune host -fast -readonly_strings
1037$unistd =
1038$thread_cflag = -pthread
1039$sys_id =
1040$lflags =
1041$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK
1042$bn_obj =
1043$des_obj =
1044$bf_obj =
1045$md5_obj =
1046$sha1_obj =
1047$cast_obj =
1048$rc4_obj =
1049$rmd160_obj =
1050$rc5_obj =
1051$dso_scheme = dlfcn
1052$shared_target= tru64-shared
1053$shared_cflag =
1054$shared_ldflag =
1055$shared_extension = .so
1056$ranlib =
1057
1058*** alpha-cc-rpath
1059$cc = cc
1060$cflags = -std1 -tune host -fast -readonly_strings
1061$unistd =
1062$thread_cflag = -pthread
1063$sys_id =
1064$lflags =
1065$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK
1066$bn_obj =
1067$des_obj =
1068$bf_obj =
1069$md5_obj =
1070$sha1_obj =
1071$cast_obj =
1072$rc4_obj =
1073$rmd160_obj =
1074$rc5_obj =
1075$dso_scheme = dlfcn
1076$shared_target= tru64-shared-rpath
1077$shared_cflag =
1078$shared_ldflag =
1079$shared_extension = .so
1080$ranlib =
1081
1082*** alpha-gcc
1083$cc = gcc
1084$cflags = -O3
1085$unistd =
1086$thread_cflag = (unknown)
1087$sys_id =
1088$lflags =
1089$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_RISC1
1090$bn_obj =
1091$des_obj =
1092$bf_obj =
1093$md5_obj =
1094$sha1_obj =
1095$cast_obj =
1096$rc4_obj =
1097$rmd160_obj =
1098$rc5_obj =
1099$dso_scheme = dlfcn
1100$shared_target= alpha-osf1-shared
1101$shared_cflag =
1102$shared_ldflag =
1103$shared_extension = .so
1104$ranlib =
1105
1106*** alpha164-cc
1107$cc = cc
1108$cflags = -std1 -tune host -fast -readonly_strings
1109$unistd =
1110$thread_cflag = -pthread
1111$sys_id =
1112$lflags =
1113$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK
1114$bn_obj =
1115$des_obj =
1116$bf_obj =
1117$md5_obj =
1118$sha1_obj =
1119$cast_obj =
1120$rc4_obj =
1121$rmd160_obj =
1122$rc5_obj =
1123$dso_scheme = dlfcn
1124$shared_target= tru64-shared
1125$shared_cflag =
1126$shared_ldflag =
1127$shared_extension = .so
1128$ranlib =
1129
1130*** alphaold-cc
1131$cc = cc
1132$cflags = -std1 -tune host -O4 -readonly_strings
1133$unistd =
1134$thread_cflag = (unknown)
1135$sys_id =
1136$lflags =
1137$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK
1138$bn_obj =
1139$des_obj =
1140$bf_obj =
1141$md5_obj =
1142$sha1_obj =
1143$cast_obj =
1144$rc4_obj =
1145$rmd160_obj =
1146$rc5_obj =
1147$dso_scheme = dlfcn
1148$shared_target= alpha-osf1-shared
1149$shared_cflag =
1150$shared_ldflag =
1151$shared_extension = .so
1152$ranlib =
1153
1154*** bsdi-elf-gcc
1155$cc = gcc
1156$cflags = -DPERL5 -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall
1157$unistd =
1158$thread_cflag = (unknown)
1159$sys_id =
1160$lflags = -ldl
1161$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1162$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1163$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1164$bf_obj = asm/bx86-elf.o
1165$md5_obj = asm/mx86-elf.o
1166$sha1_obj = asm/sx86-elf.o
1167$cast_obj = asm/cx86-elf.o
1168$rc4_obj = asm/rx86-elf.o
1169$rmd160_obj = asm/rm86-elf.o
1170$rc5_obj = asm/r586-elf.o
1171$dso_scheme = dlfcn
1172$shared_target= bsd-gcc-shared
1173$shared_cflag = -fPIC
1174$shared_ldflag =
1175$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1176$ranlib =
1177
1178*** bsdi-gcc
1179$cc = gcc
1180$cflags = -O3 -ffast-math -DL_ENDIAN -DPERL5 -m486
1181$unistd =
1182$thread_cflag = (unknown)
1183$sys_id =
1184$lflags =
1185$bn_ops = RSA_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1186$bn_obj = asm/bn86bsdi.o asm/co86bsdi.o
1187$des_obj = asm/dx86bsdi.o asm/yx86bsdi.o
1188$bf_obj = asm/bx86bsdi.o
1189$md5_obj = asm/mx86bsdi.o
1190$sha1_obj = asm/sx86bsdi.o
1191$cast_obj = asm/cx86bsdi.o
1192$rc4_obj = asm/rx86bsdi.o
1193$rmd160_obj = asm/rm86bsdi.o
1194$rc5_obj = asm/r586bsdi.o
1195$dso_scheme =
1196$shared_target=
1197$shared_cflag =
1198$shared_ldflag =
1199$shared_extension =
1200$ranlib =
1201
1202*** cc
1203$cc = cc
1204$cflags = -O
1205$unistd =
1206$thread_cflag = (unknown)
1207$sys_id =
1208$lflags =
1209$bn_ops =
1210$bn_obj =
1211$des_obj =
1212$bf_obj =
1213$md5_obj =
1214$sha1_obj =
1215$cast_obj =
1216$rc4_obj =
1217$rmd160_obj =
1218$rc5_obj =
1219$dso_scheme =
1220$shared_target=
1221$shared_cflag =
1222$shared_ldflag =
1223$shared_extension =
1224$ranlib =
1225
1226*** cray-j90
1227$cc = cc
1228$cflags = -DBIT_FIELD_LIMITS -DTERMIOS
1229$unistd =
1230$thread_cflag = (unknown)
1231$sys_id = CRAY
1232$lflags =
1233$bn_ops = SIXTY_FOUR_BIT_LONG DES_INT
1234$bn_obj =
1235$des_obj =
1236$bf_obj =
1237$md5_obj =
1238$sha1_obj =
1239$cast_obj =
1240$rc4_obj =
1241$rmd160_obj =
1242$rc5_obj =
1243$dso_scheme =
1244$shared_target=
1245$shared_cflag =
1246$shared_ldflag =
1247$shared_extension =
1248$ranlib =
1249
1250*** cray-t3e
1251$cc = cc
1252$cflags = -DBIT_FIELD_LIMITS -DTERMIOS
1253$unistd =
1254$thread_cflag = (unknown)
1255$sys_id = CRAY
1256$lflags =
1257$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT
1258$bn_obj =
1259$des_obj =
1260$bf_obj =
1261$md5_obj =
1262$sha1_obj =
1263$cast_obj =
1264$rc4_obj =
1265$rmd160_obj =
1266$rc5_obj =
1267$dso_scheme =
1268$shared_target=
1269$shared_cflag =
1270$shared_ldflag =
1271$shared_extension =
1272$ranlib =
1273
1274*** darwin-i386-cc
1275$cc = cc
1276$cflags = -O3 -nostdinc -I/System/Library/Frameworks/System.framework/Headers -I/System/Library/Frameworks/System.frameworks/Headers/bsd -I/usr/include -fomit-frame-pointer -Wall -DB_ENDIAN
1277$unistd =
1278$thread_cflag = (unknown)
1279$sys_id = MACOSX
1280$lflags =
1281$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
1282$bn_obj =
1283$des_obj =
1284$bf_obj =
1285$md5_obj =
1286$sha1_obj =
1287$cast_obj =
1288$rc4_obj =
1289$rmd160_obj =
1290$rc5_obj =
1291$dso_scheme =
1292$shared_target=
1293$shared_cflag = -fPIC
1294$shared_ldflag =
1295$shared_extension =
1296$ranlib =
1297
1298*** darwin-ppc-cc
1299$cc = cc
1300$cflags = -O3 -nostdinc -I/System/Library/Frameworks/System.framework/Headers -I/System/Library/Frameworks/System.frameworks/Headers/bsd -I/usr/include -fomit-frame-pointer -Wall -DB_ENDIAN
1301$unistd =
1302$thread_cflag = (unknown)
1303$sys_id = MACOSX
1304$lflags =
1305$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
1306$bn_obj =
1307$des_obj =
1308$bf_obj =
1309$md5_obj =
1310$sha1_obj =
1311$cast_obj =
1312$rc4_obj =
1313$rmd160_obj =
1314$rc5_obj =
1315$dso_scheme =
1316$shared_target= darwin-shared
1317$shared_cflag = -fPIC
1318$shared_ldflag = .$(SHLIB_MAJOR).$(SHLIB_MINOR).dylib
1319$shared_extension =
1320$ranlib =
1321
1322*** debug
1323$cc = gcc
1324$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror
1325$unistd =
1326$thread_cflag = (unknown)
1327$sys_id =
1328$lflags = -lefence
1329$bn_ops =
1330$bn_obj =
1331$des_obj =
1332$bf_obj =
1333$md5_obj =
1334$sha1_obj =
1335$cast_obj =
1336$rc4_obj =
1337$rmd160_obj =
1338$rc5_obj =
1339$dso_scheme =
1340$shared_target=
1341$shared_cflag =
1342$shared_ldflag =
1343$shared_extension =
1344$ranlib =
1345
1346*** debug-ben
1347$cc = gcc
1348$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -O2 -pedantic -Wall -Wshadow -Werror -pipe
1349$unistd =
1350$thread_cflag = (unknown)
1351$sys_id =
1352$lflags =
1353$bn_ops =
1354$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1355$des_obj =
1356$bf_obj =
1357$md5_obj =
1358$sha1_obj =
1359$cast_obj =
1360$rc4_obj =
1361$rmd160_obj =
1362$rc5_obj =
1363$dso_scheme =
1364$shared_target=
1365$shared_cflag =
1366$shared_ldflag =
1367$shared_extension =
1368$ranlib =
1369
1370*** debug-ben-debug
1371$cc = gcc
1372$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe
1373$unistd =
1374$thread_cflag = (unknown)
1375$sys_id =
1376$lflags =
1377$bn_ops =
1378$bn_obj =
1379$des_obj =
1380$bf_obj =
1381$md5_obj =
1382$sha1_obj =
1383$cast_obj =
1384$rc4_obj =
1385$rmd160_obj =
1386$rc5_obj =
1387$dso_scheme =
1388$shared_target=
1389$shared_cflag =
1390$shared_ldflag =
1391$shared_extension =
1392$ranlib =
1393
1394*** debug-ben-openbsd
1395$cc = gcc
1396$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe
1397$unistd =
1398$thread_cflag = (unknown)
1399$sys_id =
1400$lflags =
1401$bn_ops =
1402$bn_obj =
1403$des_obj =
1404$bf_obj =
1405$md5_obj =
1406$sha1_obj =
1407$cast_obj =
1408$rc4_obj =
1409$rmd160_obj =
1410$rc5_obj =
1411$dso_scheme =
1412$shared_target=
1413$shared_cflag =
1414$shared_ldflag =
1415$shared_extension =
1416$ranlib =
1417
1418*** debug-ben-openbsd-debug
1419$cc = gcc
1420$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe
1421$unistd =
1422$thread_cflag = (unknown)
1423$sys_id =
1424$lflags =
1425$bn_ops =
1426$bn_obj =
1427$des_obj =
1428$bf_obj =
1429$md5_obj =
1430$sha1_obj =
1431$cast_obj =
1432$rc4_obj =
1433$rmd160_obj =
1434$rc5_obj =
1435$dso_scheme =
1436$shared_target=
1437$shared_cflag =
1438$shared_ldflag =
1439$shared_extension =
1440$ranlib =
1441
1442*** debug-ben-strict
1443$cc = gcc
1444$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe
1445$unistd =
1446$thread_cflag = (unknown)
1447$sys_id =
1448$lflags =
1449$bn_ops =
1450$bn_obj =
1451$des_obj =
1452$bf_obj =
1453$md5_obj =
1454$sha1_obj =
1455$cast_obj =
1456$rc4_obj =
1457$rmd160_obj =
1458$rc5_obj =
1459$dso_scheme =
1460$shared_target=
1461$shared_cflag =
1462$shared_ldflag =
1463$shared_extension =
1464$ranlib =
1465
1466*** debug-bodo
1467$cc = gcc
1468$cflags = -DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DBIO_PAIR_DEBUG -DPEDANTIC -g -m486 -pedantic -Wshadow -Wall
1469$unistd =
1470$thread_cflag = -D_REENTRANT
1471$sys_id =
1472$lflags =
1473$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1474$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1475$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1476$bf_obj = asm/bx86-elf.o
1477$md5_obj = asm/mx86-elf.o
1478$sha1_obj = asm/sx86-elf.o
1479$cast_obj = asm/cx86-elf.o
1480$rc4_obj = asm/rx86-elf.o
1481$rmd160_obj = asm/rm86-elf.o
1482$rc5_obj = asm/r586-elf.o
1483$dso_scheme =
1484$shared_target=
1485$shared_cflag =
1486$shared_ldflag =
1487$shared_extension =
1488$ranlib =
1489
1490*** debug-levitte-linux-elf
1491$cc = gcc
1492$cflags = -DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -Wno-long-long -pipe
1493$unistd =
1494$thread_cflag = -D_REENTRANT
1495$sys_id =
1496$lflags = -ldl
1497$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1498$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1499$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1500$bf_obj = asm/bx86-elf.o
1501$md5_obj = asm/mx86-elf.o
1502$sha1_obj = asm/sx86-elf.o
1503$cast_obj = asm/cx86-elf.o
1504$rc4_obj = asm/rx86-elf.o
1505$rmd160_obj = asm/rm86-elf.o
1506$rc5_obj = asm/r586-elf.o
1507$dso_scheme = dlfcn
1508$shared_target= linux-shared
1509$shared_cflag = -fPIC
1510$shared_ldflag =
1511$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1512$ranlib =
1513
1514*** debug-levitte-linux-noasm
1515$cc = gcc
1516$cflags = -DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -Wno-long-long -pipe
1517$unistd =
1518$thread_cflag = -D_REENTRANT
1519$sys_id =
1520$lflags = -ldl
1521$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1522$bn_obj =
1523$des_obj =
1524$bf_obj =
1525$md5_obj =
1526$sha1_obj =
1527$cast_obj =
1528$rc4_obj =
1529$rmd160_obj =
1530$rc5_obj =
1531$dso_scheme = dlfcn
1532$shared_target= linux-shared
1533$shared_cflag = -fPIC
1534$shared_ldflag =
1535$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1536$ranlib =
1537
1538*** debug-linux-elf
1539$cc = gcc
1540$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall
1541$unistd =
1542$thread_cflag = -D_REENTRANT
1543$sys_id =
1544$lflags = -lefence -ldl
1545$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1546$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1547$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1548$bf_obj = asm/bx86-elf.o
1549$md5_obj = asm/mx86-elf.o
1550$sha1_obj = asm/sx86-elf.o
1551$cast_obj = asm/cx86-elf.o
1552$rc4_obj = asm/rx86-elf.o
1553$rmd160_obj = asm/rm86-elf.o
1554$rc5_obj = asm/r586-elf.o
1555$dso_scheme = dlfcn
1556$shared_target= linux-shared
1557$shared_cflag = -fPIC
1558$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1559$shared_extension =
1560$ranlib =
1561
1562*** debug-linux-elf-noefence
1563$cc = gcc
1564$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall
1565$unistd =
1566$thread_cflag = -D_REENTRANT
1567$sys_id =
1568$lflags = -ldl
1569$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1570$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1571$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1572$bf_obj = asm/bx86-elf.o
1573$md5_obj = asm/mx86-elf.o
1574$sha1_obj = asm/sx86-elf.o
1575$cast_obj = asm/cx86-elf.o
1576$rc4_obj = asm/rx86-elf.o
1577$rmd160_obj = asm/rm86-elf.o
1578$rc5_obj = asm/r586-elf.o
1579$dso_scheme = dlfcn
1580$shared_target=
1581$shared_cflag =
1582$shared_ldflag =
1583$shared_extension =
1584$ranlib =
1585
1586*** debug-linux-pentium
1587$cc = gcc
1588$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall
1589$unistd =
1590$thread_cflag = -D_REENTRANT
1591$sys_id =
1592$lflags = -ldl
1593$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1594$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1595$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1596$bf_obj = asm/bx86-elf.o
1597$md5_obj = asm/mx86-elf.o
1598$sha1_obj = asm/sx86-elf.o
1599$cast_obj = asm/cx86-elf.o
1600$rc4_obj = asm/rx86-elf.o
1601$rmd160_obj = asm/rm86-elf.o
1602$rc5_obj = asm/r586-elf.o
1603$dso_scheme = dlfcn
1604$shared_target=
1605$shared_cflag =
1606$shared_ldflag =
1607$shared_extension =
1608$ranlib =
1609
1610*** debug-linux-ppro
1611$cc = gcc
1612$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentiumpro -Wall
1613$unistd =
1614$thread_cflag = -D_REENTRANT
1615$sys_id =
1616$lflags = -ldl
1617$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1618$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1619$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1620$bf_obj = asm/bx86-elf.o
1621$md5_obj = asm/mx86-elf.o
1622$sha1_obj = asm/sx86-elf.o
1623$cast_obj = asm/cx86-elf.o
1624$rc4_obj = asm/rx86-elf.o
1625$rmd160_obj = asm/rm86-elf.o
1626$rc5_obj = asm/r586-elf.o
1627$dso_scheme = dlfcn
1628$shared_target=
1629$shared_cflag =
1630$shared_ldflag =
1631$shared_extension =
1632$ranlib =
1633
1634*** debug-rse
1635$cc = cc
1636$cflags = -DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall
1637$unistd =
1638$thread_cflag = (unknown)
1639$sys_id =
1640$lflags =
1641$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1642$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1643$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1644$bf_obj = asm/bx86-elf.o
1645$md5_obj = asm/mx86-elf.o
1646$sha1_obj = asm/sx86-elf.o
1647$cast_obj = asm/cx86-elf.o
1648$rc4_obj = asm/rx86-elf.o
1649$rmd160_obj = asm/rm86-elf.o
1650$rc5_obj = asm/r586-elf.o
1651$dso_scheme =
1652$shared_target=
1653$shared_cflag =
1654$shared_ldflag =
1655$shared_extension =
1656$ranlib =
1657
1658*** debug-solaris-sparcv8-cc
1659$cc = cc
1660$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W
1661$unistd =
1662$thread_cflag = -D_REENTRANT
1663$sys_id =
1664$lflags = -lsocket -lnsl -ldl
1665$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR
1666$bn_obj = asm/sparcv8.o
1667$des_obj =
1668$bf_obj =
1669$md5_obj =
1670$sha1_obj =
1671$cast_obj =
1672$rc4_obj =
1673$rmd160_obj =
1674$rc5_obj =
1675$dso_scheme = dlfcn
1676$shared_target= solaris-shared
1677$shared_cflag = -KPIC
1678$shared_ldflag =
1679$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1680$ranlib =
1681
1682*** debug-solaris-sparcv8-gcc
1683$cc = gcc
1684$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN
1685$unistd =
1686$thread_cflag = -D_REENTRANT
1687$sys_id =
1688$lflags = -lsocket -lnsl -ldl
1689$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
1690$bn_obj = asm/sparcv8.o
1691$des_obj =
1692$bf_obj =
1693$md5_obj =
1694$sha1_obj =
1695$cast_obj =
1696$rc4_obj =
1697$rmd160_obj =
1698$rc5_obj =
1699$dso_scheme = dlfcn
1700$shared_target= solaris-shared
1701$shared_cflag = -fPIC
1702$shared_ldflag =
1703$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1704$ranlib =
1705
1706*** debug-solaris-sparcv9-cc
1707$cc = cc
1708$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W
1709$unistd =
1710$thread_cflag = -D_REENTRANT
1711$sys_id = ULTRASPARC
1712$lflags = -lsocket -lnsl -ldl
1713$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR
1714$bn_obj = asm/sparcv8plus.o
1715$des_obj =
1716$bf_obj =
1717$md5_obj = asm/md5-sparcv8plus.o
1718$sha1_obj =
1719$cast_obj =
1720$rc4_obj =
1721$rmd160_obj =
1722$rc5_obj =
1723$dso_scheme = dlfcn
1724$shared_target= solaris-shared
1725$shared_cflag = -KPIC
1726$shared_ldflag =
1727$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1728$ranlib =
1729
1730*** debug-solaris-sparcv9-gcc
1731$cc = gcc
1732$cflags = -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN
1733$unistd =
1734$thread_cflag = -D_REENTRANT
1735$sys_id =
1736$lflags = -lsocket -lnsl -ldl
1737$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
1738$bn_obj = asm/sparcv8plus.o
1739$des_obj =
1740$bf_obj =
1741$md5_obj =
1742$sha1_obj =
1743$cast_obj =
1744$rc4_obj =
1745$rmd160_obj =
1746$rc5_obj =
1747$dso_scheme = dlfcn
1748$shared_target= solaris-shared
1749$shared_cflag = -fPIC
1750$shared_ldflag =
1751$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1752$ranlib =
1753
1754*** debug-steve
1755$cc = gcc
1756$cflags = -DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wall -Werror -Wshadow -pipe
1757$unistd =
1758$thread_cflag = -D_REENTRANT
1759$sys_id =
1760$lflags = -rdynamic -ldl
1761$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1762$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1763$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1764$bf_obj = asm/bx86-elf.o
1765$md5_obj = asm/mx86-elf.o
1766$sha1_obj = asm/sx86-elf.o
1767$cast_obj = asm/cx86-elf.o
1768$rc4_obj = asm/rx86-elf.o
1769$rmd160_obj = asm/rm86-elf.o
1770$rc5_obj = asm/r586-elf.o
1771$dso_scheme = dlfcn
1772$shared_target=
1773$shared_cflag =
1774$shared_ldflag =
1775$shared_extension =
1776$ranlib =
1777
1778*** debug-ulf
1779$cc = gcc
1780$cflags = -DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -g -O2 -m486 -Wall -Werror -Wshadow -pipe
1781$unistd =
1782$thread_cflag = -D_REENTRANT
1783$sys_id =
1784$lflags =
1785$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1786$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1787$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1788$bf_obj = asm/bx86-elf.o
1789$md5_obj = asm/mx86-elf.o
1790$sha1_obj = asm/sx86-elf.o
1791$cast_obj = asm/cx86-elf.o
1792$rc4_obj = asm/rx86-elf.o
1793$rmd160_obj = asm/rm86-elf.o
1794$rc5_obj = asm/r586-elf.o
1795$dso_scheme =
1796$shared_target=
1797$shared_cflag =
1798$shared_ldflag =
1799$shared_extension =
1800$ranlib =
1801
1802*** dgux-R3-gcc
1803$cc = gcc
1804$cflags = -O3 -fomit-frame-pointer
1805$unistd =
1806$thread_cflag = (unknown)
1807$sys_id =
1808$lflags =
1809$bn_ops = RC4_INDEX DES_UNROLL
1810$bn_obj =
1811$des_obj =
1812$bf_obj =
1813$md5_obj =
1814$sha1_obj =
1815$cast_obj =
1816$rc4_obj =
1817$rmd160_obj =
1818$rc5_obj =
1819$dso_scheme =
1820$shared_target=
1821$shared_cflag =
1822$shared_ldflag =
1823$shared_extension =
1824$ranlib =
1825
1826*** dgux-R4-gcc
1827$cc = gcc
1828$cflags = -O3 -fomit-frame-pointer
1829$unistd =
1830$thread_cflag = (unknown)
1831$sys_id =
1832$lflags = -lnsl -lsocket
1833$bn_ops = RC4_INDEX DES_UNROLL
1834$bn_obj =
1835$des_obj =
1836$bf_obj =
1837$md5_obj =
1838$sha1_obj =
1839$cast_obj =
1840$rc4_obj =
1841$rmd160_obj =
1842$rc5_obj =
1843$dso_scheme =
1844$shared_target=
1845$shared_cflag =
1846$shared_ldflag =
1847$shared_extension =
1848$ranlib =
1849
1850*** dgux-R4-x86-gcc
1851$cc = gcc
1852$cflags = -O3 -fomit-frame-pointer -DL_ENDIAN
1853$unistd =
1854$thread_cflag = (unknown)
1855$sys_id =
1856$lflags = -lnsl -lsocket
1857$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
1858$bn_obj = asm/bn86-elf.o asm/co86-elf.o
1859$des_obj = asm/dx86-elf.o asm/yx86-elf.o
1860$bf_obj = asm/bx86-elf.o
1861$md5_obj = asm/mx86-elf.o
1862$sha1_obj = asm/sx86-elf.o
1863$cast_obj = asm/cx86-elf.o
1864$rc4_obj = asm/rx86-elf.o
1865$rmd160_obj = asm/rm86-elf.o
1866$rc5_obj = asm/r586-elf.o
1867$dso_scheme =
1868$shared_target=
1869$shared_cflag =
1870$shared_ldflag =
1871$shared_extension =
1872$ranlib =
1873
1874*** dist
1875$cc = cc
1876$cflags = -O
1877$unistd =
1878$thread_cflag = (unknown)
1879$sys_id =
1880$lflags =
1881$bn_ops =
1882$bn_obj =
1883$des_obj =
1884$bf_obj =
1885$md5_obj =
1886$sha1_obj =
1887$cast_obj =
1888$rc4_obj =
1889$rmd160_obj =
1890$rc5_obj =
1891$dso_scheme =
1892$shared_target=
1893$shared_cflag =
1894$shared_ldflag =
1895$shared_extension =
1896$ranlib =
1897
1898*** gcc
1899$cc = gcc
1900$cflags = -O3
1901$unistd =
1902$thread_cflag = (unknown)
1903$sys_id =
1904$lflags =
1905$bn_ops = BN_LLONG
1906$bn_obj =
1907$des_obj =
1908$bf_obj =
1909$md5_obj =
1910$sha1_obj =
1911$cast_obj =
1912$rc4_obj =
1913$rmd160_obj =
1914$rc5_obj =
1915$dso_scheme =
1916$shared_target=
1917$shared_cflag =
1918$shared_ldflag =
1919$shared_extension =
1920$ranlib =
1921
1922*** hpux-brokencc
1923$cc = cc
1924$cflags = -DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z
1925$unistd =
1926$thread_cflag = (unknown)
1927$sys_id =
1928$lflags = -Wl,+s -ldld
1929$bn_ops = DES_PTR DES_UNROLL DES_RISC1
1930$bn_obj =
1931$des_obj =
1932$bf_obj =
1933$md5_obj =
1934$sha1_obj =
1935$cast_obj =
1936$rc4_obj =
1937$rmd160_obj =
1938$rc5_obj =
1939$dso_scheme = dl
1940$shared_target= hpux-shared
1941$shared_cflag = +Z
1942$shared_ldflag =
1943$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1944$ranlib =
1945
1946*** hpux-brokengcc
1947$cc = gcc
1948$cflags = -DB_ENDIAN -DBN_DIV2W -O3
1949$unistd =
1950$thread_cflag = (unknown)
1951$sys_id =
1952$lflags = -Wl,+s -ldld
1953$bn_ops = DES_PTR DES_UNROLL DES_RISC1
1954$bn_obj =
1955$des_obj =
1956$bf_obj =
1957$md5_obj =
1958$sha1_obj =
1959$cast_obj =
1960$rc4_obj =
1961$rmd160_obj =
1962$rc5_obj =
1963$dso_scheme = dl
1964$shared_target= hpux-shared
1965$shared_cflag = -fPIC
1966$shared_ldflag =
1967$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1968$ranlib =
1969
1970*** hpux-cc
1971$cc = cc
1972$cflags = -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z
1973$unistd =
1974$thread_cflag = (unknown)
1975$sys_id =
1976$lflags = -Wl,+s -ldld
1977$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
1978$bn_obj =
1979$des_obj =
1980$bf_obj =
1981$md5_obj =
1982$sha1_obj =
1983$cast_obj =
1984$rc4_obj =
1985$rmd160_obj =
1986$rc5_obj =
1987$dso_scheme = dl
1988$shared_target= hpux-shared
1989$shared_cflag = +Z
1990$shared_ldflag =
1991$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
1992$ranlib =
1993
1994*** hpux-gcc
1995$cc = gcc
1996$cflags = -DB_ENDIAN -DBN_DIV2W -O3
1997$unistd =
1998$thread_cflag = (unknown)
1999$sys_id =
2000$lflags = -Wl,+s -ldld
2001$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2002$bn_obj =
2003$des_obj =
2004$bf_obj =
2005$md5_obj =
2006$sha1_obj =
2007$cast_obj =
2008$rc4_obj =
2009$rmd160_obj =
2010$rc5_obj =
2011$dso_scheme = dl
2012$shared_target= hpux-shared
2013$shared_cflag = -fPIC
2014$shared_ldflag =
2015$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2016$ranlib =
2017
2018*** hpux-ia64-cc
2019$cc = cc
2020$cflags = -Ae +DD32 +O3 +ESlit -z -DB_ENDIAN
2021$unistd =
2022$thread_cflag = -D_REENTRANT
2023$sys_id =
2024$lflags = -ldl
2025$bn_ops = SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2026$bn_obj = asm/ia64-cpp.o
2027$des_obj =
2028$bf_obj =
2029$md5_obj =
2030$sha1_obj =
2031$cast_obj =
2032$rc4_obj =
2033$rmd160_obj =
2034$rc5_obj =
2035$dso_scheme = dlfcn
2036$shared_target= hpux-shared
2037$shared_cflag = +Z
2038$shared_ldflag =
2039$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2040$ranlib =
2041
2042*** hpux-m68k-gcc
2043$cc = gcc
2044$cflags = -DB_ENDIAN -DBN_DIV2W -O3
2045$unistd =
2046$thread_cflag = (unknown)
2047$sys_id =
2048$lflags =
2049$bn_ops = BN_LLONG DES_PTR DES_UNROLL
2050$bn_obj =
2051$des_obj =
2052$bf_obj =
2053$md5_obj =
2054$sha1_obj =
2055$cast_obj =
2056$rc4_obj =
2057$rmd160_obj =
2058$rc5_obj =
2059$dso_scheme =
2060$shared_target=
2061$shared_cflag =
2062$shared_ldflag =
2063$shared_extension =
2064$ranlib =
2065
2066*** hpux-parisc-cc
2067$cc = cc
2068$cflags = +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY
2069$unistd =
2070$thread_cflag = -D_REENTRANT
2071$sys_id =
2072$lflags = -Wl,+s -ldld
2073$bn_ops = MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2074$bn_obj =
2075$des_obj =
2076$bf_obj =
2077$md5_obj =
2078$sha1_obj =
2079$cast_obj =
2080$rc4_obj =
2081$rmd160_obj =
2082$rc5_obj =
2083$dso_scheme = dl
2084$shared_target= hpux-shared
2085$shared_cflag = +Z
2086$shared_ldflag =
2087$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2088$ranlib =
2089
2090*** hpux-parisc-cc-o4
2091$cc = cc
2092$cflags = -Ae +O4 +ESlit -z -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY
2093$unistd =
2094$thread_cflag =
2095$sys_id =
2096$lflags = -ldld
2097$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2098$bn_obj =
2099$des_obj =
2100$bf_obj =
2101$md5_obj =
2102$sha1_obj =
2103$cast_obj =
2104$rc4_obj =
2105$rmd160_obj =
2106$rc5_obj =
2107$dso_scheme = dl
2108$shared_target= hpux-shared
2109$shared_cflag = +Z
2110$shared_ldflag =
2111$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2112$ranlib =
2113
2114*** hpux-parisc-gcc
2115$cc = gcc
2116$cflags = -O3 -DB_ENDIAN -DBN_DIV2W
2117$unistd =
2118$thread_cflag =
2119$sys_id =
2120$lflags = -Wl,+s -ldld
2121$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2122$bn_obj =
2123$des_obj =
2124$bf_obj =
2125$md5_obj =
2126$sha1_obj =
2127$cast_obj =
2128$rc4_obj =
2129$rmd160_obj =
2130$rc5_obj =
2131$dso_scheme = dl
2132$shared_target= hpux-shared
2133$shared_cflag = -fPIC
2134$shared_ldflag =
2135$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2136$ranlib =
2137
2138*** hpux-parisc1_1-cc
2139$cc = cc
2140$cflags = +DA1.1 +DS1.1 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY
2141$unistd =
2142$thread_cflag = -D_REENTRANT
2143$sys_id =
2144$lflags = -Wl,+s -ldld
2145$bn_ops = MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2146$bn_obj =
2147$des_obj =
2148$bf_obj =
2149$md5_obj =
2150$sha1_obj =
2151$cast_obj =
2152$rc4_obj =
2153$rmd160_obj =
2154$rc5_obj =
2155$dso_scheme = dl
2156$shared_target= hpux-shared
2157$shared_cflag = +Z
2158$shared_ldflag =
2159$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2160$ranlib =
2161
2162*** hpux-parisc2-cc
2163$cc = cc
2164$cflags = +DA2.0 +DS2.0 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY
2165$unistd =
2166$thread_cflag = -D_REENTRANT
2167$sys_id =
2168$lflags = -Wl,+s -ldld
2169$bn_ops = SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2170$bn_obj = asm/pa-risc2.o
2171$des_obj =
2172$bf_obj =
2173$md5_obj =
2174$sha1_obj =
2175$cast_obj =
2176$rc4_obj =
2177$rmd160_obj =
2178$rc5_obj =
2179$dso_scheme = dl
2180$shared_target= hpux-shared
2181$shared_cflag = +Z
2182$shared_ldflag =
2183$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2184$ranlib =
2185
2186*** hpux10-brokencc
2187$cc = cc
2188$cflags = -DB_ENDIAN -DBN_DIV2W -Ae +ESlit +O2 -z
2189$unistd =
2190$thread_cflag = -D_REENTRANT
2191$sys_id =
2192$lflags = -Wl,+s -ldld
2193$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2194$bn_obj =
2195$des_obj =
2196$bf_obj =
2197$md5_obj =
2198$sha1_obj =
2199$cast_obj =
2200$rc4_obj =
2201$rmd160_obj =
2202$rc5_obj =
2203$dso_scheme = dl
2204$shared_target= hpux-shared
2205$shared_cflag = +Z
2206$shared_ldflag =
2207$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2208$ranlib =
2209
2210*** hpux10-brokengcc
2211$cc = gcc
2212$cflags = -DB_ENDIAN -DBN_DIV2W -O3
2213$unistd =
2214$thread_cflag = -D_REENTRANT
2215$sys_id =
2216$lflags = -Wl,+s -ldld
2217$bn_ops = DES_PTR DES_UNROLL DES_RISC1
2218$bn_obj =
2219$des_obj =
2220$bf_obj =
2221$md5_obj =
2222$sha1_obj =
2223$cast_obj =
2224$rc4_obj =
2225$rmd160_obj =
2226$rc5_obj =
2227$dso_scheme = dl
2228$shared_target= hpux-shared
2229$shared_cflag = -fPIC
2230$shared_ldflag =
2231$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2232$ranlib =
2233
2234*** hpux10-cc
2235$cc = cc
2236$cflags = -DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY -Ae +ESlit +O3 -z
2237$unistd =
2238$thread_cflag = -D_REENTRANT
2239$sys_id =
2240$lflags = -Wl,+s -ldld
2241$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2242$bn_obj =
2243$des_obj =
2244$bf_obj =
2245$md5_obj =
2246$sha1_obj =
2247$cast_obj =
2248$rc4_obj =
2249$rmd160_obj =
2250$rc5_obj =
2251$dso_scheme = dl
2252$shared_target= hpux-shared
2253$shared_cflag = +Z
2254$shared_ldflag =
2255$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2256$ranlib =
2257
2258*** hpux10-gcc
2259$cc = gcc
2260$cflags = -DB_ENDIAN -DBN_DIV2W -O3
2261$unistd =
2262$thread_cflag = -D_REENTRANT
2263$sys_id =
2264$lflags = -Wl,+s -ldld
2265$bn_ops = BN_LLONG DES_PTR DES_UNROLL DES_RISC1
2266$bn_obj =
2267$des_obj =
2268$bf_obj =
2269$md5_obj =
2270$sha1_obj =
2271$cast_obj =
2272$rc4_obj =
2273$rmd160_obj =
2274$rc5_obj =
2275$dso_scheme = dl
2276$shared_target= hpux-shared
2277$shared_cflag = -fPIC
2278$shared_ldflag =
2279$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2280$ranlib =
2281
2282*** hpux64-ia64-cc
2283$cc = cc
2284$cflags = -Ae +DD64 +O3 +ESlit -z -DB_ENDIAN
2285$unistd =
2286$thread_cflag = -D_REENTRANT
2287$sys_id =
2288$lflags = -ldl
2289$bn_ops = SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2290$bn_obj = asm/ia64-cpp.o
2291$des_obj =
2292$bf_obj =
2293$md5_obj =
2294$sha1_obj =
2295$cast_obj =
2296$rc4_obj =
2297$rmd160_obj =
2298$rc5_obj =
2299$dso_scheme = dlfcn
2300$shared_target= hpux64-shared
2301$shared_cflag = +Z
2302$shared_ldflag =
2303$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2304$ranlib =
2305
2306*** hpux64-parisc-cc
2307$cc = cc
2308$cflags = -Ae +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY
2309$unistd =
2310$thread_cflag = -D_REENTRANT
2311$sys_id =
2312$lflags = -ldl
2313$bn_ops = SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2314$bn_obj =
2315$des_obj =
2316$bf_obj =
2317$md5_obj =
2318$sha1_obj =
2319$cast_obj =
2320$rc4_obj =
2321$rmd160_obj =
2322$rc5_obj =
2323$dso_scheme = dlfcn
2324$shared_target= hpux64-shared
2325$shared_cflag = +Z
2326$shared_ldflag =
2327$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2328$ranlib =
2329
2330*** hpux64-parisc2-cc
2331$cc = cc
2332$cflags = +DD64 +O3 +Optrs_strongly_typed +Olibcalls -Ae +ESlit -DB_ENDIAN -DMD32_XARRAY
2333$unistd =
2334$thread_cflag = -D_REENTRANT
2335$sys_id =
2336$lflags = -ldl
2337$bn_ops = SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC1 DES_INT
2338$bn_obj = asm/pa-risc2W.o
2339$des_obj =
2340$bf_obj =
2341$md5_obj =
2342$sha1_obj =
2343$cast_obj =
2344$rc4_obj =
2345$rmd160_obj =
2346$rc5_obj =
2347$dso_scheme = dlfcn
2348$shared_target= hpux64-shared
2349$shared_cflag = +Z
2350$shared_ldflag =
2351$shared_extension = .sl.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2352$ranlib =
2353
2354*** hurd-x86
2355$cc = gcc
2356$cflags = -DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall
2357$unistd =
2358$thread_cflag = -D_REENTRANT
2359$sys_id =
2360$lflags = -ldl
2361$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2362$bn_obj = asm/bn86-elf.o asm/co86-elf.o
2363$des_obj = asm/dx86-elf.o asm/yx86-elf.o
2364$bf_obj = asm/bx86-elf.o
2365$md5_obj = asm/mx86-elf.o
2366$sha1_obj = asm/sx86-elf.o
2367$cast_obj = asm/cx86-elf.o
2368$rc4_obj = asm/rx86-elf.o
2369$rmd160_obj = asm/rm86-elf.o
2370$rc5_obj = asm/r586-elf.o
2371$dso_scheme = dlfcn
2372$shared_target= linux-shared
2373$shared_cflag = -fPIC
2374$shared_ldflag =
2375$shared_extension =
2376$ranlib =
2377
2378*** irix-cc
2379$cc = cc
2380$cflags = -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN
2381$unistd =
2382$thread_cflag = (unknown)
2383$sys_id =
2384$lflags =
2385$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC2 DES_UNROLL BF_PTR
2386$bn_obj =
2387$des_obj =
2388$bf_obj =
2389$md5_obj =
2390$sha1_obj =
2391$cast_obj =
2392$rc4_obj =
2393$rmd160_obj =
2394$rc5_obj =
2395$dso_scheme = dlfcn
2396$shared_target= irix-shared
2397$shared_cflag =
2398$shared_ldflag =
2399$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2400$ranlib =
2401
2402*** irix-gcc
2403$cc = gcc
2404$cflags = -O3 -DTERMIOS -DB_ENDIAN
2405$unistd =
2406$thread_cflag = (unknown)
2407$sys_id =
2408$lflags =
2409$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK DES_UNROLL DES_RISC2 DES_PTR BF_PTR
2410$bn_obj =
2411$des_obj =
2412$bf_obj =
2413$md5_obj =
2414$sha1_obj =
2415$cast_obj =
2416$rc4_obj =
2417$rmd160_obj =
2418$rc5_obj =
2419$dso_scheme = dlfcn
2420$shared_target= irix-shared
2421$shared_cflag =
2422$shared_ldflag =
2423$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2424$ranlib =
2425
2426*** irix-mips3-cc
2427$cc = cc
2428$cflags = -n32 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W
2429$unistd =
2430$thread_cflag = -D_SGI_MP_SOURCE
2431$sys_id =
2432$lflags =
2433$bn_ops = DES_PTR RC4_CHAR RC4_CHUNK_LL DES_RISC2 DES_UNROLL BF_PTR SIXTY_FOUR_BIT
2434$bn_obj = asm/mips3.o
2435$des_obj =
2436$bf_obj =
2437$md5_obj =
2438$sha1_obj =
2439$cast_obj =
2440$rc4_obj =
2441$rmd160_obj =
2442$rc5_obj =
2443$dso_scheme = dlfcn
2444$shared_target= irix-shared
2445$shared_cflag =
2446$shared_ldflag =
2447$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2448$ranlib =
2449
2450*** irix-mips3-gcc
2451$cc = gcc
2452$cflags = -mabi=n32 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W
2453$unistd =
2454$thread_cflag = -D_SGI_MP_SOURCE
2455$sys_id =
2456$lflags =
2457$bn_ops = MD2_CHAR RC4_INDEX RC4_CHAR RC4_CHUNK_LL DES_UNROLL DES_RISC2 DES_PTR BF_PTR SIXTY_FOUR_BIT
2458$bn_obj = asm/mips3.o
2459$des_obj =
2460$bf_obj =
2461$md5_obj =
2462$sha1_obj =
2463$cast_obj =
2464$rc4_obj =
2465$rmd160_obj =
2466$rc5_obj =
2467$dso_scheme = dlfcn
2468$shared_target= irix-shared
2469$shared_cflag =
2470$shared_ldflag =
2471$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2472$ranlib =
2473
2474*** irix64-mips4-cc
2475$cc = cc
2476$cflags = -64 -mips4 -O2 -use_readonly_const -DTERMIOS -DB_ENDIAN -DBN_DIV3W
2477$unistd =
2478$thread_cflag = -D_SGI_MP_SOURCE
2479$sys_id =
2480$lflags =
2481$bn_ops = RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG
2482$bn_obj = asm/mips3.o
2483$des_obj =
2484$bf_obj =
2485$md5_obj =
2486$sha1_obj =
2487$cast_obj =
2488$rc4_obj =
2489$rmd160_obj =
2490$rc5_obj =
2491$dso_scheme = dlfcn
2492$shared_target= irix-shared
2493$shared_cflag =
2494$shared_ldflag =
2495$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2496$ranlib =
2497
2498*** irix64-mips4-gcc
2499$cc = gcc
2500$cflags = -mabi=64 -mips4 -mmips-as -O3 -DTERMIOS -DB_ENDIAN -DBN_DIV3W
2501$unistd =
2502$thread_cflag = -D_SGI_MP_SOURCE
2503$sys_id =
2504$lflags =
2505$bn_ops = RC4_CHAR RC4_CHUNK DES_RISC2 DES_UNROLL SIXTY_FOUR_BIT_LONG
2506$bn_obj = asm/mips3.o
2507$des_obj =
2508$bf_obj =
2509$md5_obj =
2510$sha1_obj =
2511$cast_obj =
2512$rc4_obj =
2513$rmd160_obj =
2514$rc5_obj =
2515$dso_scheme = dlfcn
2516$shared_target= irix-shared
2517$shared_cflag =
2518$shared_ldflag =
2519$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2520$ranlib =
2521
2522*** linux-alpha+bwx-ccc
2523$cc = ccc
2524$cflags = -fast -readonly_strings -DL_ENDIAN -DTERMIO
2525$unistd =
2526$thread_cflag = -D_REENTRANT
2527$sys_id =
2528$lflags =
2529$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL
2530$bn_obj =
2531$des_obj =
2532$bf_obj =
2533$md5_obj =
2534$sha1_obj =
2535$cast_obj =
2536$rc4_obj =
2537$rmd160_obj =
2538$rc5_obj =
2539$dso_scheme =
2540$shared_target=
2541$shared_cflag =
2542$shared_ldflag =
2543$shared_extension =
2544$ranlib =
2545
2546*** linux-alpha+bwx-gcc
2547$cc = gcc
2548$cflags = -O3 -DL_ENDIAN -DTERMIO
2549$unistd =
2550$thread_cflag = -D_REENTRANT
2551$sys_id =
2552$lflags = -ldl
2553$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL
2554$bn_obj =
2555$des_obj =
2556$bf_obj =
2557$md5_obj =
2558$sha1_obj =
2559$cast_obj =
2560$rc4_obj =
2561$rmd160_obj =
2562$rc5_obj =
2563$dso_scheme = dlfcn
2564$shared_target= linux-shared
2565$shared_cflag = -fPIC
2566$shared_ldflag =
2567$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2568$ranlib =
2569
2570*** linux-alpha-ccc
2571$cc = ccc
2572$cflags = -fast -readonly_strings -DL_ENDIAN -DTERMIO
2573$unistd =
2574$thread_cflag = -D_REENTRANT
2575$sys_id =
2576$lflags =
2577$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL
2578$bn_obj =
2579$des_obj =
2580$bf_obj =
2581$md5_obj =
2582$sha1_obj =
2583$cast_obj =
2584$rc4_obj =
2585$rmd160_obj =
2586$rc5_obj =
2587$dso_scheme =
2588$shared_target=
2589$shared_cflag =
2590$shared_ldflag =
2591$shared_extension =
2592$ranlib =
2593
2594*** linux-alpha-gcc
2595$cc = gcc
2596$cflags = -O3 -DL_ENDIAN -DTERMIO
2597$unistd =
2598$thread_cflag = -D_REENTRANT
2599$sys_id =
2600$lflags = -ldl
2601$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL
2602$bn_obj =
2603$des_obj =
2604$bf_obj =
2605$md5_obj =
2606$sha1_obj =
2607$cast_obj =
2608$rc4_obj =
2609$rmd160_obj =
2610$rc5_obj =
2611$dso_scheme = dlfcn
2612$shared_target= linux-shared
2613$shared_cflag = -fPIC
2614$shared_ldflag =
2615$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2616$ranlib =
2617
2618*** linux-aout
2619$cc = gcc
2620$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall
2621$unistd =
2622$thread_cflag = (unknown)
2623$sys_id =
2624$lflags =
2625$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2626$bn_obj = asm/bn86-out.o asm/co86-out.o
2627$des_obj = asm/dx86-out.o asm/yx86-out.o
2628$bf_obj = asm/bx86-out.o
2629$md5_obj = asm/mx86-out.o
2630$sha1_obj = asm/sx86-out.o
2631$cast_obj = asm/cx86-out.o
2632$rc4_obj = asm/rx86-out.o
2633$rmd160_obj = asm/rm86-out.o
2634$rc5_obj = asm/r586-out.o
2635$dso_scheme =
2636$shared_target=
2637$shared_cflag =
2638$shared_ldflag =
2639$shared_extension =
2640$ranlib =
2641
2642*** linux-elf
2643$cc = gcc
2644$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall
2645$unistd =
2646$thread_cflag = -D_REENTRANT
2647$sys_id =
2648$lflags = -ldl
2649$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2650$bn_obj = asm/bn86-elf.o asm/co86-elf.o
2651$des_obj = asm/dx86-elf.o asm/yx86-elf.o
2652$bf_obj = asm/bx86-elf.o
2653$md5_obj = asm/mx86-elf.o
2654$sha1_obj = asm/sx86-elf.o
2655$cast_obj = asm/cx86-elf.o
2656$rc4_obj = asm/rx86-elf.o
2657$rmd160_obj = asm/rm86-elf.o
2658$rc5_obj = asm/r586-elf.o
2659$dso_scheme = dlfcn
2660$shared_target= linux-shared
2661$shared_cflag = -fPIC
2662$shared_ldflag =
2663$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2664$ranlib =
2665
2666*** linux-elf-arm
2667$cc = gcc
2668$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2669$unistd =
2670$thread_cflag = -D_REENTRANT
2671$sys_id =
2672$lflags =
2673$bn_ops = BN_LLONG
2674$bn_obj =
2675$des_obj =
2676$bf_obj =
2677$md5_obj =
2678$sha1_obj =
2679$cast_obj =
2680$rc4_obj =
2681$rmd160_obj =
2682$rc5_obj =
2683$dso_scheme = dlfcn
2684$shared_target= linux-shared
2685$shared_cflag = -fPIC
2686$shared_ldflag =
2687$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2688$ranlib =
2689
2690*** linux-ia64
2691$cc = gcc
2692$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2693$unistd =
2694$thread_cflag = -D_REENTRANT
2695$sys_id =
2696$lflags = -ldl
2697$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK RC4_CHAR
2698$bn_obj = asm/ia64.o
2699$des_obj =
2700$bf_obj =
2701$md5_obj =
2702$sha1_obj =
2703$cast_obj =
2704$rc4_obj =
2705$rmd160_obj =
2706$rc5_obj =
2707$dso_scheme = dlfcn
2708$shared_target= linux-shared
2709$shared_cflag = -fPIC
2710$shared_ldflag =
2711$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2712$ranlib =
2713
2714*** linux-k6
2715$cc = gcc
2716$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=k6 -Wall
2717$unistd =
2718$thread_cflag = -D_REENTRANT
2719$sys_id =
2720$lflags = -ldl
2721$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2722$bn_obj = asm/bn86-elf.o asm/co86-elf.o
2723$des_obj = asm/dx86-elf.o asm/yx86-elf.o
2724$bf_obj = asm/bx86-elf.o
2725$md5_obj = asm/mx86-elf.o
2726$sha1_obj = asm/sx86-elf.o
2727$cast_obj = asm/cx86-elf.o
2728$rc4_obj = asm/rx86-elf.o
2729$rmd160_obj = asm/rm86-elf.o
2730$rc5_obj = asm/r586-elf.o
2731$dso_scheme = dlfcn
2732$shared_target= linux-shared
2733$shared_cflag = -fPIC
2734$shared_ldflag =
2735$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2736$ranlib =
2737
2738*** linux-m68k
2739$cc = gcc
2740$cflags = -DB_ENDIAN -DTERMIO -O2 -fomit-frame-pointer -Wall
2741$unistd =
2742$thread_cflag = -D_REENTRANT
2743$sys_id =
2744$lflags =
2745$bn_ops = BN_LLONG
2746$bn_obj =
2747$des_obj =
2748$bf_obj =
2749$md5_obj =
2750$sha1_obj =
2751$cast_obj =
2752$rc4_obj =
2753$rmd160_obj =
2754$rc5_obj =
2755$dso_scheme =
2756$shared_target=
2757$shared_cflag =
2758$shared_ldflag =
2759$shared_extension =
2760$ranlib =
2761
2762*** linux-mips
2763$cc = gcc
2764$cflags = -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2765$unistd =
2766$thread_cflag = (unknown)
2767$sys_id =
2768$lflags =
2769$bn_ops = BN_LLONG
2770$bn_obj =
2771$des_obj =
2772$bf_obj =
2773$md5_obj =
2774$sha1_obj =
2775$cast_obj =
2776$rc4_obj =
2777$rmd160_obj =
2778$rc5_obj =
2779$dso_scheme =
2780$shared_target=
2781$shared_cflag =
2782$shared_ldflag =
2783$shared_extension =
2784$ranlib =
2785
2786*** linux-mipsel
2787$cc = gcc
2788$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2789$unistd =
2790$thread_cflag = (unknown)
2791$sys_id =
2792$lflags =
2793$bn_ops = BN_LLONG
2794$bn_obj =
2795$des_obj =
2796$bf_obj =
2797$md5_obj =
2798$sha1_obj =
2799$cast_obj =
2800$rc4_obj =
2801$rmd160_obj =
2802$rc5_obj =
2803$dso_scheme =
2804$shared_target=
2805$shared_cflag =
2806$shared_ldflag =
2807$shared_extension =
2808$ranlib =
2809
2810*** linux-parisc
2811$cc = gcc
2812$cflags = -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W
2813$unistd =
2814$thread_cflag = -D_REENTRANT
2815$sys_id =
2816$lflags =
2817$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
2818$bn_obj =
2819$des_obj =
2820$bf_obj =
2821$md5_obj =
2822$sha1_obj =
2823$cast_obj =
2824$rc4_obj =
2825$rmd160_obj =
2826$rc5_obj =
2827$dso_scheme =
2828$shared_target=
2829$shared_cflag =
2830$shared_ldflag =
2831$shared_extension =
2832$ranlib =
2833
2834*** linux-pentium
2835$cc = gcc
2836$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentium -Wall
2837$unistd =
2838$thread_cflag = -D_REENTRANT
2839$sys_id =
2840$lflags = -ldl
2841$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2842$bn_obj = asm/bn86-elf.o asm/co86-elf.o
2843$des_obj = asm/dx86-elf.o asm/yx86-elf.o
2844$bf_obj = asm/bx86-elf.o
2845$md5_obj = asm/mx86-elf.o
2846$sha1_obj = asm/sx86-elf.o
2847$cast_obj = asm/cx86-elf.o
2848$rc4_obj = asm/rx86-elf.o
2849$rmd160_obj = asm/rm86-elf.o
2850$rc5_obj = asm/r586-elf.o
2851$dso_scheme = dlfcn
2852$shared_target= linux-shared
2853$shared_cflag = -fPIC
2854$shared_ldflag =
2855$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2856$ranlib =
2857
2858*** linux-ppc
2859$cc = gcc
2860$cflags = -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2861$unistd =
2862$thread_cflag = -D_REENTRANT
2863$sys_id =
2864$lflags = -ldl
2865$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL
2866$bn_obj =
2867$des_obj =
2868$bf_obj =
2869$md5_obj =
2870$sha1_obj =
2871$cast_obj =
2872$rc4_obj =
2873$rmd160_obj =
2874$rc5_obj =
2875$dso_scheme = dlfcn
2876$shared_target= linux-shared
2877$shared_cflag = -fPIC
2878$shared_ldflag =
2879$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2880$ranlib =
2881
2882*** linux-ppro
2883$cc = gcc
2884$cflags = -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -mcpu=pentiumpro -Wall
2885$unistd =
2886$thread_cflag = -D_REENTRANT
2887$sys_id =
2888$lflags = -ldl
2889$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
2890$bn_obj = asm/bn86-elf.o asm/co86-elf.o
2891$des_obj = asm/dx86-elf.o asm/yx86-elf.o
2892$bf_obj = asm/bx86-elf.o
2893$md5_obj = asm/mx86-elf.o
2894$sha1_obj = asm/sx86-elf.o
2895$cast_obj = asm/cx86-elf.o
2896$rc4_obj = asm/rx86-elf.o
2897$rmd160_obj = asm/rm86-elf.o
2898$rc5_obj = asm/r586-elf.o
2899$dso_scheme = dlfcn
2900$shared_target= linux-shared
2901$shared_cflag = -fPIC
2902$shared_ldflag =
2903$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2904$ranlib =
2905
2906*** linux-s390
2907$cc = gcc
2908$cflags = -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2909$unistd =
2910$thread_cflag = -D_REENTRANT
2911$sys_id =
2912$lflags =
2913$bn_ops = BN_LLONG
2914$bn_obj =
2915$des_obj =
2916$bf_obj =
2917$md5_obj =
2918$sha1_obj =
2919$cast_obj =
2920$rc4_obj =
2921$rmd160_obj =
2922$rc5_obj =
2923$dso_scheme =
2924$shared_target=
2925$shared_cflag =
2926$shared_ldflag =
2927$shared_extension =
2928$ranlib =
2929
2930*** linux-s390x
2931$cc = gcc
2932$cflags = -DB_ENDIAN -DTERMIO -DNO_ASM -O3 -fomit-frame-pointer -Wall
2933$unistd =
2934$thread_cflag = -D_REENTRANT
2935$sys_id =
2936$lflags =
2937$bn_ops = SIXTY_FOUR_BIT_LONG
2938$bn_obj =
2939$des_obj =
2940$bf_obj =
2941$md5_obj =
2942$sha1_obj =
2943$cast_obj =
2944$rc4_obj =
2945$rmd160_obj =
2946$rc5_obj =
2947$dso_scheme =
2948$shared_target= linux-shared
2949$shared_cflag = -fPIC
2950$shared_ldflag =
2951$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
2952$ranlib =
2953
2954*** linux-sparcv7
2955$cc = gcc
2956$cflags = -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall
2957$unistd =
2958$thread_cflag = -D_REENTRANT
2959$sys_id =
2960$lflags =
2961$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
2962$bn_obj =
2963$des_obj =
2964$bf_obj =
2965$md5_obj =
2966$sha1_obj =
2967$cast_obj =
2968$rc4_obj =
2969$rmd160_obj =
2970$rc5_obj =
2971$dso_scheme =
2972$shared_target=
2973$shared_cflag =
2974$shared_ldflag =
2975$shared_extension =
2976$ranlib =
2977
2978*** linux-sparcv8
2979$cc = gcc
2980$cflags = -mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W
2981$unistd =
2982$thread_cflag = -D_REENTRANT
2983$sys_id =
2984$lflags =
2985$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
2986$bn_obj = asm/sparcv8.o
2987$des_obj =
2988$bf_obj =
2989$md5_obj =
2990$sha1_obj =
2991$cast_obj =
2992$rc4_obj =
2993$rmd160_obj =
2994$rc5_obj =
2995$dso_scheme =
2996$shared_target=
2997$shared_cflag =
2998$shared_ldflag =
2999$shared_extension =
3000$ranlib =
3001
3002*** linux-sparcv9
3003$cc = gcc
3004$cflags = -mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DBN_DIV2W
3005$unistd =
3006$thread_cflag = -D_REENTRANT
3007$sys_id = ULTRASPARC
3008$lflags =
3009$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3010$bn_obj = asm/sparcv8plus.o
3011$des_obj =
3012$bf_obj =
3013$md5_obj = asm/md5-sparcv8plus.o
3014$sha1_obj =
3015$cast_obj =
3016$rc4_obj =
3017$rmd160_obj =
3018$rc5_obj =
3019$dso_scheme = dlfcn
3020$shared_target= linux-shared
3021$shared_cflag = -fPIC
3022$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3023$shared_extension =
3024$ranlib =
3025
3026*** ncr-scde
3027$cc = cc
3028$cflags = -O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw
3029$unistd =
3030$thread_cflag = (unknown)
3031$sys_id =
3032$lflags = -lsocket -lnsl
3033$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3034$bn_obj =
3035$des_obj =
3036$bf_obj =
3037$md5_obj =
3038$sha1_obj =
3039$cast_obj =
3040$rc4_obj =
3041$rmd160_obj =
3042$rc5_obj =
3043$dso_scheme =
3044$shared_target=
3045$shared_cflag =
3046$shared_ldflag =
3047$shared_extension =
3048$ranlib =
3049
3050*** newsos4-gcc
3051$cc = gcc
3052$cflags = -O -DB_ENDIAN
3053$unistd =
3054$thread_cflag = (unknown)
3055$sys_id = NEWS4
3056$lflags = -lmld -liberty
3057$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3058$bn_obj =
3059$des_obj =
3060$bf_obj =
3061$md5_obj =
3062$sha1_obj =
3063$cast_obj =
3064$rc4_obj =
3065$rmd160_obj =
3066$rc5_obj =
3067$dso_scheme =
3068$shared_target=
3069$shared_cflag =
3070$shared_ldflag =
3071$shared_extension =
3072$ranlib =
3073
3074*** nextstep
3075$cc = cc
3076$cflags = -O -Wall
3077$unistd = <libc.h>
3078$thread_cflag = (unknown)
3079$sys_id =
3080$lflags =
3081$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3082$bn_obj =
3083$des_obj =
3084$bf_obj =
3085$md5_obj =
3086$sha1_obj =
3087$cast_obj =
3088$rc4_obj =
3089$rmd160_obj =
3090$rc5_obj =
3091$dso_scheme =
3092$shared_target=
3093$shared_cflag =
3094$shared_ldflag =
3095$shared_extension =
3096$ranlib =
3097
3098*** nextstep3.3
3099$cc = cc
3100$cflags = -O3 -Wall
3101$unistd = <libc.h>
3102$thread_cflag = (unknown)
3103$sys_id =
3104$lflags =
3105$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3106$bn_obj =
3107$des_obj =
3108$bf_obj =
3109$md5_obj =
3110$sha1_obj =
3111$cast_obj =
3112$rc4_obj =
3113$rmd160_obj =
3114$rc5_obj =
3115$dso_scheme =
3116$shared_target=
3117$shared_cflag =
3118$shared_ldflag =
3119$shared_extension =
3120$ranlib =
3121
3122*** purify
3123$cc = purify gcc
3124$cflags = -g -DPURIFY -Wall
3125$unistd =
3126$thread_cflag = (unknown)
3127$sys_id =
3128$lflags = -lsocket -lnsl
3129$bn_ops =
3130$bn_obj =
3131$des_obj =
3132$bf_obj =
3133$md5_obj =
3134$sha1_obj =
3135$cast_obj =
3136$rc4_obj =
3137$rmd160_obj =
3138$rc5_obj =
3139$dso_scheme =
3140$shared_target=
3141$shared_cflag =
3142$shared_ldflag =
3143$shared_extension =
3144$ranlib =
3145
3146*** qnx4
3147$cc = cc
3148$cflags = -DL_ENDIAN -DTERMIO
3149$unistd =
3150$thread_cflag = (unknown)
3151$sys_id =
3152$lflags =
3153$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3154$bn_obj =
3155$des_obj =
3156$bf_obj =
3157$md5_obj =
3158$sha1_obj =
3159$cast_obj =
3160$rc4_obj =
3161$rmd160_obj =
3162$rc5_obj =
3163$dso_scheme =
3164$shared_target=
3165$shared_cflag =
3166$shared_ldflag =
3167$shared_extension =
3168$ranlib =
3169
3170*** qnx6
3171$cc = cc
3172$cflags = -DL_ENDIAN -DTERMIOS
3173$unistd =
3174$thread_cflag = (unknown)
3175$sys_id =
3176$lflags = -lsocket
3177$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3178$bn_obj =
3179$des_obj =
3180$bf_obj =
3181$md5_obj =
3182$sha1_obj =
3183$cast_obj =
3184$rc4_obj =
3185$rmd160_obj =
3186$rc5_obj =
3187$dso_scheme =
3188$shared_target=
3189$shared_cflag =
3190$shared_ldflag =
3191$shared_extension =
3192$ranlib =
3193
3194*** rhapsody-ppc-cc
3195$cc = cc
3196$cflags = -O3 -DB_ENDIAN
3197$unistd =
3198$thread_cflag = (unknown)
3199$sys_id = MACOSX
3200$lflags =
3201$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3202$bn_obj =
3203$des_obj =
3204$bf_obj =
3205$md5_obj =
3206$sha1_obj =
3207$cast_obj =
3208$rc4_obj =
3209$rmd160_obj =
3210$rc5_obj =
3211$dso_scheme =
3212$shared_target=
3213$shared_cflag =
3214$shared_ldflag =
3215$shared_extension =
3216$ranlib =
3217
3218*** sco3-gcc
3219$cc = gcc
3220$cflags = -O3 -fomit-frame-pointer -Dssize_t=int -DNO_SYS_UN_H
3221$unistd =
3222$thread_cflag = (unknown)
3223$sys_id =
3224$lflags = -lsocket
3225$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3226$bn_obj =
3227$des_obj =
3228$bf_obj =
3229$md5_obj =
3230$sha1_obj =
3231$cast_obj =
3232$rc4_obj =
3233$rmd160_obj =
3234$rc5_obj =
3235$dso_scheme =
3236$shared_target=
3237$shared_cflag =
3238$shared_ldflag =
3239$shared_extension =
3240$ranlib =
3241
3242*** sco5-cc
3243$cc = cc
3244$cflags = -belf
3245$unistd =
3246$thread_cflag = (unknown)
3247$sys_id =
3248$lflags = -lsocket -lresolv -lnsl
3249$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3250$bn_obj =
3251$des_obj =
3252$bf_obj =
3253$md5_obj =
3254$sha1_obj =
3255$cast_obj =
3256$rc4_obj =
3257$rmd160_obj =
3258$rc5_obj =
3259$dso_scheme = dlfcn
3260$shared_target= svr3-shared
3261$shared_cflag = -Kpic
3262$shared_ldflag =
3263$shared_extension =
3264$ranlib =
3265
3266*** sco5-cc-pentium
3267$cc = cc
3268$cflags = -Kpentium
3269$unistd =
3270$thread_cflag = (unknown)
3271$sys_id =
3272$lflags = -lsocket
3273$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3274$bn_obj =
3275$des_obj =
3276$bf_obj =
3277$md5_obj =
3278$sha1_obj =
3279$cast_obj =
3280$rc4_obj =
3281$rmd160_obj =
3282$rc5_obj =
3283$dso_scheme =
3284$shared_target=
3285$shared_cflag =
3286$shared_ldflag =
3287$shared_extension =
3288$ranlib =
3289
3290*** sco5-gcc
3291$cc = gcc
3292$cflags = -O3 -fomit-frame-pointer
3293$unistd =
3294$thread_cflag = (unknown)
3295$sys_id =
3296$lflags = -lsocket -lresolv -lnsl
3297$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3298$bn_obj = asm/bn86-elf.o asm/co86-elf.o
3299$des_obj = asm/dx86-elf.o asm/yx86-elf.o
3300$bf_obj = asm/bx86-elf.o
3301$md5_obj = asm/mx86-elf.o
3302$sha1_obj = asm/sx86-elf.o
3303$cast_obj = asm/cx86-elf.o
3304$rc4_obj = asm/rx86-elf.o
3305$rmd160_obj = asm/rm86-elf.o
3306$rc5_obj = asm/r586-elf.o
3307$dso_scheme = dlfcn
3308$shared_target= svr3-shared
3309$shared_cflag = -fPIC
3310$shared_ldflag =
3311$shared_extension =
3312$ranlib =
3313
3314*** solaris-sparc-sc3
3315$cc = cc
3316$cflags = -fast -O -Xa -DB_ENDIAN
3317$unistd =
3318$thread_cflag = -D_REENTRANT
3319$sys_id =
3320$lflags = -lsocket -lnsl -ldl
3321$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR
3322$bn_obj =
3323$des_obj =
3324$bf_obj =
3325$md5_obj =
3326$sha1_obj =
3327$cast_obj =
3328$rc4_obj =
3329$rmd160_obj =
3330$rc5_obj =
3331$dso_scheme = dlfcn
3332$shared_target= solaris-shared
3333$shared_cflag = -KPIC
3334$shared_ldflag =
3335$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3336$ranlib =
3337
3338*** solaris-sparcv7-cc
3339$cc = cc
3340$cflags = -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W
3341$unistd =
3342$thread_cflag = -D_REENTRANT
3343$sys_id =
3344$lflags = -lsocket -lnsl -ldl
3345$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3346$bn_obj =
3347$des_obj =
3348$bf_obj =
3349$md5_obj =
3350$sha1_obj =
3351$cast_obj =
3352$rc4_obj =
3353$rmd160_obj =
3354$rc5_obj =
3355$dso_scheme = dlfcn
3356$shared_target= solaris-shared
3357$shared_cflag = -KPIC
3358$shared_ldflag =
3359$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3360$ranlib =
3361
3362*** solaris-sparcv7-gcc
3363$cc = gcc
3364$cflags = -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W
3365$unistd =
3366$thread_cflag = -D_REENTRANT
3367$sys_id =
3368$lflags = -lsocket -lnsl -ldl
3369$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3370$bn_obj =
3371$des_obj =
3372$bf_obj =
3373$md5_obj =
3374$sha1_obj =
3375$cast_obj =
3376$rc4_obj =
3377$rmd160_obj =
3378$rc5_obj =
3379$dso_scheme = dlfcn
3380$shared_target= solaris-shared
3381$shared_cflag = -fPIC
3382$shared_ldflag =
3383$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3384$ranlib =
3385
3386*** solaris-sparcv8-cc
3387$cc = cc
3388$cflags = -xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W
3389$unistd =
3390$thread_cflag = -D_REENTRANT
3391$sys_id =
3392$lflags = -lsocket -lnsl -ldl
3393$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3394$bn_obj = asm/sparcv8.o
3395$des_obj =
3396$bf_obj =
3397$md5_obj =
3398$sha1_obj =
3399$cast_obj =
3400$rc4_obj =
3401$rmd160_obj =
3402$rc5_obj =
3403$dso_scheme = dlfcn
3404$shared_target= solaris-shared
3405$shared_cflag = -KPIC
3406$shared_ldflag =
3407$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3408$ranlib =
3409
3410*** solaris-sparcv8-gcc
3411$cc = gcc
3412$cflags = -mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W
3413$unistd =
3414$thread_cflag = -D_REENTRANT
3415$sys_id =
3416$lflags = -lsocket -lnsl -ldl
3417$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3418$bn_obj = asm/sparcv8.o
3419$des_obj =
3420$bf_obj =
3421$md5_obj =
3422$sha1_obj =
3423$cast_obj =
3424$rc4_obj =
3425$rmd160_obj =
3426$rc5_obj =
3427$dso_scheme = dlfcn
3428$shared_target= solaris-shared
3429$shared_cflag = -fPIC
3430$shared_ldflag =
3431$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3432$ranlib =
3433
3434*** solaris-sparcv9-cc
3435$cc = cc
3436$cflags = -xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W
3437$unistd =
3438$thread_cflag = -D_REENTRANT
3439$sys_id = ULTRASPARC
3440$lflags = -lsocket -lnsl -ldl
3441$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3442$bn_obj = asm/sparcv8plus.o
3443$des_obj =
3444$bf_obj =
3445$md5_obj = asm/md5-sparcv8plus.o
3446$sha1_obj =
3447$cast_obj =
3448$rc4_obj =
3449$rmd160_obj =
3450$rc5_obj =
3451$dso_scheme = dlfcn
3452$shared_target= solaris-shared
3453$shared_cflag = -KPIC
3454$shared_ldflag =
3455$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3456$ranlib =
3457
3458*** solaris-sparcv9-gcc
3459$cc = gcc
3460$cflags = -m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W
3461$unistd =
3462$thread_cflag = -D_REENTRANT
3463$sys_id = ULTRASPARC
3464$lflags = -lsocket -lnsl -ldl
3465$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3466$bn_obj = asm/sparcv8plus.o
3467$des_obj =
3468$bf_obj =
3469$md5_obj = asm/md5-sparcv8plus.o
3470$sha1_obj =
3471$cast_obj =
3472$rc4_obj =
3473$rmd160_obj =
3474$rc5_obj =
3475$dso_scheme = dlfcn
3476$shared_target= solaris-shared
3477$shared_cflag = -fPIC
3478$shared_ldflag =
3479$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3480$ranlib =
3481
3482*** solaris-sparcv9-gcc27
3483$cc = gcc
3484$cflags = -mv8 -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W
3485$unistd =
3486$thread_cflag = -D_REENTRANT
3487$sys_id = ULTRASPARC
3488$lflags = -lsocket -lnsl -ldl
3489$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR
3490$bn_obj = asm/sparcv8plus-gcc27.o
3491$des_obj =
3492$bf_obj =
3493$md5_obj = asm/md5-sparcv8plus-gcc27.o
3494$sha1_obj =
3495$cast_obj =
3496$rc4_obj =
3497$rmd160_obj =
3498$rc5_obj =
3499$dso_scheme = dlfcn
3500$shared_target= solaris-shared
3501$shared_cflag = -fPIC
3502$shared_ldflag =
3503$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3504$ranlib =
3505
3506*** solaris-x86-cc
3507$cc = cc
3508$cflags = -fast -O -Xa
3509$unistd =
3510$thread_cflag = -D_REENTRANT
3511$sys_id =
3512$lflags = -lsocket -lnsl -ldl
3513$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR
3514$bn_obj =
3515$des_obj =
3516$bf_obj =
3517$md5_obj =
3518$sha1_obj =
3519$cast_obj =
3520$rc4_obj =
3521$rmd160_obj =
3522$rc5_obj =
3523$dso_scheme = dlfcn
3524$shared_target= solaris-shared
3525$shared_cflag = -KPIC
3526$shared_ldflag =
3527$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3528$ranlib =
3529
3530*** solaris-x86-gcc
3531$cc = gcc
3532$cflags = -O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DOPENSSL_NO_INLINE_ASM
3533$unistd =
3534$thread_cflag = -D_REENTRANT
3535$sys_id =
3536$lflags = -lsocket -lnsl -ldl
3537$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3538$bn_obj = asm/bn86-sol.o asm/co86-sol.o
3539$des_obj = asm/dx86-sol.o asm/yx86-sol.o
3540$bf_obj = asm/bx86-sol.o
3541$md5_obj = asm/mx86-sol.o
3542$sha1_obj = asm/sx86-sol.o
3543$cast_obj = asm/cx86-sol.o
3544$rc4_obj = asm/rx86-sol.o
3545$rmd160_obj = asm/rm86-sol.o
3546$rc5_obj = asm/r586-sol.o
3547$dso_scheme = dlfcn
3548$shared_target= solaris-shared
3549$shared_cflag = -fPIC
3550$shared_ldflag =
3551$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3552$ranlib =
3553
3554*** solaris64-sparcv9-cc
3555$cc = cc
3556$cflags = -xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN
3557$unistd =
3558$thread_cflag = -D_REENTRANT
3559$sys_id = ULTRASPARC
3560$lflags = -lsocket -lnsl -ldl
3561$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3562$bn_obj =
3563$des_obj =
3564$bf_obj =
3565$md5_obj = asm/md5-sparcv9.o
3566$sha1_obj =
3567$cast_obj =
3568$rc4_obj =
3569$rmd160_obj =
3570$rc5_obj =
3571$dso_scheme = dlfcn
3572$shared_target= solaris-shared
3573$shared_cflag = -KPIC
3574$shared_ldflag = -xarch=v9
3575$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3576$ranlib = /usr/ccs/bin/ar rs
3577
3578*** solaris64-sparcv9-gcc
3579$cc = gcc
3580$cflags = -m64 -mcpu=ultrasparc -O3 -Wall -DB_ENDIAN
3581$unistd =
3582$thread_cflag = -D_REENTRANT
3583$sys_id = ULTRASPARC
3584$lflags = -lsocket -lnsl -ldl
3585$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR
3586$bn_obj =
3587$des_obj =
3588$bf_obj =
3589$md5_obj = asm/md5-sparcv9.o
3590$sha1_obj =
3591$cast_obj =
3592$rc4_obj =
3593$rmd160_obj =
3594$rc5_obj =
3595$dso_scheme = dlfcn
3596$shared_target= solaris-shared
3597$shared_cflag = -fPIC
3598$shared_ldflag =
3599$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3600$ranlib =
3601
3602*** sunos-gcc
3603$cc = gcc
3604$cflags = -O3 -mv8 -Dssize_t=int
3605$unistd =
3606$thread_cflag = (unknown)
3607$sys_id =
3608$lflags =
3609$bn_ops = BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL DES_PTR DES_RISC1
3610$bn_obj =
3611$des_obj =
3612$bf_obj =
3613$md5_obj =
3614$sha1_obj =
3615$cast_obj =
3616$rc4_obj =
3617$rmd160_obj =
3618$rc5_obj =
3619$dso_scheme =
3620$shared_target=
3621$shared_cflag =
3622$shared_ldflag =
3623$shared_extension =
3624$ranlib =
3625
3626*** ultrix-cc
3627$cc = cc
3628$cflags = -std1 -O -Olimit 1000 -DL_ENDIAN
3629$unistd =
3630$thread_cflag = (unknown)
3631$sys_id =
3632$lflags =
3633$bn_ops =
3634$bn_obj =
3635$des_obj =
3636$bf_obj =
3637$md5_obj =
3638$sha1_obj =
3639$cast_obj =
3640$rc4_obj =
3641$rmd160_obj =
3642$rc5_obj =
3643$dso_scheme =
3644$shared_target=
3645$shared_cflag =
3646$shared_ldflag =
3647$shared_extension =
3648$ranlib =
3649
3650*** ultrix-gcc
3651$cc = gcc
3652$cflags = -O3 -DL_ENDIAN
3653$unistd =
3654$thread_cflag = (unknown)
3655$sys_id =
3656$lflags =
3657$bn_ops =
3658$bn_obj =
3659$des_obj =
3660$bf_obj =
3661$md5_obj =
3662$sha1_obj =
3663$cast_obj =
3664$rc4_obj =
3665$rmd160_obj =
3666$rc5_obj =
3667$dso_scheme =
3668$shared_target=
3669$shared_cflag =
3670$shared_ldflag =
3671$shared_extension =
3672$ranlib =
3673
3674*** unixware-2.0
3675$cc = cc
3676$cflags = -DFILIO_H
3677$unistd =
3678$thread_cflag = -Kthread
3679$sys_id =
3680$lflags = -lsocket -lnsl -lx
3681$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3682$bn_obj =
3683$des_obj =
3684$bf_obj =
3685$md5_obj =
3686$sha1_obj =
3687$cast_obj =
3688$rc4_obj =
3689$rmd160_obj =
3690$rc5_obj =
3691$dso_scheme =
3692$shared_target=
3693$shared_cflag =
3694$shared_ldflag =
3695$shared_extension =
3696$ranlib =
3697
3698*** unixware-2.0-pentium
3699$cc = cc
3700$cflags = -DFILIO_H -Kpentium
3701$unistd =
3702$thread_cflag = -Kthread
3703$sys_id =
3704$lflags = -lsocket -lnsl -lx
3705$bn_ops = MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3706$bn_obj =
3707$des_obj =
3708$bf_obj =
3709$md5_obj =
3710$sha1_obj =
3711$cast_obj =
3712$rc4_obj =
3713$rmd160_obj =
3714$rc5_obj =
3715$dso_scheme =
3716$shared_target=
3717$shared_cflag =
3718$shared_ldflag =
3719$shared_extension =
3720$ranlib =
3721
3722*** unixware-2.1
3723$cc = cc
3724$cflags = -O -DFILIO_H
3725$unistd =
3726$thread_cflag = -Kthread
3727$sys_id =
3728$lflags = -lsocket -lnsl -lx
3729$bn_ops = DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3730$bn_obj =
3731$des_obj =
3732$bf_obj =
3733$md5_obj =
3734$sha1_obj =
3735$cast_obj =
3736$rc4_obj =
3737$rmd160_obj =
3738$rc5_obj =
3739$dso_scheme =
3740$shared_target=
3741$shared_cflag =
3742$shared_ldflag =
3743$shared_extension =
3744$ranlib =
3745
3746*** unixware-2.1-p6
3747$cc = cc
3748$cflags = -O -DFILIO_H -Kp6
3749$unistd =
3750$thread_cflag = -Kthread
3751$sys_id =
3752$lflags = -lsocket -lnsl -lx
3753$bn_ops = MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3754$bn_obj =
3755$des_obj =
3756$bf_obj =
3757$md5_obj =
3758$sha1_obj =
3759$cast_obj =
3760$rc4_obj =
3761$rmd160_obj =
3762$rc5_obj =
3763$dso_scheme =
3764$shared_target=
3765$shared_cflag =
3766$shared_ldflag =
3767$shared_extension =
3768$ranlib =
3769
3770*** unixware-2.1-pentium
3771$cc = cc
3772$cflags = -O -DFILIO_H -Kpentium
3773$unistd =
3774$thread_cflag = -Kthread
3775$sys_id =
3776$lflags = -lsocket -lnsl -lx
3777$bn_ops = MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3778$bn_obj =
3779$des_obj =
3780$bf_obj =
3781$md5_obj =
3782$sha1_obj =
3783$cast_obj =
3784$rc4_obj =
3785$rmd160_obj =
3786$rc5_obj =
3787$dso_scheme =
3788$shared_target=
3789$shared_cflag =
3790$shared_ldflag =
3791$shared_extension =
3792$ranlib =
3793
3794*** unixware-7
3795$cc = cc
3796$cflags = -O -DFILIO_H -Kalloca
3797$unistd =
3798$thread_cflag = -Kthread
3799$sys_id =
3800$lflags = -lsocket -lnsl
3801$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3802$bn_obj =
3803$des_obj =
3804$bf_obj =
3805$md5_obj =
3806$sha1_obj =
3807$cast_obj =
3808$rc4_obj =
3809$rmd160_obj =
3810$rc5_obj =
3811$dso_scheme = dlfcn
3812$shared_target= svr5-shared
3813$shared_cflag = -Kpic
3814$shared_ldflag =
3815$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3816$ranlib =
3817
3818*** unixware-7-gcc
3819$cc = gcc
3820$cflags = -DL_ENDIAN -DFILIO_H -O3 -fomit-frame-pointer -m486 -Wall
3821$unistd =
3822$thread_cflag = -D_REENTRANT
3823$sys_id =
3824$lflags = -lsocket -lnsl
3825$bn_ops = BN_LLONG DES_PTR DES_RISC1 DES_UNROLL RC4_INDEX MD2_INT
3826$bn_obj =
3827$des_obj =
3828$bf_obj =
3829$md5_obj =
3830$sha1_obj =
3831$cast_obj =
3832$rc4_obj =
3833$rmd160_obj =
3834$rc5_obj =
3835$dso_scheme = dlfcn
3836$shared_target= gnu-shared
3837$shared_cflag = -fPIC
3838$shared_ldflag =
3839$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3840$ranlib =
3841
3842*** unixware-7-pentium
3843$cc = cc
3844$cflags = -O -DFILIO_H -Kalloca -Kpentium
3845$unistd =
3846$thread_cflag = -Kthread
3847$sys_id =
3848$lflags = -lsocket -lnsl
3849$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3850$bn_obj =
3851$des_obj =
3852$bf_obj =
3853$md5_obj =
3854$sha1_obj =
3855$cast_obj =
3856$rc4_obj =
3857$rmd160_obj =
3858$rc5_obj =
3859$dso_scheme = dlfcn
3860$shared_target= svr5-shared
3861$shared_cflag = -Kpic
3862$shared_ldflag =
3863$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3864$ranlib =
3865
3866*** unixware-7-pentium_pro
3867$cc = cc
3868$cflags = -O -DFILIO_H -Kalloca -Kpentium_pro
3869$unistd =
3870$thread_cflag = -Kthread
3871$sys_id =
3872$lflags = -lsocket -lnsl
3873$bn_ops = BN_LLONG MD2_CHAR RC4_INDEX DES_PTR DES_RISC1 DES_UNROLL
3874$bn_obj =
3875$des_obj =
3876$bf_obj =
3877$md5_obj =
3878$sha1_obj =
3879$cast_obj =
3880$rc4_obj =
3881$rmd160_obj =
3882$rc5_obj =
3883$dso_scheme = dlfcn
3884$shared_target= svr5-shared
3885$shared_cflag = -Kpic
3886$shared_ldflag =
3887$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
3888$ranlib =
3889
3890*** vxworks-ppc405
3891$cc = ccppc
3892$cflags = -g -msoft-float -mlongcall -DCPU=PPC405 -I$(WIND_BASE)/target/h
3893$unistd =
3894$thread_cflag =
3895$sys_id = VXWORKS
3896$lflags = -r
3897$bn_ops =
3898$bn_obj =
3899$des_obj =
3900$bf_obj =
3901$md5_obj =
3902$sha1_obj =
3903$cast_obj =
3904$rc4_obj =
3905$rmd160_obj =
3906$rc5_obj =
3907$dso_scheme =
3908$shared_target=
3909$shared_cflag =
3910$shared_ldflag =
3911$shared_extension =
3912$ranlib =
diff --git a/src/lib/libssl/src/VMS/mkshared.com b/src/lib/libssl/src/VMS/mkshared.com
new file mode 100644
index 0000000000..afdc85bbe0
--- /dev/null
+++ b/src/lib/libssl/src/VMS/mkshared.com
@@ -0,0 +1,353 @@
1$! MKSHARED.COM -- script to created shareable images on VMS
2$!
3$! No command line parameters. This should be run at the start of the source
4$! tree (the same directory where one finds INSTALL.VMS).
5$!
6$! Input: [.UTIL]LIBEAY.NUM,[.AXP.EXE.CRYPTO]LIBCRYPTO.OLB
7$! [.UTIL]SSLEAY.NUM,[.AXP.EXE.SSL]LIBSSL.OLB
8$! Output: [.AXP.EXE.CRYPTO]LIBCRYPTO.OPT,.MAP,.EXE
9$! [.AXP.EXE.SSL]LIBSSL.OPT,.MAP,.EXE
10$!
11$! So far, tests have only been made on VMS for Alpha. VAX will come in time.
12$! ===========================================================================
13$
14$! ----- Prepare info for processing: version number and file info
15$ gosub read_version_info
16$ if libver .eqs. ""
17$ then
18$ write sys$error "ERROR: Couldn't find any library version info..."
19$ exit
20$ endif
21$
22$ if f$getsyi("CPU") .ge. 128
23$ then
24$ libid = "Crypto"
25$ libnum = "[.UTIL]LIBEAY.NUM"
26$ libdir = "[.AXP.EXE.CRYPTO]"
27$ libolb = "''libdir'LIBCRYPTO.OLB"
28$ libopt = "''libdir'LIBCRYPTO.OPT"
29$ libmap = "''libdir'LIBCRYPTO.MAP"
30$ libgoal= "''libdir'LIBCRYPTO.EXE"
31$ libref = ""
32$ gosub create_axp_shr
33$ libid = "SSL"
34$ libnum = "[.UTIL]SSLEAY.NUM"
35$ libdir = "[.AXP.EXE.SSL]"
36$ libolb = "''libdir'LIBSSL.OLB"
37$ libopt = "''libdir'LIBSSL.OPT"
38$ libmap = "''libdir'LIBSSL.MAP"
39$ libgoal= "''libdir'LIBSSL.EXE"
40$ libref = "[.AXP.EXE.CRYPTO]LIBCRYPTO.EXE"
41$ gosub create_axp_shr
42$ else
43$ libtit = "CRYPTO_TRANSFER_VECTOR"
44$ libid = "Crypto"
45$ libnum = "[.UTIL]LIBEAY.NUM"
46$ libdir = "[.VAX.EXE.CRYPTO]"
47$ libmar = "''libdir'LIBCRYPTO.MAR"
48$ libolb = "''libdir'LIBCRYPTO.OLB"
49$ libopt = "''libdir'LIBCRYPTO.OPT"
50$ libobj = "''libdir'LIBCRYPTO.OBJ"
51$ libmap = "''libdir'LIBCRYPTO.MAP"
52$ libgoal= "''libdir'LIBCRYPTO.EXE"
53$ libref = ""
54$ libvec = "LIBCRYPTO"
55$ gosub create_vax_shr
56$ libtit = "SSL_TRANSFER_VECTOR"
57$ libid = "SSL"
58$ libnum = "[.UTIL]SSLEAY.NUM"
59$ libdir = "[.VAX.EXE.SSL]"
60$ libmar = "''libdir'LIBSSL.MAR"
61$ libolb = "''libdir'LIBSSL.OLB"
62$ libopt = "''libdir'LIBSSL.OPT"
63$ libobj = "''libdir'LIBSSL.OBJ"
64$ libmap = "''libdir'LIBSSL.MAP"
65$ libgoal= "''libdir'LIBSSL.EXE"
66$ libref = "[.VAX.EXE.CRYPTO]LIBCRYPTO.EXE"
67$ libvec = "LIBSSL"
68$ gosub create_vax_shr
69$ endif
70$ exit
71$
72$! ----- Soubroutines to actually build the shareable libraries
73$! The way things work, there's a main shareable library creator for each
74$! supported architecture, which is called from the main code above.
75$! The creator will define a number of variables to tell the next levels of
76$! subroutines what routines to use to write to the option files, call the
77$! main processor, read_func_num, and when that is done, it will write version
78$! data at the end of the .opt file, close it, and link the library.
79$!
80$! read_func_num reads through a .num file and calls the writer routine for
81$! each line. It's also responsible for checking that order is properly kept
82$! in the .num file, check that each line applies to VMS and the architecture,
83$! and to fill in "holes" with dummy entries.
84$!
85$! The creator routines depend on the following variables:
86$! libnum The name of the .num file to use as input
87$! libolb The name of the object library to build from
88$! libid The identification string of the shareable library
89$! libopt The name of the .opt file to write
90$! libtit The title of the assembler transfer vector file (VAX only)
91$! libmar The name of the assembler transfer vector file (VAX only)
92$! libmap The name of the map file to write
93$! libgoal The name of the shareable library to write
94$! libref The name of a shareable library to link in
95$!
96$! read_func_num depends on the following variables from the creator:
97$! libwriter The name of the writer routine to call for each .num file line
98$! -----
99$
100$! ----- Subroutines for AXP
101$! -----
102$! The creator routine
103$ create_axp_shr:
104$ open/write opt 'libopt'
105$ write opt "identification=""",libid," ",libverstr,""""
106$ write opt libolb,"/lib"
107$ if libref .nes. "" then write opt libref,"/SHARE"
108$ write opt "SYMBOL_VECTOR=(-"
109$ libfirstentry := true
110$ libwrch := opt
111$ libwriter := write_axp_transfer_entry
112$ textcount = 0
113$ gosub read_func_num
114$ write opt ")"
115$ write opt "GSMATCH=",libvmatch,",",libver
116$ close opt
117$ link/map='libmap'/full/share='libgoal' 'libopt'/option
118$ return
119$
120$! The record writer routine
121$ write_axp_transfer_entry:
122$ if libentry .eqs. ".dummy" then return
123$ if info_kind .eqs. "VARIABLE"
124$ then
125$ pr:=DATA
126$ else
127$ pr:=PROCEDURE
128$ endif
129$ textcount_this = f$length(pr) + f$length(libentry) + 5
130$ if textcount + textcount_this .gt. 1024
131$ then
132$ write opt ")"
133$ write opt "SYMBOL_VECTOR=(-"
134$ textcount = 16
135$ libfirstentry := true
136$ endif
137$ if libfirstentry
138$ then
139$ write 'libwrch' " ",libentry,"=",pr," -"
140$ else
141$ write 'libwrch' " ,",libentry,"=",pr," -"
142$ endif
143$ libfirstentry := false
144$ textcount = textcount + textcount_this
145$ return
146$
147$! ----- Subroutines for AXP
148$! -----
149$! The creator routine
150$ create_vax_shr:
151$ open/write mar 'libmar'
152$ type sys$input:/out=mar:
153;
154; Transfer vector for VAX shareable image
155;
156$ write mar " .TITLE ",libtit
157$ write mar " .IDENT /",libid,"/"
158$ type sys$input:/out=mar:
159;
160; Define macro to assist in building transfer vector entries. Each entry
161; should take no more than 8 bytes.
162;
163 .MACRO FTRANSFER_ENTRY routine
164 .ALIGN QUAD
165 .TRANSFER routine
166 .MASK routine
167 JMP routine+2
168 .ENDM FTRANSFER_ENTRY
169;
170; Place entries in own program section.
171;
172$ write mar " .PSECT $$",libvec,",QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT"
173$ write mar libvec,"_xfer:"
174$ libwrch := mar
175$ libwriter := write_vax_ftransfer_entry
176$ gosub read_func_num
177$ type sys$input:/out=mar:
178;
179; Allocate extra storage at end of vector to allow for expansion.
180;
181$ write mar " .BLKB 32768-<.-",libvec,"_xfer> ; 64 pages total."
182$! libwriter := write_vax_vtransfer_entry
183$! gosub read_func_num
184$ write mar " .END"
185$ close mar
186$ open/write opt 'libopt'
187$ write opt "identification=""",libid," ",libverstr,""""
188$ write opt libobj
189$ write opt libolb,"/lib"
190$ if libref .nes. "" then write opt libref,"/SHARE"
191$ type sys$input:/out=opt:
192!
193! Ensure transfer vector is at beginning of image
194!
195CLUSTER=FIRST
196$ write opt "COLLECT=FIRST,$$",libvec
197$ write opt "GSMATCH=",libvmatch,",",libver
198$ type sys$input:/out=opt:
199!
200! make psects nonshareable so image can be installed.
201!
202PSECT_ATTR=$CHAR_STRING_CONSTANTS,NOWRT
203$ libwrch := opt
204$ libwriter := write_vax_psect_attr
205$ gosub read_func_num
206$ close opt
207$ macro/obj='libobj' 'libmar'
208$ link/map='libmap'/full/share='libgoal' 'libopt'/option
209$ return
210$
211$! The record writer routine for VAX functions
212$ write_vax_ftransfer_entry:
213$ if info_kind .nes. "FUNCTION" then return
214$ if libentry .eqs ".dummy"
215$ then
216$ write 'libwrch' " .BLKB 8" ! Dummy is zeroes...
217$ else
218$ write 'libwrch' " FTRANSFER_ENTRY ",libentry
219$ endif
220$ return
221$! The record writer routine for VAX variables (should never happen!)
222$ write_vax_psect_attr:
223$ if info_kind .nes. "VARIABLE" then return
224$ if libentry .eqs ".dummy" then return
225$ write 'libwrch' "PSECT_ATTR=",libentry,",NOSHR"
226$ return
227$
228$! ----- Common subroutines
229$! -----
230$! The .num file reader. This one has great responsability.
231$ read_func_num:
232$ open libnum 'libnum'
233$ goto read_nums
234$
235$ read_nums:
236$ libentrynum=0
237$ liblastentry:=false
238$ entrycount=0
239$ loop:
240$ read/end=loop_end/err=loop_end libnum line
241$ entrynum=f$int(f$element(1," ",f$edit(line,"COMPRESS,TRIM")))
242$ entryinfo=f$element(2," ",f$edit(line,"COMPRESS,TRIM"))
243$ curentry=f$element(0," ",f$edit(line,"COMPRESS,TRIM"))
244$ info_exist=f$element(0,":",entryinfo)
245$ info_platforms=","+f$element(1,":",entryinfo)+","
246$ info_kind=f$element(2,":",entryinfo)
247$ info_algorithms=","+f$element(3,":",entryinfo)+","
248$ if info_exist .eqs. "NOEXIST" then goto loop
249$ truesum = 0
250$ falsesum = 0
251$ negatives = 1
252$ plat_i = 0
253$ loop1:
254$ plat_entry = f$element(plat_i,",",info_platforms)
255$ plat_i = plat_i + 1
256$ if plat_entry .eqs. "" then goto loop1
257$ if plat_entry .nes. ","
258$ then
259$ if f$extract(0,1,plat_entry) .nes. "!" then negatives = 0
260$ if f$getsyi("CPU") .lt. 128
261$ then
262$ if plat_entry .eqs. "EXPORT_VAR_AS_FUNCTION" then -
263$ truesum = truesum + 1
264$ if plat_entry .eqs. "!EXPORT_VAR_AS_FUNCTION" then -
265$ falsesum = falsesum + 1
266$ endif
267$ if plat_entry .eqs. "VMS" then truesum = truesum + 1
268$ if plat_entry .eqs. "!VMS" then falsesum = falsesum + 1
269$ goto loop1
270$ endif
271$ endloop1:
272$!DEBUG!$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
273$!DEBUG!$ then
274$!DEBUG!$ write sys$output line
275$!DEBUG!$ write sys$output " truesum = ",truesum,-
276$!DEBUG! ", negatives = ",negatives,", falsesum = ",falsesum
277$!DEBUG!$ endif
278$ if falsesum .ne. 0 then goto loop
279$ if truesum+negatives .eq. 0 then goto loop
280$ alg_i = 0
281$ loop2:
282$ alg_entry = f$element(alg_i,",",info_algorithms)
283$ alg_i = alg_i + 1
284$ if alg_entry .eqs. "" then goto loop2
285$ if alg_entry .nes. ","
286$ then
287$ if alg_entry .eqs. "KRB5" then goto loop ! Special for now
288$ if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
289$ goto loop2
290$ endif
291$ endloop2:
292$ if info_platforms - "EXPORT_VAR_AS_FUNCTION" .nes. info_platforms
293$ then
294$!DEBUG!$ write sys$output curentry," ; ",entrynum," ; ",entryinfo
295$ endif
296$ redo:
297$ next:=loop
298$ tolibentry=curentry
299$ if libentrynum .ne. entrynum
300$ then
301$ entrycount=entrycount+1
302$ if entrycount .lt. entrynum
303$ then
304$!DEBUG!$ write sys$output "Info: entrycount: ''entrycount', entrynum: ''entrynum' => 0"
305$ tolibentry=".dummy"
306$ next:=redo
307$ endif
308$ if entrycount .gt. entrynum
309$ then
310$ write sys$error "Decreasing library entry numbers! Can't continue"
311$ write sys$error """",line,""""
312$ close libnum
313$ return
314$ endif
315$ libentry=tolibentry
316$!DEBUG!$ write sys$output entrycount," ",libentry," ",entryinfo
317$ if libentry .nes. "" .and. libwriter .nes. "" then gosub 'libwriter'
318$ else
319$ write sys$error "Info: ""''curentry'"" is an alias for ""''libentry'"". Overriding..."
320$ endif
321$ libentrynum=entrycount
322$ goto 'next'
323$ loop_end:
324$ close libnum
325$ return
326$
327$! The version number reader
328$ read_version_info:
329$ libver = ""
330$ open/read vf [.CRYPTO]OPENSSLV.H
331$ loop_rvi:
332$ read/err=endloop_rvi/end=endloop_rvi vf rvi_line
333$ if rvi_line - "SHLIB_VERSION_NUMBER """ .eqs. rvi_line then -
334 goto loop_rvi
335$ libverstr = f$element(1,"""",rvi_line)
336$ libvmajor = f$element(0,".",libverstr)
337$ libvminor = f$element(1,".",libverstr)
338$ libvedit = f$element(2,".",libverstr)
339$ libvpatch = f$cvui(0,8,f$extract(1,1,libvedit)+"@")-f$cvui(0,8,"@")
340$ libvedit = f$extract(0,1,libvedit)
341$ libver = f$string(f$int(libvmajor)*100)+","+-
342 f$string(f$int(libvminor)*100+f$int(libvedit)*10+f$int(libvpatch))
343$ if libvmajor .eqs. "0"
344$ then
345$ libvmatch = "EQUAL"
346$ else
347$ ! Starting with the 1.0 release, backward compatibility should be
348$ ! kept, so switch over to the following
349$ libvmatch = "LEQUAL"
350$ endif
351$ endloop_rvi:
352$ close vf
353$ return
diff --git a/src/lib/libssl/src/apps/CA.pl b/src/lib/libssl/src/apps/CA.pl
index 3d0f9ea7f4..64ad92eb78 100644
--- a/src/lib/libssl/src/apps/CA.pl
+++ b/src/lib/libssl/src/apps/CA.pl
@@ -5,7 +5,7 @@
5# things easier between now and when Eric is convinced to fix it :-) 5# things easier between now and when Eric is convinced to fix it :-)
6# 6#
7# CA -newca ... will setup the right stuff 7# CA -newca ... will setup the right stuff
8# CA -newreq ... will generate a certificate request 8# CA -newreq[-nodes] ... will generate a certificate request
9# CA -sign ... will sign the generated request and output 9# CA -sign ... will sign the generated request and output
10# 10#
11# At the end of that grab newreq.pem and newcert.pem (one has the key 11# At the end of that grab newreq.pem and newcert.pem (one has the key
@@ -54,7 +54,7 @@ $RET = 0;
54 54
55foreach (@ARGV) { 55foreach (@ARGV) {
56 if ( /^(-\?|-h|-help)$/ ) { 56 if ( /^(-\?|-h|-help)$/ ) {
57 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n"; 57 print STDERR "usage: CA -newcert|-newreq|newreq-nodes|-newca|-sign|-verify\n";
58 exit 0; 58 exit 0;
59 } elsif (/^-newcert$/) { 59 } elsif (/^-newcert$/) {
60 # create a certificate 60 # create a certificate
@@ -66,6 +66,11 @@ foreach (@ARGV) {
66 system ("$REQ -new -keyout newreq.pem -out newreq.pem $DAYS"); 66 system ("$REQ -new -keyout newreq.pem -out newreq.pem $DAYS");
67 $RET=$?; 67 $RET=$?;
68 print "Request (and private key) is in newreq.pem\n"; 68 print "Request (and private key) is in newreq.pem\n";
69 } elsif (/^-newreq-nodes$/) {
70 # create a certificate request
71 system ("$REQ -new -nodes -keyout newreq.pem -out newreq.pem $DAYS");
72 $RET=$?;
73 print "Request (and private key) is in newreq.pem\n";
69 } elsif (/^-newca$/) { 74 } elsif (/^-newca$/) {
70 # if explicitly asked for or it doesn't exist then setup the 75 # if explicitly asked for or it doesn't exist then setup the
71 # directory structure that Eric likes to manage things 76 # directory structure that Eric likes to manage things
@@ -143,7 +148,7 @@ foreach (@ARGV) {
143 } 148 }
144 } else { 149 } else {
145 print STDERR "Unknown arg $_\n"; 150 print STDERR "Unknown arg $_\n";
146 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n"; 151 print STDERR "usage: CA -newcert|-newreq|newreq-nodes|-newca|-sign|-verify\n";
147 exit 1; 152 exit 1;
148 } 153 }
149} 154}
diff --git a/src/lib/libssl/src/apps/CA.pl.in b/src/lib/libssl/src/apps/CA.pl.in
index f1ac7e7726..8b2ce7ea42 100644
--- a/src/lib/libssl/src/apps/CA.pl.in
+++ b/src/lib/libssl/src/apps/CA.pl.in
@@ -5,7 +5,7 @@
5# things easier between now and when Eric is convinced to fix it :-) 5# things easier between now and when Eric is convinced to fix it :-)
6# 6#
7# CA -newca ... will setup the right stuff 7# CA -newca ... will setup the right stuff
8# CA -newreq ... will generate a certificate request 8# CA -newreq[-nodes] ... will generate a certificate request
9# CA -sign ... will sign the generated request and output 9# CA -sign ... will sign the generated request and output
10# 10#
11# At the end of that grab newreq.pem and newcert.pem (one has the key 11# At the end of that grab newreq.pem and newcert.pem (one has the key
@@ -54,7 +54,7 @@ $RET = 0;
54 54
55foreach (@ARGV) { 55foreach (@ARGV) {
56 if ( /^(-\?|-h|-help)$/ ) { 56 if ( /^(-\?|-h|-help)$/ ) {
57 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n"; 57 print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
58 exit 0; 58 exit 0;
59 } elsif (/^-newcert$/) { 59 } elsif (/^-newcert$/) {
60 # create a certificate 60 # create a certificate
@@ -66,6 +66,11 @@ foreach (@ARGV) {
66 system ("$REQ -new -keyout newreq.pem -out newreq.pem $DAYS"); 66 system ("$REQ -new -keyout newreq.pem -out newreq.pem $DAYS");
67 $RET=$?; 67 $RET=$?;
68 print "Request (and private key) is in newreq.pem\n"; 68 print "Request (and private key) is in newreq.pem\n";
69 } elsif (/^-newreq-nodes$/) {
70 # create a certificate request
71 system ("$REQ -new -nodes -keyout newreq.pem -out newreq.pem $DAYS");
72 $RET=$?;
73 print "Request (and private key) is in newreq.pem\n";
69 } elsif (/^-newca$/) { 74 } elsif (/^-newca$/) {
70 # if explicitly asked for or it doesn't exist then setup the 75 # if explicitly asked for or it doesn't exist then setup the
71 # directory structure that Eric likes to manage things 76 # directory structure that Eric likes to manage things
@@ -143,7 +148,7 @@ foreach (@ARGV) {
143 } 148 }
144 } else { 149 } else {
145 print STDERR "Unknown arg $_\n"; 150 print STDERR "Unknown arg $_\n";
146 print STDERR "usage: CA -newcert|-newreq|-newca|-sign|-verify\n"; 151 print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
147 exit 1; 152 exit 1;
148 } 153 }
149} 154}
diff --git a/src/lib/libssl/src/apps/Makefile.ssl b/src/lib/libssl/src/apps/Makefile.ssl
index 75aeb56df3..1d658d4e39 100644
--- a/src/lib/libssl/src/apps/Makefile.ssl
+++ b/src/lib/libssl/src/apps/Makefile.ssl
@@ -5,21 +5,27 @@
5DIR= apps 5DIR= apps
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDES= -I../include 8INCLUDES= -I$(TOP) -I../include $(KRB5_INCLUDES)
9CFLAG= -g -static 9CFLAG= -g -static
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11INSTALLTOP= /usr/local/ssl 11INSTALLTOP= /usr/local/ssl
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /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
16PERL=/usr/local/bin/perl 17PERL= perl
17RM= rm -f 18RM= rm -f
19# KRB5 stuff
20KRB5_INCLUDES=
21LIBKRB5=
18 22
19PEX_LIBS= 23PEX_LIBS=
20EX_LIBS= 24EX_LIBS=
21EXE_EXT= 25EXE_EXT=
22 26
27SHLIB_TARGET=
28
23CFLAGS= -DMONOLITH $(INCLUDES) $(CFLAG) 29CFLAGS= -DMONOLITH $(INCLUDES) $(CFLAG)
24 30
25GENERAL=Makefile makeapps.com install.com 31GENERAL=Makefile makeapps.com install.com
@@ -39,7 +45,7 @@ E_EXE= verify asn1pars req dgst dh dhparam enc passwd gendh errstr \
39 ca crl rsa rsautl dsa dsaparam \ 45 ca crl rsa rsautl dsa dsaparam \
40 x509 genrsa gendsa s_server s_client speed \ 46 x509 genrsa gendsa s_server s_client speed \
41 s_time version pkcs7 crl2pkcs7 sess_id ciphers nseq pkcs12 \ 47 s_time version pkcs7 crl2pkcs7 sess_id ciphers nseq pkcs12 \
42 pkcs8 spkac smime rand 48 pkcs8 spkac smime rand engine ocsp
43 49
44PROGS= $(PROGRAM).c 50PROGS= $(PROGRAM).c
45 51
@@ -55,14 +61,14 @@ E_OBJ= verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o er
55 rsa.o rsautl.o dsa.o dsaparam.o \ 61 rsa.o rsautl.o dsa.o dsaparam.o \
56 x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o \ 62 x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o \
57 s_time.o $(A_OBJ) $(S_OBJ) $(RAND_OBJ) version.o sess_id.o \ 63 s_time.o $(A_OBJ) $(S_OBJ) $(RAND_OBJ) version.o sess_id.o \
58 ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o 64 ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o engine.o ocsp.o
59 65
60E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c \ 66E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c passwd.c gendh.c errstr.c ca.c \
61 pkcs7.c crl2p7.c crl.c \ 67 pkcs7.c crl2p7.c crl.c \
62 rsa.c rsautl.c dsa.c dsaparam.c \ 68 rsa.c rsautl.c dsa.c dsaparam.c \
63 x509.c genrsa.c gendsa.c s_server.c s_client.c speed.c \ 69 x509.c genrsa.c gendsa.c s_server.c s_client.c speed.c \
64 s_time.c $(A_SRC) $(S_SRC) $(RAND_SRC) version.c sess_id.c \ 70 s_time.c $(A_SRC) $(S_SRC) $(RAND_SRC) version.c sess_id.c \
65 ciphers.c nseq.c pkcs12.c pkcs8.c spkac.c smime.c rand.c 71 ciphers.c nseq.c pkcs12.c pkcs8.c spkac.c smime.c rand.c engine.c ocsp.c
66 72
67SRC=$(E_SRC) 73SRC=$(E_SRC)
68 74
@@ -135,8 +141,15 @@ $(DLIBCRYPTO):
135 141
136$(PROGRAM): progs.h $(E_OBJ) $(PROGRAM).o $(DLIBCRYPTO) $(DLIBSSL) 142$(PROGRAM): progs.h $(E_OBJ) $(PROGRAM).o $(DLIBCRYPTO) $(DLIBSSL)
137 $(RM) $(PROGRAM) 143 $(RM) $(PROGRAM)
138 $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) 144 if [ "$(SHLIB_TARGET)" = "hpux-shared" ] ; then \
139 -(cd ..; OPENSSL="`pwd`/apps/openssl"; export OPENSSL; $(PERL) tools/c_rehash certs) 145 $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(DLIBSSL) $(LIBKRB5) $(DLIBCRYPTO) $(EX_LIBS) ; \
146 else \
147 $(CC) -o $(PROGRAM) $(CFLAGS) $(PROGRAM).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBKRB5) $(LIBCRYPTO) $(EX_LIBS) ; \
148 fi
149 -(cd ..; OPENSSL="`pwd`/apps/openssl"; export OPENSSL; \
150 LIBPATH="`pwd`"; LD_LIBRARY_PATH="`pwd`"; SHLIB_PATH="`pwd`"; \
151 export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
152 $(PERL) tools/c_rehash certs)
140 153
141progs.h: progs.pl 154progs.h: progs.pl
142 $(PERL) progs.pl $(E_EXE) >progs.h 155 $(PERL) progs.pl $(E_EXE) >progs.h
@@ -144,727 +157,619 @@ progs.h: progs.pl
144 157
145# DO NOT DELETE THIS LINE -- make depend depends on it. 158# DO NOT DELETE THIS LINE -- make depend depends on it.
146 159
147app_rand.o: ../include/openssl/asn1.h ../include/openssl/bio.h 160app_rand.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
148app_rand.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 161app_rand.o: ../include/openssl/bn.h ../include/openssl/buffer.h
149app_rand.o: ../include/openssl/buffer.h ../include/openssl/cast.h
150app_rand.o: ../include/openssl/conf.h ../include/openssl/crypto.h 162app_rand.o: ../include/openssl/conf.h ../include/openssl/crypto.h
151app_rand.o: ../include/openssl/des.h ../include/openssl/dh.h 163app_rand.o: ../include/openssl/dh.h ../include/openssl/dsa.h
152app_rand.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 164app_rand.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
153app_rand.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 165app_rand.o: ../include/openssl/err.h ../include/openssl/evp.h
154app_rand.o: ../include/openssl/evp.h ../include/openssl/idea.h 166app_rand.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
155app_rand.o: ../include/openssl/lhash.h ../include/openssl/md2.h
156app_rand.o: ../include/openssl/md4.h ../include/openssl/md5.h
157app_rand.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
158app_rand.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 167app_rand.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
159app_rand.o: ../include/openssl/opensslv.h ../include/openssl/pkcs7.h 168app_rand.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
160app_rand.o: ../include/openssl/rand.h ../include/openssl/rc2.h 169app_rand.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
161app_rand.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 170app_rand.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
162app_rand.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 171app_rand.o: ../include/openssl/sha.h ../include/openssl/stack.h
163app_rand.o: ../include/openssl/safestack.h ../include/openssl/sha.h 172app_rand.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
164app_rand.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 173app_rand.o: ../include/openssl/ui.h ../include/openssl/x509.h
165app_rand.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 174app_rand.o: ../include/openssl/x509_vfy.h app_rand.c apps.h
166apps.o: ../include/openssl/asn1.h ../include/openssl/bio.h 175apps.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
167apps.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 176apps.o: ../include/openssl/bn.h ../include/openssl/buffer.h
168apps.o: ../include/openssl/buffer.h ../include/openssl/cast.h
169apps.o: ../include/openssl/conf.h ../include/openssl/crypto.h 177apps.o: ../include/openssl/conf.h ../include/openssl/crypto.h
170apps.o: ../include/openssl/des.h ../include/openssl/dh.h 178apps.o: ../include/openssl/dh.h ../include/openssl/dsa.h
171apps.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 179apps.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
172apps.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
173apps.o: ../include/openssl/err.h ../include/openssl/evp.h 180apps.o: ../include/openssl/err.h ../include/openssl/evp.h
174apps.o: ../include/openssl/idea.h ../include/openssl/lhash.h 181apps.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
175apps.o: ../include/openssl/md2.h ../include/openssl/md4.h 182apps.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
176apps.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 183apps.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
177apps.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
178apps.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
179apps.o: ../include/openssl/pem.h ../include/openssl/pem2.h 184apps.o: ../include/openssl/pem.h ../include/openssl/pem2.h
180apps.o: ../include/openssl/pkcs12.h ../include/openssl/pkcs7.h 185apps.o: ../include/openssl/pkcs12.h ../include/openssl/pkcs7.h
181apps.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 186apps.o: ../include/openssl/rand.h ../include/openssl/rsa.h
182apps.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 187apps.o: ../include/openssl/safestack.h ../include/openssl/sha.h
183apps.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 188apps.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
184apps.o: ../include/openssl/sha.h ../include/openssl/stack.h 189apps.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
185apps.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 190apps.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
186apps.o: ../include/openssl/x509_vfy.h apps.h 191apps.o: ../include/openssl/x509v3.h apps.c apps.h
187asn1pars.o: ../include/openssl/asn1.h ../include/openssl/bio.h 192asn1pars.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
188asn1pars.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 193asn1pars.o: ../include/openssl/bn.h ../include/openssl/buffer.h
189asn1pars.o: ../include/openssl/buffer.h ../include/openssl/cast.h
190asn1pars.o: ../include/openssl/conf.h ../include/openssl/crypto.h 194asn1pars.o: ../include/openssl/conf.h ../include/openssl/crypto.h
191asn1pars.o: ../include/openssl/des.h ../include/openssl/dh.h 195asn1pars.o: ../include/openssl/dh.h ../include/openssl/dsa.h
192asn1pars.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 196asn1pars.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
193asn1pars.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
194asn1pars.o: ../include/openssl/err.h ../include/openssl/evp.h 197asn1pars.o: ../include/openssl/err.h ../include/openssl/evp.h
195asn1pars.o: ../include/openssl/idea.h ../include/openssl/lhash.h 198asn1pars.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
196asn1pars.o: ../include/openssl/md2.h ../include/openssl/md4.h 199asn1pars.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
197asn1pars.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 200asn1pars.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
198asn1pars.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
199asn1pars.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
200asn1pars.o: ../include/openssl/pem.h ../include/openssl/pem2.h 201asn1pars.o: ../include/openssl/pem.h ../include/openssl/pem2.h
201asn1pars.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 202asn1pars.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
202asn1pars.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 203asn1pars.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
203asn1pars.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 204asn1pars.o: ../include/openssl/sha.h ../include/openssl/stack.h
204asn1pars.o: ../include/openssl/safestack.h ../include/openssl/sha.h 205asn1pars.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
205asn1pars.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 206asn1pars.o: ../include/openssl/ui.h ../include/openssl/x509.h
206asn1pars.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 207asn1pars.o: ../include/openssl/x509_vfy.h apps.h asn1pars.c
207ca.o: ../include/openssl/asn1.h ../include/openssl/bio.h 208ca.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
208ca.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 209ca.o: ../include/openssl/bn.h ../include/openssl/buffer.h
209ca.o: ../include/openssl/buffer.h ../include/openssl/cast.h
210ca.o: ../include/openssl/conf.h ../include/openssl/crypto.h 210ca.o: ../include/openssl/conf.h ../include/openssl/crypto.h
211ca.o: ../include/openssl/des.h ../include/openssl/dh.h ../include/openssl/dsa.h 211ca.o: ../include/openssl/dh.h ../include/openssl/dsa.h
212ca.o: ../include/openssl/e_os.h ../include/openssl/e_os.h
213ca.o: ../include/openssl/e_os2.h ../include/openssl/engine.h 212ca.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
214ca.o: ../include/openssl/err.h ../include/openssl/evp.h 213ca.o: ../include/openssl/err.h ../include/openssl/evp.h
215ca.o: ../include/openssl/idea.h ../include/openssl/lhash.h 214ca.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
216ca.o: ../include/openssl/md2.h ../include/openssl/md4.h 215ca.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
217ca.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
218ca.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
219ca.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 216ca.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
220ca.o: ../include/openssl/pem.h ../include/openssl/pem2.h 217ca.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
221ca.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 218ca.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
222ca.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 219ca.o: ../include/openssl/rand.h ../include/openssl/rsa.h
223ca.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 220ca.o: ../include/openssl/safestack.h ../include/openssl/sha.h
224ca.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 221ca.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
225ca.o: ../include/openssl/sha.h ../include/openssl/stack.h 222ca.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
226ca.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
227ca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 223ca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
228ca.o: ../include/openssl/x509v3.h apps.h 224ca.o: ../include/openssl/x509v3.h apps.h ca.c
229ciphers.o: ../include/openssl/asn1.h ../include/openssl/bio.h 225ciphers.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
230ciphers.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 226ciphers.o: ../include/openssl/bn.h ../include/openssl/buffer.h
231ciphers.o: ../include/openssl/buffer.h ../include/openssl/cast.h
232ciphers.o: ../include/openssl/comp.h ../include/openssl/conf.h 227ciphers.o: ../include/openssl/comp.h ../include/openssl/conf.h
233ciphers.o: ../include/openssl/crypto.h ../include/openssl/des.h 228ciphers.o: ../include/openssl/crypto.h ../include/openssl/dh.h
234ciphers.o: ../include/openssl/dh.h ../include/openssl/dsa.h 229ciphers.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
235ciphers.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 230ciphers.o: ../include/openssl/engine.h ../include/openssl/err.h
236ciphers.o: ../include/openssl/e_os2.h ../include/openssl/err.h 231ciphers.o: ../include/openssl/evp.h ../include/openssl/kssl.h
237ciphers.o: ../include/openssl/evp.h ../include/openssl/idea.h 232ciphers.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
238ciphers.o: ../include/openssl/lhash.h ../include/openssl/md2.h
239ciphers.o: ../include/openssl/md4.h ../include/openssl/md5.h
240ciphers.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
241ciphers.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 233ciphers.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
242ciphers.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 234ciphers.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
243ciphers.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 235ciphers.o: ../include/openssl/pem.h ../include/openssl/pem2.h
244ciphers.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 236ciphers.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
245ciphers.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
246ciphers.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 237ciphers.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
247ciphers.o: ../include/openssl/sha.h ../include/openssl/ssl.h 238ciphers.o: ../include/openssl/sha.h ../include/openssl/ssl.h
248ciphers.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 239ciphers.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
249ciphers.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 240ciphers.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
250ciphers.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 241ciphers.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
242ciphers.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
251ciphers.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 243ciphers.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
252crl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 244ciphers.o: ciphers.c
253crl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 245crl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
254crl.o: ../include/openssl/buffer.h ../include/openssl/cast.h 246crl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
255crl.o: ../include/openssl/conf.h ../include/openssl/crypto.h 247crl.o: ../include/openssl/conf.h ../include/openssl/crypto.h
256crl.o: ../include/openssl/des.h ../include/openssl/dh.h 248crl.o: ../include/openssl/dh.h ../include/openssl/dsa.h
257crl.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 249crl.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
258crl.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
259crl.o: ../include/openssl/err.h ../include/openssl/evp.h 250crl.o: ../include/openssl/err.h ../include/openssl/evp.h
260crl.o: ../include/openssl/idea.h ../include/openssl/lhash.h 251crl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
261crl.o: ../include/openssl/md2.h ../include/openssl/md4.h 252crl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
262crl.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 253crl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
263crl.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
264crl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
265crl.o: ../include/openssl/pem.h ../include/openssl/pem2.h 254crl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
266crl.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 255crl.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
267crl.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 256crl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
268crl.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 257crl.o: ../include/openssl/sha.h ../include/openssl/stack.h
269crl.o: ../include/openssl/safestack.h ../include/openssl/sha.h 258crl.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
270crl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 259crl.o: ../include/openssl/ui.h ../include/openssl/x509.h
271crl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 260crl.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h crl.c
272crl.o: ../include/openssl/x509v3.h apps.h 261crl2p7.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
273crl2p7.o: ../include/openssl/asn1.h ../include/openssl/bio.h 262crl2p7.o: ../include/openssl/bn.h ../include/openssl/buffer.h
274crl2p7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
275crl2p7.o: ../include/openssl/buffer.h ../include/openssl/cast.h
276crl2p7.o: ../include/openssl/conf.h ../include/openssl/crypto.h 263crl2p7.o: ../include/openssl/conf.h ../include/openssl/crypto.h
277crl2p7.o: ../include/openssl/des.h ../include/openssl/dh.h 264crl2p7.o: ../include/openssl/dh.h ../include/openssl/dsa.h
278crl2p7.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 265crl2p7.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
279crl2p7.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
280crl2p7.o: ../include/openssl/err.h ../include/openssl/evp.h 266crl2p7.o: ../include/openssl/err.h ../include/openssl/evp.h
281crl2p7.o: ../include/openssl/idea.h ../include/openssl/lhash.h 267crl2p7.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
282crl2p7.o: ../include/openssl/md2.h ../include/openssl/md4.h 268crl2p7.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
283crl2p7.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 269crl2p7.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
284crl2p7.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
285crl2p7.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
286crl2p7.o: ../include/openssl/pem.h ../include/openssl/pem2.h 270crl2p7.o: ../include/openssl/pem.h ../include/openssl/pem2.h
287crl2p7.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 271crl2p7.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
288crl2p7.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 272crl2p7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
289crl2p7.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 273crl2p7.o: ../include/openssl/sha.h ../include/openssl/stack.h
290crl2p7.o: ../include/openssl/safestack.h ../include/openssl/sha.h 274crl2p7.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
291crl2p7.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 275crl2p7.o: ../include/openssl/ui.h ../include/openssl/x509.h
292crl2p7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 276crl2p7.o: ../include/openssl/x509_vfy.h apps.h crl2p7.c
293dgst.o: ../include/openssl/asn1.h ../include/openssl/bio.h 277dgst.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
294dgst.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 278dgst.o: ../include/openssl/bn.h ../include/openssl/buffer.h
295dgst.o: ../include/openssl/buffer.h ../include/openssl/cast.h
296dgst.o: ../include/openssl/conf.h ../include/openssl/crypto.h 279dgst.o: ../include/openssl/conf.h ../include/openssl/crypto.h
297dgst.o: ../include/openssl/des.h ../include/openssl/dh.h 280dgst.o: ../include/openssl/dh.h ../include/openssl/dsa.h
298dgst.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 281dgst.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
299dgst.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 282dgst.o: ../include/openssl/err.h ../include/openssl/evp.h
300dgst.o: ../include/openssl/engine.h ../include/openssl/err.h 283dgst.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
301dgst.o: ../include/openssl/evp.h ../include/openssl/idea.h
302dgst.o: ../include/openssl/lhash.h ../include/openssl/md2.h
303dgst.o: ../include/openssl/md4.h ../include/openssl/md5.h
304dgst.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
305dgst.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 284dgst.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
306dgst.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 285dgst.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
307dgst.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 286dgst.o: ../include/openssl/pem.h ../include/openssl/pem2.h
308dgst.o: ../include/openssl/rand.h ../include/openssl/rc2.h 287dgst.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
309dgst.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 288dgst.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
310dgst.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 289dgst.o: ../include/openssl/sha.h ../include/openssl/stack.h
311dgst.o: ../include/openssl/safestack.h ../include/openssl/sha.h 290dgst.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
312dgst.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 291dgst.o: ../include/openssl/ui.h ../include/openssl/x509.h
313dgst.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 292dgst.o: ../include/openssl/x509_vfy.h apps.h dgst.c
314dh.o: ../include/openssl/asn1.h ../include/openssl/bio.h 293dh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
315dh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 294dh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
316dh.o: ../include/openssl/buffer.h ../include/openssl/cast.h
317dh.o: ../include/openssl/conf.h ../include/openssl/crypto.h 295dh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
318dh.o: ../include/openssl/des.h ../include/openssl/dh.h ../include/openssl/dsa.h 296dh.o: ../include/openssl/dh.h ../include/openssl/dsa.h
319dh.o: ../include/openssl/e_os.h ../include/openssl/e_os.h
320dh.o: ../include/openssl/e_os2.h ../include/openssl/engine.h 297dh.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
321dh.o: ../include/openssl/err.h ../include/openssl/evp.h 298dh.o: ../include/openssl/err.h ../include/openssl/evp.h
322dh.o: ../include/openssl/idea.h ../include/openssl/lhash.h 299dh.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
323dh.o: ../include/openssl/md2.h ../include/openssl/md4.h 300dh.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
324dh.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 301dh.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
325dh.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
326dh.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
327dh.o: ../include/openssl/pem.h ../include/openssl/pem2.h 302dh.o: ../include/openssl/pem.h ../include/openssl/pem2.h
328dh.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 303dh.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
329dh.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
330dh.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
331dh.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 304dh.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
332dh.o: ../include/openssl/sha.h ../include/openssl/stack.h 305dh.o: ../include/openssl/sha.h ../include/openssl/stack.h
333dh.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 306dh.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
334dh.o: ../include/openssl/x509_vfy.h apps.h 307dh.o: ../include/openssl/ui.h ../include/openssl/x509.h
335dsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 308dh.o: ../include/openssl/x509_vfy.h apps.h dh.c
336dsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 309dsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
337dsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h 310dsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
338dsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h 311dsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
339dsa.o: ../include/openssl/des.h ../include/openssl/dh.h 312dsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
340dsa.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 313dsa.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
341dsa.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 314dsa.o: ../include/openssl/err.h ../include/openssl/evp.h
342dsa.o: ../include/openssl/engine.h ../include/openssl/err.h 315dsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
343dsa.o: ../include/openssl/evp.h ../include/openssl/idea.h
344dsa.o: ../include/openssl/lhash.h ../include/openssl/md2.h
345dsa.o: ../include/openssl/md4.h ../include/openssl/md5.h
346dsa.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
347dsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 316dsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
348dsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 317dsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
349dsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 318dsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
350dsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 319dsa.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
351dsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 320dsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
352dsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 321dsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
353dsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 322dsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
354dsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 323dsa.o: ../include/openssl/ui.h ../include/openssl/x509.h
355dsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 324dsa.o: ../include/openssl/x509_vfy.h apps.h dsa.c
356dsaparam.o: ../include/openssl/asn1.h ../include/openssl/bio.h 325dsaparam.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
357dsaparam.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 326dsaparam.o: ../include/openssl/bn.h ../include/openssl/buffer.h
358dsaparam.o: ../include/openssl/buffer.h ../include/openssl/cast.h
359dsaparam.o: ../include/openssl/conf.h ../include/openssl/crypto.h 327dsaparam.o: ../include/openssl/conf.h ../include/openssl/crypto.h
360dsaparam.o: ../include/openssl/des.h ../include/openssl/dh.h 328dsaparam.o: ../include/openssl/dh.h ../include/openssl/dsa.h
361dsaparam.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 329dsaparam.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
362dsaparam.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 330dsaparam.o: ../include/openssl/err.h ../include/openssl/evp.h
363dsaparam.o: ../include/openssl/engine.h ../include/openssl/err.h 331dsaparam.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
364dsaparam.o: ../include/openssl/evp.h ../include/openssl/idea.h
365dsaparam.o: ../include/openssl/lhash.h ../include/openssl/md2.h
366dsaparam.o: ../include/openssl/md4.h ../include/openssl/md5.h
367dsaparam.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
368dsaparam.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 332dsaparam.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
369dsaparam.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 333dsaparam.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
370dsaparam.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 334dsaparam.o: ../include/openssl/pem.h ../include/openssl/pem2.h
371dsaparam.o: ../include/openssl/rand.h ../include/openssl/rc2.h 335dsaparam.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
372dsaparam.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 336dsaparam.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
373dsaparam.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 337dsaparam.o: ../include/openssl/sha.h ../include/openssl/stack.h
374dsaparam.o: ../include/openssl/safestack.h ../include/openssl/sha.h 338dsaparam.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
375dsaparam.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 339dsaparam.o: ../include/openssl/ui.h ../include/openssl/x509.h
376dsaparam.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 340dsaparam.o: ../include/openssl/x509_vfy.h apps.h dsaparam.c
377enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h 341enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
378enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 342enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h
379enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h
380enc.o: ../include/openssl/conf.h ../include/openssl/crypto.h 343enc.o: ../include/openssl/conf.h ../include/openssl/crypto.h
381enc.o: ../include/openssl/des.h ../include/openssl/dh.h 344enc.o: ../include/openssl/dh.h ../include/openssl/dsa.h
382enc.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 345enc.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
383enc.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 346enc.o: ../include/openssl/err.h ../include/openssl/evp.h
384enc.o: ../include/openssl/engine.h ../include/openssl/err.h 347enc.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
385enc.o: ../include/openssl/evp.h ../include/openssl/idea.h
386enc.o: ../include/openssl/lhash.h ../include/openssl/md2.h
387enc.o: ../include/openssl/md4.h ../include/openssl/md5.h
388enc.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
389enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 348enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
390enc.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 349enc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
391enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 350enc.o: ../include/openssl/pem.h ../include/openssl/pem2.h
392enc.o: ../include/openssl/rand.h ../include/openssl/rc2.h 351enc.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
393enc.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 352enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
394enc.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 353enc.o: ../include/openssl/sha.h ../include/openssl/stack.h
395enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h 354enc.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
396enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 355enc.o: ../include/openssl/ui.h ../include/openssl/x509.h
397enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 356enc.o: ../include/openssl/x509_vfy.h apps.h enc.c
398errstr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 357engine.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
399errstr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 358engine.o: ../include/openssl/bn.h ../include/openssl/buffer.h
400errstr.o: ../include/openssl/buffer.h ../include/openssl/cast.h 359engine.o: ../include/openssl/comp.h ../include/openssl/conf.h
360engine.o: ../include/openssl/crypto.h ../include/openssl/dh.h
361engine.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
362engine.o: ../include/openssl/engine.h ../include/openssl/err.h
363engine.o: ../include/openssl/evp.h ../include/openssl/kssl.h
364engine.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
365engine.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
366engine.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
367engine.o: ../include/openssl/pem.h ../include/openssl/pem2.h
368engine.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
369engine.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
370engine.o: ../include/openssl/sha.h ../include/openssl/ssl.h
371engine.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
372engine.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
373engine.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
374engine.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
375engine.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
376engine.o: engine.c
377errstr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
378errstr.o: ../include/openssl/bn.h ../include/openssl/buffer.h
401errstr.o: ../include/openssl/comp.h ../include/openssl/conf.h 379errstr.o: ../include/openssl/comp.h ../include/openssl/conf.h
402errstr.o: ../include/openssl/crypto.h ../include/openssl/des.h 380errstr.o: ../include/openssl/crypto.h ../include/openssl/dh.h
403errstr.o: ../include/openssl/dh.h ../include/openssl/dsa.h 381errstr.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
404errstr.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 382errstr.o: ../include/openssl/engine.h ../include/openssl/err.h
405errstr.o: ../include/openssl/e_os2.h ../include/openssl/err.h 383errstr.o: ../include/openssl/evp.h ../include/openssl/kssl.h
406errstr.o: ../include/openssl/evp.h ../include/openssl/idea.h 384errstr.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
407errstr.o: ../include/openssl/lhash.h ../include/openssl/md2.h
408errstr.o: ../include/openssl/md4.h ../include/openssl/md5.h
409errstr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
410errstr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 385errstr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
411errstr.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 386errstr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
412errstr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 387errstr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
413errstr.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 388errstr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
414errstr.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
415errstr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 389errstr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
416errstr.o: ../include/openssl/sha.h ../include/openssl/ssl.h 390errstr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
417errstr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 391errstr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
418errstr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 392errstr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
419errstr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 393errstr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
394errstr.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
420errstr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 395errstr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
421gendh.o: ../include/openssl/asn1.h ../include/openssl/bio.h 396errstr.o: errstr.c
422gendh.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 397gendh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
423gendh.o: ../include/openssl/buffer.h ../include/openssl/cast.h 398gendh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
424gendh.o: ../include/openssl/conf.h ../include/openssl/crypto.h 399gendh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
425gendh.o: ../include/openssl/des.h ../include/openssl/dh.h 400gendh.o: ../include/openssl/dh.h ../include/openssl/dsa.h
426gendh.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 401gendh.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
427gendh.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 402gendh.o: ../include/openssl/err.h ../include/openssl/evp.h
428gendh.o: ../include/openssl/engine.h ../include/openssl/err.h 403gendh.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
429gendh.o: ../include/openssl/evp.h ../include/openssl/idea.h
430gendh.o: ../include/openssl/lhash.h ../include/openssl/md2.h
431gendh.o: ../include/openssl/md4.h ../include/openssl/md5.h
432gendh.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
433gendh.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 404gendh.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
434gendh.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 405gendh.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
435gendh.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 406gendh.o: ../include/openssl/pem.h ../include/openssl/pem2.h
436gendh.o: ../include/openssl/rand.h ../include/openssl/rc2.h 407gendh.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
437gendh.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 408gendh.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
438gendh.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 409gendh.o: ../include/openssl/sha.h ../include/openssl/stack.h
439gendh.o: ../include/openssl/safestack.h ../include/openssl/sha.h 410gendh.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
440gendh.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 411gendh.o: ../include/openssl/ui.h ../include/openssl/x509.h
441gendh.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 412gendh.o: ../include/openssl/x509_vfy.h apps.h gendh.c
442gendsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 413gendsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
443gendsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 414gendsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
444gendsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
445gendsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h 415gendsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
446gendsa.o: ../include/openssl/des.h ../include/openssl/dh.h 416gendsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
447gendsa.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 417gendsa.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
448gendsa.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 418gendsa.o: ../include/openssl/err.h ../include/openssl/evp.h
449gendsa.o: ../include/openssl/engine.h ../include/openssl/err.h 419gendsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
450gendsa.o: ../include/openssl/evp.h ../include/openssl/idea.h
451gendsa.o: ../include/openssl/lhash.h ../include/openssl/md2.h
452gendsa.o: ../include/openssl/md4.h ../include/openssl/md5.h
453gendsa.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
454gendsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 420gendsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
455gendsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 421gendsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
456gendsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 422gendsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
457gendsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 423gendsa.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
458gendsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 424gendsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
459gendsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 425gendsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
460gendsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 426gendsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
461gendsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 427gendsa.o: ../include/openssl/ui.h ../include/openssl/x509.h
462gendsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 428gendsa.o: ../include/openssl/x509_vfy.h apps.h gendsa.c
463genrsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 429genrsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
464genrsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 430genrsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
465genrsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
466genrsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h 431genrsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
467genrsa.o: ../include/openssl/des.h ../include/openssl/dh.h 432genrsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
468genrsa.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 433genrsa.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
469genrsa.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 434genrsa.o: ../include/openssl/err.h ../include/openssl/evp.h
470genrsa.o: ../include/openssl/engine.h ../include/openssl/err.h 435genrsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
471genrsa.o: ../include/openssl/evp.h ../include/openssl/idea.h
472genrsa.o: ../include/openssl/lhash.h ../include/openssl/md2.h
473genrsa.o: ../include/openssl/md4.h ../include/openssl/md5.h
474genrsa.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
475genrsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 436genrsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
476genrsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 437genrsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
477genrsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 438genrsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
478genrsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 439genrsa.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
479genrsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 440genrsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
480genrsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 441genrsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
481genrsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 442genrsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
482genrsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 443genrsa.o: ../include/openssl/ui.h ../include/openssl/x509.h
483genrsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 444genrsa.o: ../include/openssl/x509_vfy.h apps.h genrsa.c
484nseq.o: ../include/openssl/asn1.h ../include/openssl/bio.h 445nseq.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
485nseq.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 446nseq.o: ../include/openssl/bn.h ../include/openssl/buffer.h
486nseq.o: ../include/openssl/buffer.h ../include/openssl/cast.h
487nseq.o: ../include/openssl/conf.h ../include/openssl/crypto.h 447nseq.o: ../include/openssl/conf.h ../include/openssl/crypto.h
488nseq.o: ../include/openssl/des.h ../include/openssl/dh.h 448nseq.o: ../include/openssl/dh.h ../include/openssl/dsa.h
489nseq.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 449nseq.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
490nseq.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
491nseq.o: ../include/openssl/err.h ../include/openssl/evp.h 450nseq.o: ../include/openssl/err.h ../include/openssl/evp.h
492nseq.o: ../include/openssl/idea.h ../include/openssl/lhash.h 451nseq.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
493nseq.o: ../include/openssl/md2.h ../include/openssl/md4.h 452nseq.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
494nseq.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 453nseq.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
495nseq.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
496nseq.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
497nseq.o: ../include/openssl/pem.h ../include/openssl/pem2.h 454nseq.o: ../include/openssl/pem.h ../include/openssl/pem2.h
498nseq.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 455nseq.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
499nseq.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 456nseq.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
500nseq.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 457nseq.o: ../include/openssl/sha.h ../include/openssl/stack.h
501nseq.o: ../include/openssl/safestack.h ../include/openssl/sha.h 458nseq.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
502nseq.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 459nseq.o: ../include/openssl/ui.h ../include/openssl/x509.h
503nseq.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 460nseq.o: ../include/openssl/x509_vfy.h apps.h nseq.c
504openssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 461ocsp.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
505openssl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 462ocsp.o: ../include/openssl/bn.h ../include/openssl/buffer.h
506openssl.o: ../include/openssl/buffer.h ../include/openssl/cast.h 463ocsp.o: ../include/openssl/comp.h ../include/openssl/conf.h
464ocsp.o: ../include/openssl/crypto.h ../include/openssl/dh.h
465ocsp.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
466ocsp.o: ../include/openssl/engine.h ../include/openssl/err.h
467ocsp.o: ../include/openssl/evp.h ../include/openssl/kssl.h
468ocsp.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
469ocsp.o: ../include/openssl/objects.h ../include/openssl/ocsp.h
470ocsp.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
471ocsp.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
472ocsp.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
473ocsp.o: ../include/openssl/rand.h ../include/openssl/rsa.h
474ocsp.o: ../include/openssl/safestack.h ../include/openssl/sha.h
475ocsp.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
476ocsp.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
477ocsp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
478ocsp.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
479ocsp.o: ../include/openssl/ui.h ../include/openssl/x509.h
480ocsp.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h ocsp.c
481openssl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
482openssl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
507openssl.o: ../include/openssl/comp.h ../include/openssl/conf.h 483openssl.o: ../include/openssl/comp.h ../include/openssl/conf.h
508openssl.o: ../include/openssl/crypto.h ../include/openssl/des.h 484openssl.o: ../include/openssl/crypto.h ../include/openssl/dh.h
509openssl.o: ../include/openssl/dh.h ../include/openssl/dsa.h 485openssl.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
510openssl.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 486openssl.o: ../include/openssl/engine.h ../include/openssl/err.h
511openssl.o: ../include/openssl/e_os2.h ../include/openssl/err.h 487openssl.o: ../include/openssl/evp.h ../include/openssl/kssl.h
512openssl.o: ../include/openssl/evp.h ../include/openssl/idea.h 488openssl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
513openssl.o: ../include/openssl/lhash.h ../include/openssl/md2.h
514openssl.o: ../include/openssl/md4.h ../include/openssl/md5.h
515openssl.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
516openssl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 489openssl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
517openssl.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 490openssl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
518openssl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 491openssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
519openssl.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 492openssl.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
520openssl.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
521openssl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 493openssl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
522openssl.o: ../include/openssl/sha.h ../include/openssl/ssl.h 494openssl.o: ../include/openssl/sha.h ../include/openssl/ssl.h
523openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 495openssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
524openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 496openssl.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
525openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 497openssl.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
498openssl.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
526openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 499openssl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
527openssl.o: progs.h s_apps.h 500openssl.o: openssl.c progs.h s_apps.h
528passwd.o: ../include/openssl/asn1.h ../include/openssl/bio.h 501passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
529passwd.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 502passwd.o: ../include/openssl/bn.h ../include/openssl/buffer.h
530passwd.o: ../include/openssl/buffer.h ../include/openssl/cast.h
531passwd.o: ../include/openssl/conf.h ../include/openssl/crypto.h 503passwd.o: ../include/openssl/conf.h ../include/openssl/crypto.h
532passwd.o: ../include/openssl/des.h ../include/openssl/dh.h 504passwd.o: ../include/openssl/des.h ../include/openssl/des_old.h
533passwd.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 505passwd.o: ../include/openssl/dh.h ../include/openssl/dsa.h
534passwd.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 506passwd.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
535passwd.o: ../include/openssl/err.h ../include/openssl/evp.h 507passwd.o: ../include/openssl/err.h ../include/openssl/evp.h
536passwd.o: ../include/openssl/idea.h ../include/openssl/lhash.h 508passwd.o: ../include/openssl/lhash.h ../include/openssl/md5.h
537passwd.o: ../include/openssl/md2.h ../include/openssl/md4.h
538passwd.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
539passwd.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h 509passwd.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
540passwd.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 510passwd.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
541passwd.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 511passwd.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
542passwd.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 512passwd.o: ../include/openssl/rand.h ../include/openssl/rsa.h
543passwd.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 513passwd.o: ../include/openssl/safestack.h ../include/openssl/sha.h
544passwd.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 514passwd.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
545passwd.o: ../include/openssl/sha.h ../include/openssl/stack.h 515passwd.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
546passwd.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 516passwd.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h
547passwd.o: ../include/openssl/x509_vfy.h apps.h 517passwd.o: ../include/openssl/x509_vfy.h apps.h passwd.c
548pkcs12.o: ../include/openssl/asn1.h ../include/openssl/bio.h 518pkcs12.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
549pkcs12.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 519pkcs12.o: ../include/openssl/bn.h ../include/openssl/buffer.h
550pkcs12.o: ../include/openssl/buffer.h ../include/openssl/cast.h
551pkcs12.o: ../include/openssl/conf.h ../include/openssl/crypto.h 520pkcs12.o: ../include/openssl/conf.h ../include/openssl/crypto.h
552pkcs12.o: ../include/openssl/des.h ../include/openssl/dh.h 521pkcs12.o: ../include/openssl/dh.h ../include/openssl/dsa.h
553pkcs12.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 522pkcs12.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
554pkcs12.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 523pkcs12.o: ../include/openssl/err.h ../include/openssl/evp.h
555pkcs12.o: ../include/openssl/engine.h ../include/openssl/err.h 524pkcs12.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
556pkcs12.o: ../include/openssl/evp.h ../include/openssl/idea.h
557pkcs12.o: ../include/openssl/lhash.h ../include/openssl/md2.h
558pkcs12.o: ../include/openssl/md4.h ../include/openssl/md5.h
559pkcs12.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
560pkcs12.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 525pkcs12.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
561pkcs12.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 526pkcs12.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
562pkcs12.o: ../include/openssl/pem2.h ../include/openssl/pkcs12.h 527pkcs12.o: ../include/openssl/pem.h ../include/openssl/pem2.h
563pkcs12.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 528pkcs12.o: ../include/openssl/pkcs12.h ../include/openssl/pkcs7.h
564pkcs12.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 529pkcs12.o: ../include/openssl/rand.h ../include/openssl/rsa.h
565pkcs12.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 530pkcs12.o: ../include/openssl/safestack.h ../include/openssl/sha.h
566pkcs12.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 531pkcs12.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
567pkcs12.o: ../include/openssl/sha.h ../include/openssl/stack.h 532pkcs12.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
568pkcs12.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 533pkcs12.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
569pkcs12.o: ../include/openssl/x509_vfy.h apps.h 534pkcs12.o: pkcs12.c
570pkcs7.o: ../include/openssl/asn1.h ../include/openssl/bio.h 535pkcs7.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
571pkcs7.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 536pkcs7.o: ../include/openssl/bn.h ../include/openssl/buffer.h
572pkcs7.o: ../include/openssl/buffer.h ../include/openssl/cast.h
573pkcs7.o: ../include/openssl/conf.h ../include/openssl/crypto.h 537pkcs7.o: ../include/openssl/conf.h ../include/openssl/crypto.h
574pkcs7.o: ../include/openssl/des.h ../include/openssl/dh.h 538pkcs7.o: ../include/openssl/dh.h ../include/openssl/dsa.h
575pkcs7.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 539pkcs7.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
576pkcs7.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 540pkcs7.o: ../include/openssl/err.h ../include/openssl/evp.h
577pkcs7.o: ../include/openssl/engine.h ../include/openssl/err.h 541pkcs7.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
578pkcs7.o: ../include/openssl/evp.h ../include/openssl/idea.h
579pkcs7.o: ../include/openssl/lhash.h ../include/openssl/md2.h
580pkcs7.o: ../include/openssl/md4.h ../include/openssl/md5.h
581pkcs7.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
582pkcs7.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 542pkcs7.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
583pkcs7.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 543pkcs7.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
584pkcs7.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 544pkcs7.o: ../include/openssl/pem.h ../include/openssl/pem2.h
585pkcs7.o: ../include/openssl/rand.h ../include/openssl/rc2.h 545pkcs7.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
586pkcs7.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 546pkcs7.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
587pkcs7.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 547pkcs7.o: ../include/openssl/sha.h ../include/openssl/stack.h
588pkcs7.o: ../include/openssl/safestack.h ../include/openssl/sha.h 548pkcs7.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
589pkcs7.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 549pkcs7.o: ../include/openssl/ui.h ../include/openssl/x509.h
590pkcs7.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 550pkcs7.o: ../include/openssl/x509_vfy.h apps.h pkcs7.c
591pkcs8.o: ../include/openssl/asn1.h ../include/openssl/bio.h 551pkcs8.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
592pkcs8.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 552pkcs8.o: ../include/openssl/bn.h ../include/openssl/buffer.h
593pkcs8.o: ../include/openssl/buffer.h ../include/openssl/cast.h
594pkcs8.o: ../include/openssl/conf.h ../include/openssl/crypto.h 553pkcs8.o: ../include/openssl/conf.h ../include/openssl/crypto.h
595pkcs8.o: ../include/openssl/des.h ../include/openssl/dh.h 554pkcs8.o: ../include/openssl/dh.h ../include/openssl/dsa.h
596pkcs8.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 555pkcs8.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
597pkcs8.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 556pkcs8.o: ../include/openssl/err.h ../include/openssl/evp.h
598pkcs8.o: ../include/openssl/engine.h ../include/openssl/err.h 557pkcs8.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
599pkcs8.o: ../include/openssl/evp.h ../include/openssl/idea.h
600pkcs8.o: ../include/openssl/lhash.h ../include/openssl/md2.h
601pkcs8.o: ../include/openssl/md4.h ../include/openssl/md5.h
602pkcs8.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
603pkcs8.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 558pkcs8.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
604pkcs8.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 559pkcs8.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
605pkcs8.o: ../include/openssl/pem2.h ../include/openssl/pkcs12.h 560pkcs8.o: ../include/openssl/pem.h ../include/openssl/pem2.h
606pkcs8.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 561pkcs8.o: ../include/openssl/pkcs12.h ../include/openssl/pkcs7.h
607pkcs8.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 562pkcs8.o: ../include/openssl/rand.h ../include/openssl/rsa.h
608pkcs8.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 563pkcs8.o: ../include/openssl/safestack.h ../include/openssl/sha.h
609pkcs8.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 564pkcs8.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
610pkcs8.o: ../include/openssl/sha.h ../include/openssl/stack.h 565pkcs8.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
611pkcs8.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 566pkcs8.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h pkcs8.c
612pkcs8.o: ../include/openssl/x509_vfy.h apps.h 567rand.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
613rand.o: ../include/openssl/asn1.h ../include/openssl/bio.h 568rand.o: ../include/openssl/bn.h ../include/openssl/buffer.h
614rand.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
615rand.o: ../include/openssl/buffer.h ../include/openssl/cast.h
616rand.o: ../include/openssl/conf.h ../include/openssl/crypto.h 569rand.o: ../include/openssl/conf.h ../include/openssl/crypto.h
617rand.o: ../include/openssl/des.h ../include/openssl/dh.h 570rand.o: ../include/openssl/dh.h ../include/openssl/dsa.h
618rand.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 571rand.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
619rand.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 572rand.o: ../include/openssl/err.h ../include/openssl/evp.h
620rand.o: ../include/openssl/engine.h ../include/openssl/err.h 573rand.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
621rand.o: ../include/openssl/evp.h ../include/openssl/idea.h
622rand.o: ../include/openssl/lhash.h ../include/openssl/md2.h
623rand.o: ../include/openssl/md4.h ../include/openssl/md5.h
624rand.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
625rand.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 574rand.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
626rand.o: ../include/openssl/opensslv.h ../include/openssl/pkcs7.h 575rand.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
627rand.o: ../include/openssl/rand.h ../include/openssl/rc2.h 576rand.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
628rand.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 577rand.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
629rand.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 578rand.o: ../include/openssl/sha.h ../include/openssl/stack.h
630rand.o: ../include/openssl/safestack.h ../include/openssl/sha.h 579rand.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
631rand.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 580rand.o: ../include/openssl/ui.h ../include/openssl/x509.h
632rand.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 581rand.o: ../include/openssl/x509_vfy.h apps.h rand.c
633req.o: ../include/openssl/asn1.h ../include/openssl/bio.h 582req.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
634req.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 583req.o: ../include/openssl/bn.h ../include/openssl/buffer.h
635req.o: ../include/openssl/buffer.h ../include/openssl/cast.h
636req.o: ../include/openssl/conf.h ../include/openssl/crypto.h 584req.o: ../include/openssl/conf.h ../include/openssl/crypto.h
637req.o: ../include/openssl/des.h ../include/openssl/dh.h 585req.o: ../include/openssl/dh.h ../include/openssl/dsa.h
638req.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 586req.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
639req.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 587req.o: ../include/openssl/err.h ../include/openssl/evp.h
640req.o: ../include/openssl/engine.h ../include/openssl/err.h 588req.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
641req.o: ../include/openssl/evp.h ../include/openssl/idea.h
642req.o: ../include/openssl/lhash.h ../include/openssl/md2.h
643req.o: ../include/openssl/md4.h ../include/openssl/md5.h
644req.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
645req.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 589req.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
646req.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 590req.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
647req.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 591req.o: ../include/openssl/pem.h ../include/openssl/pem2.h
648req.o: ../include/openssl/rand.h ../include/openssl/rc2.h 592req.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
649req.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 593req.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
650req.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 594req.o: ../include/openssl/sha.h ../include/openssl/stack.h
651req.o: ../include/openssl/safestack.h ../include/openssl/sha.h 595req.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
652req.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 596req.o: ../include/openssl/ui.h ../include/openssl/x509.h
653req.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 597req.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h req.c
654req.o: ../include/openssl/x509v3.h apps.h 598rsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
655rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 599rsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
656rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
657rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
658rsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h 600rsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
659rsa.o: ../include/openssl/des.h ../include/openssl/dh.h 601rsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
660rsa.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 602rsa.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
661rsa.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 603rsa.o: ../include/openssl/err.h ../include/openssl/evp.h
662rsa.o: ../include/openssl/engine.h ../include/openssl/err.h 604rsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
663rsa.o: ../include/openssl/evp.h ../include/openssl/idea.h
664rsa.o: ../include/openssl/lhash.h ../include/openssl/md2.h
665rsa.o: ../include/openssl/md4.h ../include/openssl/md5.h
666rsa.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
667rsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 605rsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
668rsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 606rsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
669rsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 607rsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
670rsa.o: ../include/openssl/rand.h ../include/openssl/rc2.h 608rsa.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
671rsa.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 609rsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
672rsa.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 610rsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
673rsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h 611rsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
674rsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 612rsa.o: ../include/openssl/ui.h ../include/openssl/x509.h
675rsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 613rsa.o: ../include/openssl/x509_vfy.h apps.h rsa.c
676rsautl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 614rsautl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
677rsautl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 615rsautl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
678rsautl.o: ../include/openssl/buffer.h ../include/openssl/cast.h
679rsautl.o: ../include/openssl/conf.h ../include/openssl/crypto.h 616rsautl.o: ../include/openssl/conf.h ../include/openssl/crypto.h
680rsautl.o: ../include/openssl/des.h ../include/openssl/dh.h 617rsautl.o: ../include/openssl/dh.h ../include/openssl/dsa.h
681rsautl.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 618rsautl.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
682rsautl.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 619rsautl.o: ../include/openssl/err.h ../include/openssl/evp.h
683rsautl.o: ../include/openssl/engine.h ../include/openssl/err.h 620rsautl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
684rsautl.o: ../include/openssl/evp.h ../include/openssl/idea.h
685rsautl.o: ../include/openssl/lhash.h ../include/openssl/md2.h
686rsautl.o: ../include/openssl/md4.h ../include/openssl/md5.h
687rsautl.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
688rsautl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 621rsautl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
689rsautl.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 622rsautl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
690rsautl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 623rsautl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
691rsautl.o: ../include/openssl/rand.h ../include/openssl/rc2.h 624rsautl.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
692rsautl.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 625rsautl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
693rsautl.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 626rsautl.o: ../include/openssl/sha.h ../include/openssl/stack.h
694rsautl.o: ../include/openssl/safestack.h ../include/openssl/sha.h 627rsautl.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
695rsautl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 628rsautl.o: ../include/openssl/ui.h ../include/openssl/x509.h
696rsautl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 629rsautl.o: ../include/openssl/x509_vfy.h apps.h rsautl.c
697s_cb.o: ../include/openssl/asn1.h ../include/openssl/bio.h 630s_cb.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
698s_cb.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 631s_cb.o: ../include/openssl/bn.h ../include/openssl/buffer.h
699s_cb.o: ../include/openssl/buffer.h ../include/openssl/cast.h
700s_cb.o: ../include/openssl/comp.h ../include/openssl/conf.h 632s_cb.o: ../include/openssl/comp.h ../include/openssl/conf.h
701s_cb.o: ../include/openssl/crypto.h ../include/openssl/des.h 633s_cb.o: ../include/openssl/crypto.h ../include/openssl/dh.h
702s_cb.o: ../include/openssl/dh.h ../include/openssl/dsa.h 634s_cb.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
703s_cb.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 635s_cb.o: ../include/openssl/engine.h ../include/openssl/err.h
704s_cb.o: ../include/openssl/e_os2.h ../include/openssl/err.h 636s_cb.o: ../include/openssl/evp.h ../include/openssl/kssl.h
705s_cb.o: ../include/openssl/evp.h ../include/openssl/idea.h 637s_cb.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
706s_cb.o: ../include/openssl/lhash.h ../include/openssl/md2.h
707s_cb.o: ../include/openssl/md4.h ../include/openssl/md5.h
708s_cb.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
709s_cb.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 638s_cb.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
710s_cb.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 639s_cb.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
711s_cb.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 640s_cb.o: ../include/openssl/pem.h ../include/openssl/pem2.h
712s_cb.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 641s_cb.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
713s_cb.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
714s_cb.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 642s_cb.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
715s_cb.o: ../include/openssl/sha.h ../include/openssl/ssl.h 643s_cb.o: ../include/openssl/sha.h ../include/openssl/ssl.h
716s_cb.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 644s_cb.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
717s_cb.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 645s_cb.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
718s_cb.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 646s_cb.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
647s_cb.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
719s_cb.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h s_apps.h 648s_cb.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h s_apps.h
720s_client.o: ../include/openssl/asn1.h ../include/openssl/bio.h 649s_cb.o: s_cb.c
721s_client.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 650s_client.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
722s_client.o: ../include/openssl/buffer.h ../include/openssl/cast.h 651s_client.o: ../include/openssl/bn.h ../include/openssl/buffer.h
723s_client.o: ../include/openssl/comp.h ../include/openssl/conf.h 652s_client.o: ../include/openssl/comp.h ../include/openssl/conf.h
724s_client.o: ../include/openssl/crypto.h ../include/openssl/des.h 653s_client.o: ../include/openssl/crypto.h ../include/openssl/dh.h
725s_client.o: ../include/openssl/dh.h ../include/openssl/dsa.h 654s_client.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
726s_client.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 655s_client.o: ../include/openssl/engine.h ../include/openssl/err.h
727s_client.o: ../include/openssl/e_os2.h ../include/openssl/engine.h 656s_client.o: ../include/openssl/evp.h ../include/openssl/kssl.h
728s_client.o: ../include/openssl/err.h ../include/openssl/evp.h 657s_client.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
729s_client.o: ../include/openssl/idea.h ../include/openssl/lhash.h 658s_client.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
730s_client.o: ../include/openssl/md2.h ../include/openssl/md4.h 659s_client.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
731s_client.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
732s_client.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
733s_client.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
734s_client.o: ../include/openssl/pem.h ../include/openssl/pem2.h 660s_client.o: ../include/openssl/pem.h ../include/openssl/pem2.h
735s_client.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 661s_client.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
736s_client.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
737s_client.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
738s_client.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 662s_client.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
739s_client.o: ../include/openssl/sha.h ../include/openssl/ssl.h 663s_client.o: ../include/openssl/sha.h ../include/openssl/ssl.h
740s_client.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 664s_client.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
741s_client.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 665s_client.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
742s_client.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 666s_client.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
667s_client.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
743s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 668s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
744s_client.o: s_apps.h 669s_client.o: s_apps.h s_client.c
745s_server.o: ../include/openssl/asn1.h ../include/openssl/bio.h 670s_server.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
746s_server.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 671s_server.o: ../include/openssl/bn.h ../include/openssl/buffer.h
747s_server.o: ../include/openssl/buffer.h ../include/openssl/cast.h
748s_server.o: ../include/openssl/comp.h ../include/openssl/conf.h 672s_server.o: ../include/openssl/comp.h ../include/openssl/conf.h
749s_server.o: ../include/openssl/crypto.h ../include/openssl/des.h 673s_server.o: ../include/openssl/crypto.h ../include/openssl/dh.h
750s_server.o: ../include/openssl/dh.h ../include/openssl/dsa.h 674s_server.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
751s_server.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 675s_server.o: ../include/openssl/engine.h ../include/openssl/err.h
752s_server.o: ../include/openssl/e_os2.h ../include/openssl/engine.h 676s_server.o: ../include/openssl/evp.h ../include/openssl/kssl.h
753s_server.o: ../include/openssl/err.h ../include/openssl/evp.h 677s_server.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
754s_server.o: ../include/openssl/idea.h ../include/openssl/lhash.h 678s_server.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
755s_server.o: ../include/openssl/md2.h ../include/openssl/md4.h 679s_server.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
756s_server.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
757s_server.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
758s_server.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
759s_server.o: ../include/openssl/pem.h ../include/openssl/pem2.h 680s_server.o: ../include/openssl/pem.h ../include/openssl/pem2.h
760s_server.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 681s_server.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
761s_server.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
762s_server.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
763s_server.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 682s_server.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
764s_server.o: ../include/openssl/sha.h ../include/openssl/ssl.h 683s_server.o: ../include/openssl/sha.h ../include/openssl/ssl.h
765s_server.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 684s_server.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
766s_server.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 685s_server.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
767s_server.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 686s_server.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
687s_server.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
768s_server.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 688s_server.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
769s_server.o: s_apps.h 689s_server.o: s_apps.h s_server.c
770s_socket.o: ../include/openssl/asn1.h ../include/openssl/bio.h 690s_socket.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
771s_socket.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 691s_socket.o: ../include/openssl/bn.h ../include/openssl/buffer.h
772s_socket.o: ../include/openssl/buffer.h ../include/openssl/cast.h
773s_socket.o: ../include/openssl/comp.h ../include/openssl/conf.h 692s_socket.o: ../include/openssl/comp.h ../include/openssl/conf.h
774s_socket.o: ../include/openssl/crypto.h ../include/openssl/des.h 693s_socket.o: ../include/openssl/crypto.h ../include/openssl/dh.h
775s_socket.o: ../include/openssl/dh.h ../include/openssl/dsa.h 694s_socket.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
776s_socket.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 695s_socket.o: ../include/openssl/engine.h ../include/openssl/err.h
777s_socket.o: ../include/openssl/e_os2.h ../include/openssl/evp.h 696s_socket.o: ../include/openssl/evp.h ../include/openssl/kssl.h
778s_socket.o: ../include/openssl/idea.h ../include/openssl/lhash.h 697s_socket.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
779s_socket.o: ../include/openssl/md2.h ../include/openssl/md4.h 698s_socket.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
780s_socket.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 699s_socket.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
781s_socket.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
782s_socket.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
783s_socket.o: ../include/openssl/pem.h ../include/openssl/pem2.h 700s_socket.o: ../include/openssl/pem.h ../include/openssl/pem2.h
784s_socket.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 701s_socket.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
785s_socket.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 702s_socket.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
786s_socket.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 703s_socket.o: ../include/openssl/sha.h ../include/openssl/ssl.h
787s_socket.o: ../include/openssl/safestack.h ../include/openssl/sha.h 704s_socket.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
788s_socket.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 705s_socket.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
789s_socket.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 706s_socket.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
790s_socket.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 707s_socket.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
791s_socket.o: ../include/openssl/tls1.h ../include/openssl/x509.h 708s_socket.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
792s_socket.o: ../include/openssl/x509_vfy.h apps.h s_apps.h 709s_socket.o: s_apps.h s_socket.c
793s_time.o: ../include/openssl/asn1.h ../include/openssl/bio.h 710s_time.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
794s_time.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 711s_time.o: ../include/openssl/bn.h ../include/openssl/buffer.h
795s_time.o: ../include/openssl/buffer.h ../include/openssl/cast.h
796s_time.o: ../include/openssl/comp.h ../include/openssl/conf.h 712s_time.o: ../include/openssl/comp.h ../include/openssl/conf.h
797s_time.o: ../include/openssl/crypto.h ../include/openssl/des.h 713s_time.o: ../include/openssl/crypto.h ../include/openssl/dh.h
798s_time.o: ../include/openssl/dh.h ../include/openssl/dsa.h 714s_time.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
799s_time.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 715s_time.o: ../include/openssl/engine.h ../include/openssl/err.h
800s_time.o: ../include/openssl/e_os2.h ../include/openssl/err.h 716s_time.o: ../include/openssl/evp.h ../include/openssl/kssl.h
801s_time.o: ../include/openssl/evp.h ../include/openssl/idea.h 717s_time.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
802s_time.o: ../include/openssl/lhash.h ../include/openssl/md2.h
803s_time.o: ../include/openssl/md4.h ../include/openssl/md5.h
804s_time.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
805s_time.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 718s_time.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
806s_time.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 719s_time.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
807s_time.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 720s_time.o: ../include/openssl/pem.h ../include/openssl/pem2.h
808s_time.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 721s_time.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
809s_time.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
810s_time.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 722s_time.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
811s_time.o: ../include/openssl/sha.h ../include/openssl/ssl.h 723s_time.o: ../include/openssl/sha.h ../include/openssl/ssl.h
812s_time.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 724s_time.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
813s_time.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 725s_time.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
814s_time.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 726s_time.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
727s_time.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
815s_time.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 728s_time.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
816s_time.o: s_apps.h 729s_time.o: s_apps.h s_time.c
817sess_id.o: ../include/openssl/asn1.h ../include/openssl/bio.h 730sess_id.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
818sess_id.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 731sess_id.o: ../include/openssl/bn.h ../include/openssl/buffer.h
819sess_id.o: ../include/openssl/buffer.h ../include/openssl/cast.h
820sess_id.o: ../include/openssl/comp.h ../include/openssl/conf.h 732sess_id.o: ../include/openssl/comp.h ../include/openssl/conf.h
821sess_id.o: ../include/openssl/crypto.h ../include/openssl/des.h 733sess_id.o: ../include/openssl/crypto.h ../include/openssl/dh.h
822sess_id.o: ../include/openssl/dh.h ../include/openssl/dsa.h 734sess_id.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
823sess_id.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 735sess_id.o: ../include/openssl/engine.h ../include/openssl/err.h
824sess_id.o: ../include/openssl/e_os2.h ../include/openssl/err.h 736sess_id.o: ../include/openssl/evp.h ../include/openssl/kssl.h
825sess_id.o: ../include/openssl/evp.h ../include/openssl/idea.h 737sess_id.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
826sess_id.o: ../include/openssl/lhash.h ../include/openssl/md2.h
827sess_id.o: ../include/openssl/md4.h ../include/openssl/md5.h
828sess_id.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
829sess_id.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 738sess_id.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
830sess_id.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 739sess_id.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
831sess_id.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 740sess_id.o: ../include/openssl/pem.h ../include/openssl/pem2.h
832sess_id.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 741sess_id.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
833sess_id.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
834sess_id.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 742sess_id.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
835sess_id.o: ../include/openssl/sha.h ../include/openssl/ssl.h 743sess_id.o: ../include/openssl/sha.h ../include/openssl/ssl.h
836sess_id.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 744sess_id.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
837sess_id.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 745sess_id.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
838sess_id.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 746sess_id.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
747sess_id.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
839sess_id.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 748sess_id.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
840smime.o: ../include/openssl/asn1.h ../include/openssl/bio.h 749sess_id.o: sess_id.c
841smime.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 750smime.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
842smime.o: ../include/openssl/buffer.h ../include/openssl/cast.h 751smime.o: ../include/openssl/bn.h ../include/openssl/buffer.h
843smime.o: ../include/openssl/conf.h ../include/openssl/crypto.h 752smime.o: ../include/openssl/conf.h ../include/openssl/crypto.h
844smime.o: ../include/openssl/des.h ../include/openssl/dh.h 753smime.o: ../include/openssl/dh.h ../include/openssl/dsa.h
845smime.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 754smime.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
846smime.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 755smime.o: ../include/openssl/err.h ../include/openssl/evp.h
847smime.o: ../include/openssl/engine.h ../include/openssl/err.h 756smime.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
848smime.o: ../include/openssl/evp.h ../include/openssl/idea.h
849smime.o: ../include/openssl/lhash.h ../include/openssl/md2.h
850smime.o: ../include/openssl/md4.h ../include/openssl/md5.h
851smime.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
852smime.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 757smime.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
853smime.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 758smime.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
854smime.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 759smime.o: ../include/openssl/pem.h ../include/openssl/pem2.h
855smime.o: ../include/openssl/rand.h ../include/openssl/rc2.h 760smime.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
856smime.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 761smime.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
857smime.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 762smime.o: ../include/openssl/sha.h ../include/openssl/stack.h
858smime.o: ../include/openssl/safestack.h ../include/openssl/sha.h 763smime.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
859smime.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 764smime.o: ../include/openssl/ui.h ../include/openssl/x509.h
860smime.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 765smime.o: ../include/openssl/x509_vfy.h apps.h smime.c
861speed.o: ../include/openssl/asn1.h ../include/openssl/bio.h 766speed.o: ../e_os.h ../include/openssl/aes.h ../include/openssl/asn1.h
862speed.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 767speed.o: ../include/openssl/bio.h ../include/openssl/blowfish.h
863speed.o: ../include/openssl/buffer.h ../include/openssl/cast.h 768speed.o: ../include/openssl/bn.h ../include/openssl/buffer.h
864speed.o: ../include/openssl/conf.h ../include/openssl/crypto.h 769speed.o: ../include/openssl/cast.h ../include/openssl/conf.h
865speed.o: ../include/openssl/des.h ../include/openssl/dh.h 770speed.o: ../include/openssl/crypto.h ../include/openssl/des.h
866speed.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 771speed.o: ../include/openssl/des_old.h ../include/openssl/dh.h
867speed.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 772speed.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
868speed.o: ../include/openssl/engine.h ../include/openssl/err.h 773speed.o: ../include/openssl/engine.h ../include/openssl/err.h
869speed.o: ../include/openssl/evp.h ../include/openssl/hmac.h 774speed.o: ../include/openssl/evp.h ../include/openssl/hmac.h
870speed.o: ../include/openssl/idea.h ../include/openssl/lhash.h 775speed.o: ../include/openssl/idea.h ../include/openssl/lhash.h
@@ -872,94 +777,80 @@ speed.o: ../include/openssl/md2.h ../include/openssl/md4.h
872speed.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 777speed.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
873speed.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h 778speed.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
874speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 779speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
875speed.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 780speed.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
876speed.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 781speed.o: ../include/openssl/rand.h ../include/openssl/rc2.h
877speed.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 782speed.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
878speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 783speed.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
879speed.o: ../include/openssl/sha.h ../include/openssl/stack.h 784speed.o: ../include/openssl/safestack.h ../include/openssl/sha.h
880speed.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 785speed.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
881speed.o: ../include/openssl/x509_vfy.h ./testdsa.h ./testrsa.h apps.h 786speed.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
882spkac.o: ../include/openssl/asn1.h ../include/openssl/bio.h 787speed.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h
883spkac.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 788speed.o: ../include/openssl/x509_vfy.h apps.h speed.c testdsa.h testrsa.h
884spkac.o: ../include/openssl/buffer.h ../include/openssl/cast.h 789spkac.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
790spkac.o: ../include/openssl/bn.h ../include/openssl/buffer.h
885spkac.o: ../include/openssl/conf.h ../include/openssl/crypto.h 791spkac.o: ../include/openssl/conf.h ../include/openssl/crypto.h
886spkac.o: ../include/openssl/des.h ../include/openssl/dh.h 792spkac.o: ../include/openssl/dh.h ../include/openssl/dsa.h
887spkac.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 793spkac.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
888spkac.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 794spkac.o: ../include/openssl/err.h ../include/openssl/evp.h
889spkac.o: ../include/openssl/engine.h ../include/openssl/err.h 795spkac.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
890spkac.o: ../include/openssl/evp.h ../include/openssl/idea.h
891spkac.o: ../include/openssl/lhash.h ../include/openssl/md2.h
892spkac.o: ../include/openssl/md4.h ../include/openssl/md5.h
893spkac.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
894spkac.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 796spkac.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
895spkac.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 797spkac.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
896spkac.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 798spkac.o: ../include/openssl/pem.h ../include/openssl/pem2.h
897spkac.o: ../include/openssl/rand.h ../include/openssl/rc2.h 799spkac.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
898spkac.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 800spkac.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
899spkac.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 801spkac.o: ../include/openssl/sha.h ../include/openssl/stack.h
900spkac.o: ../include/openssl/safestack.h ../include/openssl/sha.h 802spkac.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
901spkac.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 803spkac.o: ../include/openssl/ui.h ../include/openssl/x509.h
902spkac.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h 804spkac.o: ../include/openssl/x509_vfy.h apps.h spkac.c
903verify.o: ../include/openssl/asn1.h ../include/openssl/bio.h 805verify.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
904verify.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 806verify.o: ../include/openssl/bn.h ../include/openssl/buffer.h
905verify.o: ../include/openssl/buffer.h ../include/openssl/cast.h
906verify.o: ../include/openssl/conf.h ../include/openssl/crypto.h 807verify.o: ../include/openssl/conf.h ../include/openssl/crypto.h
907verify.o: ../include/openssl/des.h ../include/openssl/dh.h 808verify.o: ../include/openssl/dh.h ../include/openssl/dsa.h
908verify.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 809verify.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
909verify.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 810verify.o: ../include/openssl/err.h ../include/openssl/evp.h
910verify.o: ../include/openssl/engine.h ../include/openssl/err.h 811verify.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
911verify.o: ../include/openssl/evp.h ../include/openssl/idea.h
912verify.o: ../include/openssl/lhash.h ../include/openssl/md2.h
913verify.o: ../include/openssl/md4.h ../include/openssl/md5.h
914verify.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
915verify.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 812verify.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
916verify.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 813verify.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
917verify.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 814verify.o: ../include/openssl/pem.h ../include/openssl/pem2.h
918verify.o: ../include/openssl/rand.h ../include/openssl/rc2.h 815verify.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
919verify.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 816verify.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
920verify.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 817verify.o: ../include/openssl/sha.h ../include/openssl/stack.h
921verify.o: ../include/openssl/safestack.h ../include/openssl/sha.h 818verify.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
922verify.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 819verify.o: ../include/openssl/ui.h ../include/openssl/x509.h
923verify.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 820verify.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h
924verify.o: ../include/openssl/x509v3.h apps.h 821verify.o: verify.c
925version.o: ../include/openssl/asn1.h ../include/openssl/bio.h 822version.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
926version.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 823version.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
927version.o: ../include/openssl/buffer.h ../include/openssl/cast.h 824version.o: ../include/openssl/buffer.h ../include/openssl/conf.h
928version.o: ../include/openssl/conf.h ../include/openssl/crypto.h 825version.o: ../include/openssl/crypto.h ../include/openssl/des.h
929version.o: ../include/openssl/des.h ../include/openssl/dh.h 826version.o: ../include/openssl/des_old.h ../include/openssl/dh.h
930version.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 827version.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
931version.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 828version.o: ../include/openssl/engine.h ../include/openssl/err.h
932version.o: ../include/openssl/evp.h ../include/openssl/idea.h 829version.o: ../include/openssl/evp.h ../include/openssl/idea.h
933version.o: ../include/openssl/lhash.h ../include/openssl/md2.h 830version.o: ../include/openssl/lhash.h ../include/openssl/md2.h
934version.o: ../include/openssl/md4.h ../include/openssl/md5.h 831version.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
935version.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 832version.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
936version.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 833version.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
937version.o: ../include/openssl/opensslv.h ../include/openssl/pkcs7.h 834version.o: ../include/openssl/rand.h ../include/openssl/rc4.h
938version.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
939version.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
940version.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 835version.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
941version.o: ../include/openssl/sha.h ../include/openssl/stack.h 836version.o: ../include/openssl/sha.h ../include/openssl/stack.h
942version.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 837version.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
943version.o: ../include/openssl/x509_vfy.h apps.h 838version.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h
944x509.o: ../include/openssl/asn1.h ../include/openssl/bio.h 839version.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
945x509.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 840version.o: version.c
946x509.o: ../include/openssl/buffer.h ../include/openssl/cast.h 841x509.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
842x509.o: ../include/openssl/bn.h ../include/openssl/buffer.h
947x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h 843x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h
948x509.o: ../include/openssl/des.h ../include/openssl/dh.h 844x509.o: ../include/openssl/dh.h ../include/openssl/dsa.h
949x509.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 845x509.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
950x509.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h 846x509.o: ../include/openssl/err.h ../include/openssl/evp.h
951x509.o: ../include/openssl/engine.h ../include/openssl/err.h 847x509.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
952x509.o: ../include/openssl/evp.h ../include/openssl/idea.h
953x509.o: ../include/openssl/lhash.h ../include/openssl/md2.h
954x509.o: ../include/openssl/md4.h ../include/openssl/md5.h
955x509.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
956x509.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 848x509.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
957x509.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 849x509.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
958x509.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 850x509.o: ../include/openssl/pem.h ../include/openssl/pem2.h
959x509.o: ../include/openssl/rand.h ../include/openssl/rc2.h 851x509.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
960x509.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 852x509.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
961x509.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 853x509.o: ../include/openssl/sha.h ../include/openssl/stack.h
962x509.o: ../include/openssl/safestack.h ../include/openssl/sha.h 854x509.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
963x509.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 855x509.o: ../include/openssl/ui.h ../include/openssl/x509.h
964x509.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 856x509.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h x509.c
965x509.o: ../include/openssl/x509v3.h apps.h
diff --git a/src/lib/libssl/src/apps/app_rand.c b/src/lib/libssl/src/apps/app_rand.c
index 8a78e12eb7..b7b6128c1e 100644
--- a/src/lib/libssl/src/apps/app_rand.c
+++ b/src/lib/libssl/src/apps/app_rand.c
@@ -124,7 +124,7 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
124 int consider_randfile = (file == NULL); 124 int consider_randfile = (file == NULL);
125 char buffer[200]; 125 char buffer[200];
126 126
127#ifdef WINDOWS 127#ifdef OPENSSL_SYS_WINDOWS
128 BIO_printf(bio_e,"Loading 'screen' into random state -"); 128 BIO_printf(bio_e,"Loading 'screen' into random state -");
129 BIO_flush(bio_e); 129 BIO_flush(bio_e);
130 RAND_screen(); 130 RAND_screen();
@@ -142,18 +142,21 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
142 } 142 }
143 if (file == NULL || !RAND_load_file(file, -1)) 143 if (file == NULL || !RAND_load_file(file, -1))
144 { 144 {
145 if (RAND_status() == 0 && !dont_warn) 145 if (RAND_status() == 0)
146 { 146 {
147 BIO_printf(bio_e,"unable to load 'random state'\n"); 147 if (!dont_warn)
148 BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
149 BIO_printf(bio_e,"with much random data.\n");
150 if (consider_randfile) /* explanation does not apply when a file is explicitly named */
151 { 148 {
152 BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n"); 149 BIO_printf(bio_e,"unable to load 'random state'\n");
153 BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n"); 150 BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
151 BIO_printf(bio_e,"with much random data.\n");
152 if (consider_randfile) /* explanation does not apply when a file is explicitly named */
153 {
154 BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n");
155 BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n");
156 }
154 } 157 }
158 return 0;
155 } 159 }
156 return 0;
157 } 160 }
158 seeded = 1; 161 seeded = 1;
159 return 1; 162 return 1;
diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c
index 167c319ebe..e797796e30 100644
--- a/src/lib/libssl/src/apps/apps.c
+++ b/src/lib/libssl/src/apps/apps.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 <stdlib.h> 113#include <stdlib.h>
@@ -66,14 +119,41 @@
66#undef NON_MAIN 119#undef NON_MAIN
67#include <openssl/err.h> 120#include <openssl/err.h>
68#include <openssl/x509.h> 121#include <openssl/x509.h>
122#include <openssl/x509v3.h>
69#include <openssl/pem.h> 123#include <openssl/pem.h>
70#include <openssl/pkcs12.h> 124#include <openssl/pkcs12.h>
125#include <openssl/ui.h>
71#include <openssl/safestack.h> 126#include <openssl/safestack.h>
127#include <openssl/engine.h>
128
129#ifdef OPENSSL_SYS_WINDOWS
130#define strcasecmp _stricmp
131#else
132#include <strings.h>
133#endif
72 134
73#ifdef WINDOWS 135#ifdef OPENSSL_SYS_WINDOWS
74# include "bss_file.c" 136# include "bss_file.c"
75#endif 137#endif
76 138
139typedef struct {
140 char *name;
141 unsigned long flag;
142 unsigned long mask;
143} NAME_EX_TBL;
144
145static UI_METHOD *ui_method = NULL;
146
147static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl);
148static int set_multi_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl);
149
150#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
151/* Looks like this stuff is worth moving into separate function */
152static EVP_PKEY *
153load_netscape_key(BIO *err, BIO *key, const char *file,
154 const char *key_descrip, int format);
155#endif
156
77int app_init(long mesgwin); 157int app_init(long mesgwin);
78#ifdef undef /* never finished - probably never will be :-) */ 158#ifdef undef /* never finished - probably never will be :-) */
79int args_from_file(char *file, int *argc, char **argv[]) 159int args_from_file(char *file, int *argc, char **argv[])
@@ -176,7 +256,7 @@ int str2fmt(char *s)
176 return(FORMAT_UNDEF); 256 return(FORMAT_UNDEF);
177 } 257 }
178 258
179#if defined(MSDOS) || defined(WIN32) || defined(WIN16) 259#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
180void program_name(char *in, char *out, int size) 260void program_name(char *in, char *out, int size)
181 { 261 {
182 int i,n; 262 int i,n;
@@ -214,7 +294,7 @@ void program_name(char *in, char *out, int size)
214 out[n]='\0'; 294 out[n]='\0';
215 } 295 }
216#else 296#else
217#ifdef VMS 297#ifdef OPENSSL_SYS_VMS
218void program_name(char *in, char *out, int size) 298void program_name(char *in, char *out, int size)
219 { 299 {
220 char *p=in, *q; 300 char *p=in, *q;
@@ -250,19 +330,16 @@ void program_name(char *in, char *out, int size)
250#endif 330#endif
251#endif 331#endif
252 332
253#ifdef WIN32 333#ifdef OPENSSL_SYS_WIN32
254int WIN32_rename(char *from, char *to) 334int WIN32_rename(char *from, char *to)
255 { 335 {
256#ifdef WINNT 336 /* Windows rename gives an error if 'to' exists, so delete it
257 int ret; 337 * first and ignore file not found errror
258/* Note: MoveFileEx() doesn't work under Win95, Win98 */ 338 */
259 339 if((remove(to) != 0) && (errno != ENOENT))
260 ret=MoveFileEx(from,to,MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED); 340 return -1;
261 return(ret?0:-1); 341#undef rename
262#else 342 return rename(from, to);
263 unlink(to);
264 return MoveFile(from, to);
265#endif
266 } 343 }
267#endif 344#endif
268 345
@@ -353,6 +430,159 @@ int dump_cert_text (BIO *out, X509 *x)
353 return 0; 430 return 0;
354} 431}
355 432
433static int ui_open(UI *ui)
434 {
435 return UI_method_get_opener(UI_OpenSSL())(ui);
436 }
437static int ui_read(UI *ui, UI_STRING *uis)
438 {
439 if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD
440 && UI_get0_user_data(ui))
441 {
442 switch(UI_get_string_type(uis))
443 {
444 case UIT_PROMPT:
445 case UIT_VERIFY:
446 {
447 const char *password =
448 ((PW_CB_DATA *)UI_get0_user_data(ui))->password;
449 if (password[0] != '\0')
450 {
451 UI_set_result(ui, uis, password);
452 return 1;
453 }
454 }
455 default:
456 break;
457 }
458 }
459 return UI_method_get_reader(UI_OpenSSL())(ui, uis);
460 }
461static int ui_write(UI *ui, UI_STRING *uis)
462 {
463 if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD
464 && UI_get0_user_data(ui))
465 {
466 switch(UI_get_string_type(uis))
467 {
468 case UIT_PROMPT:
469 case UIT_VERIFY:
470 {
471 const char *password =
472 ((PW_CB_DATA *)UI_get0_user_data(ui))->password;
473 if (password[0] != '\0')
474 return 1;
475 }
476 default:
477 break;
478 }
479 }
480 return UI_method_get_writer(UI_OpenSSL())(ui, uis);
481 }
482static int ui_close(UI *ui)
483 {
484 return UI_method_get_closer(UI_OpenSSL())(ui);
485 }
486int setup_ui_method()
487 {
488 ui_method = UI_create_method("OpenSSL application user interface");
489 UI_method_set_opener(ui_method, ui_open);
490 UI_method_set_reader(ui_method, ui_read);
491 UI_method_set_writer(ui_method, ui_write);
492 UI_method_set_closer(ui_method, ui_close);
493 return 0;
494 }
495void destroy_ui_method()
496 {
497 if(ui_method)
498 {
499 UI_destroy_method(ui_method);
500 ui_method = NULL;
501 }
502 }
503int password_callback(char *buf, int bufsiz, int verify,
504 PW_CB_DATA *cb_tmp)
505 {
506 UI *ui = NULL;
507 int res = 0;
508 const char *prompt_info = NULL;
509 const char *password = NULL;
510 PW_CB_DATA *cb_data = (PW_CB_DATA *)cb_tmp;
511
512 if (cb_data)
513 {
514 if (cb_data->password)
515 password = cb_data->password;
516 if (cb_data->prompt_info)
517 prompt_info = cb_data->prompt_info;
518 }
519
520 if (password)
521 {
522 res = strlen(password);
523 if (res > bufsiz)
524 res = bufsiz;
525 memcpy(buf, password, res);
526 return res;
527 }
528
529 ui = UI_new_method(ui_method);
530 if (ui)
531 {
532 int ok = 0;
533 char *buff = NULL;
534 int ui_flags = 0;
535 char *prompt = NULL;
536
537 prompt = UI_construct_prompt(ui, "pass phrase",
538 cb_data->prompt_info);
539
540 ui_flags |= UI_INPUT_FLAG_DEFAULT_PWD;
541 UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
542
543 if (ok >= 0)
544 ok = UI_add_input_string(ui,prompt,ui_flags,buf,
545 PW_MIN_LENGTH,BUFSIZ-1);
546 if (ok >= 0 && verify)
547 {
548 buff = (char *)OPENSSL_malloc(bufsiz);
549 ok = UI_add_verify_string(ui,prompt,ui_flags,buff,
550 PW_MIN_LENGTH,BUFSIZ-1, buf);
551 }
552 if (ok >= 0)
553 do
554 {
555 ok = UI_process(ui);
556 }
557 while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
558
559 if (buff)
560 {
561 memset(buff,0,(unsigned int)bufsiz);
562 OPENSSL_free(buff);
563 }
564
565 if (ok >= 0)
566 res = strlen(buf);
567 if (ok == -1)
568 {
569 BIO_printf(bio_err, "User interface error\n");
570 ERR_print_errors(bio_err);
571 memset(buf,0,(unsigned int)bufsiz);
572 res = 0;
573 }
574 if (ok == -2)
575 {
576 BIO_printf(bio_err,"aborted!\n");
577 memset(buf,0,(unsigned int)bufsiz);
578 res = 0;
579 }
580 UI_free(ui);
581 OPENSSL_free(prompt);
582 }
583 return res;
584 }
585
356static char *app_get_pass(BIO *err, char *arg, int keepbio); 586static char *app_get_pass(BIO *err, char *arg, int keepbio);
357 587
358int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2) 588int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2)
@@ -428,14 +658,18 @@ static char *app_get_pass(BIO *err, char *arg, int keepbio)
428 return BUF_strdup(tpass); 658 return BUF_strdup(tpass);
429} 659}
430 660
431int add_oid_section(BIO *err, LHASH *conf) 661int add_oid_section(BIO *err, CONF *conf)
432{ 662{
433 char *p; 663 char *p;
434 STACK_OF(CONF_VALUE) *sktmp; 664 STACK_OF(CONF_VALUE) *sktmp;
435 CONF_VALUE *cnf; 665 CONF_VALUE *cnf;
436 int i; 666 int i;
437 if(!(p=CONF_get_string(conf,NULL,"oid_section"))) return 1; 667 if(!(p=NCONF_get_string(conf,NULL,"oid_section")))
438 if(!(sktmp = CONF_get_section(conf, p))) { 668 {
669 ERR_clear_error();
670 return 1;
671 }
672 if(!(sktmp = NCONF_get_section(conf, p))) {
439 BIO_printf(err, "problem loading oid section %s\n", p); 673 BIO_printf(err, "problem loading oid section %s\n", p);
440 return 0; 674 return 0;
441 } 675 }
@@ -450,7 +684,8 @@ int add_oid_section(BIO *err, LHASH *conf)
450 return 1; 684 return 1;
451} 685}
452 686
453X509 *load_cert(BIO *err, char *file, int format) 687X509 *load_cert(BIO *err, const char *file, int format,
688 const char *pass, ENGINE *e, const char *cert_descrip)
454 { 689 {
455 ASN1_HEADER *ah=NULL; 690 ASN1_HEADER *ah=NULL;
456 BUF_MEM *buf=NULL; 691 BUF_MEM *buf=NULL;
@@ -464,12 +699,17 @@ X509 *load_cert(BIO *err, char *file, int format)
464 } 699 }
465 700
466 if (file == NULL) 701 if (file == NULL)
702 {
703 setvbuf(stdin, NULL, _IONBF, 0);
467 BIO_set_fp(cert,stdin,BIO_NOCLOSE); 704 BIO_set_fp(cert,stdin,BIO_NOCLOSE);
705 }
468 else 706 else
469 { 707 {
470 if (BIO_read_filename(cert,file) <= 0) 708 if (BIO_read_filename(cert,file) <= 0)
471 { 709 {
472 perror(file); 710 BIO_printf(err, "Error opening %s %s\n",
711 cert_descrip, file);
712 ERR_print_errors(err);
473 goto end; 713 goto end;
474 } 714 }
475 } 715 }
@@ -520,7 +760,8 @@ X509 *load_cert(BIO *err, char *file, int format)
520 ah->data=NULL; 760 ah->data=NULL;
521 } 761 }
522 else if (format == FORMAT_PEM) 762 else if (format == FORMAT_PEM)
523 x=PEM_read_bio_X509_AUX(cert,NULL,NULL,NULL); 763 x=PEM_read_bio_X509_AUX(cert,NULL,
764 (pem_password_cb *)password_callback, NULL);
524 else if (format == FORMAT_PKCS12) 765 else if (format == FORMAT_PKCS12)
525 { 766 {
526 PKCS12 *p12 = d2i_PKCS12_bio(cert, NULL); 767 PKCS12 *p12 = d2i_PKCS12_bio(cert, NULL);
@@ -530,7 +771,8 @@ X509 *load_cert(BIO *err, char *file, int format)
530 p12 = NULL; 771 p12 = NULL;
531 } 772 }
532 else { 773 else {
533 BIO_printf(err,"bad input format specified for input cert\n"); 774 BIO_printf(err,"bad input format specified for %s\n",
775 cert_descrip);
534 goto end; 776 goto end;
535 } 777 }
536end: 778end:
@@ -545,16 +787,30 @@ end:
545 return(x); 787 return(x);
546 } 788 }
547 789
548EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass) 790EVP_PKEY *load_key(BIO *err, const char *file, int format,
791 const char *pass, ENGINE *e, const char *key_descrip)
549 { 792 {
550 BIO *key=NULL; 793 BIO *key=NULL;
551 EVP_PKEY *pkey=NULL; 794 EVP_PKEY *pkey=NULL;
795 PW_CB_DATA cb_data;
796
797 cb_data.password = pass;
798 cb_data.prompt_info = file;
552 799
553 if (file == NULL) 800 if (file == NULL)
554 { 801 {
555 BIO_printf(err,"no keyfile specified\n"); 802 BIO_printf(err,"no keyfile specified\n");
556 goto end; 803 goto end;
557 } 804 }
805 if (format == FORMAT_ENGINE)
806 {
807 if (!e)
808 BIO_printf(bio_err,"no engine specified\n");
809 else
810 pkey = ENGINE_load_private_key(e, file,
811 ui_method, &cb_data);
812 goto end;
813 }
558 key=BIO_new(BIO_s_file()); 814 key=BIO_new(BIO_s_file());
559 if (key == NULL) 815 if (key == NULL)
560 { 816 {
@@ -563,7 +819,8 @@ EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
563 } 819 }
564 if (BIO_read_filename(key,file) <= 0) 820 if (BIO_read_filename(key,file) <= 0)
565 { 821 {
566 perror(file); 822 BIO_printf(err, "Error opening %s %s\n", key_descrip, file);
823 ERR_print_errors(err);
567 goto end; 824 goto end;
568 } 825 }
569 if (format == FORMAT_ASN1) 826 if (format == FORMAT_ASN1)
@@ -572,8 +829,13 @@ EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
572 } 829 }
573 else if (format == FORMAT_PEM) 830 else if (format == FORMAT_PEM)
574 { 831 {
575 pkey=PEM_read_bio_PrivateKey(key,NULL,NULL,pass); 832 pkey=PEM_read_bio_PrivateKey(key,NULL,
833 (pem_password_cb *)password_callback, &cb_data);
576 } 834 }
835#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
836 else if (format == FORMAT_NETSCAPE || format == FORMAT_IISSGC)
837 pkey = load_netscape_key(err, key, file, key_descrip, format);
838#endif
577 else if (format == FORMAT_PKCS12) 839 else if (format == FORMAT_PKCS12)
578 { 840 {
579 PKCS12 *p12 = d2i_PKCS12_bio(key, NULL); 841 PKCS12 *p12 = d2i_PKCS12_bio(key, NULL);
@@ -584,26 +846,40 @@ EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
584 } 846 }
585 else 847 else
586 { 848 {
587 BIO_printf(err,"bad input format specified for key\n"); 849 BIO_printf(err,"bad input format specified for key file\n");
588 goto end; 850 goto end;
589 } 851 }
590 end: 852 end:
591 if (key != NULL) BIO_free(key); 853 if (key != NULL) BIO_free(key);
592 if (pkey == NULL) 854 if (pkey == NULL)
593 BIO_printf(err,"unable to load Private Key\n"); 855 BIO_printf(err,"unable to load %s\n", key_descrip);
594 return(pkey); 856 return(pkey);
595 } 857 }
596 858
597EVP_PKEY *load_pubkey(BIO *err, char *file, int format) 859EVP_PKEY *load_pubkey(BIO *err, const char *file, int format,
860 const char *pass, ENGINE *e, const char *key_descrip)
598 { 861 {
599 BIO *key=NULL; 862 BIO *key=NULL;
600 EVP_PKEY *pkey=NULL; 863 EVP_PKEY *pkey=NULL;
864 PW_CB_DATA cb_data;
865
866 cb_data.password = pass;
867 cb_data.prompt_info = file;
601 868
602 if (file == NULL) 869 if (file == NULL)
603 { 870 {
604 BIO_printf(err,"no keyfile specified\n"); 871 BIO_printf(err,"no keyfile specified\n");
605 goto end; 872 goto end;
606 } 873 }
874 if (format == FORMAT_ENGINE)
875 {
876 if (!e)
877 BIO_printf(bio_err,"no engine specified\n");
878 else
879 pkey = ENGINE_load_public_key(e, file,
880 ui_method, &cb_data);
881 goto end;
882 }
607 key=BIO_new(BIO_s_file()); 883 key=BIO_new(BIO_s_file());
608 if (key == NULL) 884 if (key == NULL)
609 { 885 {
@@ -612,7 +888,8 @@ EVP_PKEY *load_pubkey(BIO *err, char *file, int format)
612 } 888 }
613 if (BIO_read_filename(key,file) <= 0) 889 if (BIO_read_filename(key,file) <= 0)
614 { 890 {
615 perror(file); 891 BIO_printf(err, "Error opening %s %s\n", key_descrip, file);
892 ERR_print_errors(err);
616 goto end; 893 goto end;
617 } 894 }
618 if (format == FORMAT_ASN1) 895 if (format == FORMAT_ASN1)
@@ -621,27 +898,83 @@ EVP_PKEY *load_pubkey(BIO *err, char *file, int format)
621 } 898 }
622 else if (format == FORMAT_PEM) 899 else if (format == FORMAT_PEM)
623 { 900 {
624 pkey=PEM_read_bio_PUBKEY(key,NULL,NULL,NULL); 901 pkey=PEM_read_bio_PUBKEY(key,NULL,
902 (pem_password_cb *)password_callback, &cb_data);
625 } 903 }
904#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
905 else if (format == FORMAT_NETSCAPE || format == FORMAT_IISSGC)
906 pkey = load_netscape_key(err, key, file, key_descrip, format);
907#endif
626 else 908 else
627 { 909 {
628 BIO_printf(err,"bad input format specified for key\n"); 910 BIO_printf(err,"bad input format specified for key file\n");
629 goto end; 911 goto end;
630 } 912 }
631 end: 913 end:
632 if (key != NULL) BIO_free(key); 914 if (key != NULL) BIO_free(key);
633 if (pkey == NULL) 915 if (pkey == NULL)
634 BIO_printf(err,"unable to load Public Key\n"); 916 BIO_printf(err,"unable to load %s\n", key_descrip);
635 return(pkey); 917 return(pkey);
636 } 918 }
637 919
638STACK_OF(X509) *load_certs(BIO *err, char *file, int format) 920#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
921EVP_PKEY *
922load_netscape_key(BIO *err, BIO *key, const char *file,
923 const char *key_descrip, int format)
924 {
925 EVP_PKEY *pkey;
926 BUF_MEM *buf;
927 RSA *rsa;
928 const unsigned char *p;
929 int size, i;
930
931 buf=BUF_MEM_new();
932 pkey = EVP_PKEY_new();
933 size = 0;
934 if (buf == NULL || pkey == NULL)
935 goto error;
936 for (;;)
937 {
938 if (!BUF_MEM_grow(buf,size+1024*10))
939 goto error;
940 i = BIO_read(key, &(buf->data[size]), 1024*10);
941 size += i;
942 if (i == 0)
943 break;
944 if (i < 0)
945 {
946 BIO_printf(err, "Error reading %s %s",
947 key_descrip, file);
948 goto error;
949 }
950 }
951 p=(unsigned char *)buf->data;
952 rsa = d2i_RSA_NET(NULL,&p,(long)size,NULL,
953 (format == FORMAT_IISSGC ? 1 : 0));
954 if (rsa == NULL)
955 goto error;
956 BUF_MEM_free(buf);
957 EVP_PKEY_set1_RSA(pkey, rsa);
958 return pkey;
959error:
960 BUF_MEM_free(buf);
961 EVP_PKEY_free(pkey);
962 return NULL;
963 }
964#endif /* ndef OPENSSL_NO_RC4 */
965
966STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
967 const char *pass, ENGINE *e, const char *cert_descrip)
639 { 968 {
640 BIO *certs; 969 BIO *certs;
641 int i; 970 int i;
642 STACK_OF(X509) *othercerts = NULL; 971 STACK_OF(X509) *othercerts = NULL;
643 STACK_OF(X509_INFO) *allcerts = NULL; 972 STACK_OF(X509_INFO) *allcerts = NULL;
644 X509_INFO *xi; 973 X509_INFO *xi;
974 PW_CB_DATA cb_data;
975
976 cb_data.password = pass;
977 cb_data.prompt_info = file;
645 978
646 if((certs = BIO_new(BIO_s_file())) == NULL) 979 if((certs = BIO_new(BIO_s_file())) == NULL)
647 { 980 {
@@ -655,7 +988,9 @@ STACK_OF(X509) *load_certs(BIO *err, char *file, int format)
655 { 988 {
656 if (BIO_read_filename(certs,file) <= 0) 989 if (BIO_read_filename(certs,file) <= 0)
657 { 990 {
658 perror(file); 991 BIO_printf(err, "Error opening %s %s\n",
992 cert_descrip, file);
993 ERR_print_errors(err);
659 goto end; 994 goto end;
660 } 995 }
661 } 996 }
@@ -669,7 +1004,8 @@ STACK_OF(X509) *load_certs(BIO *err, char *file, int format)
669 othercerts = NULL; 1004 othercerts = NULL;
670 goto end; 1005 goto end;
671 } 1006 }
672 allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL); 1007 allcerts = PEM_X509_INFO_read_bio(certs, NULL,
1008 (pem_password_cb *)password_callback, &cb_data);
673 for(i = 0; i < sk_X509_INFO_num(allcerts); i++) 1009 for(i = 0; i < sk_X509_INFO_num(allcerts); i++)
674 { 1010 {
675 xi = sk_X509_INFO_value (allcerts, i); 1011 xi = sk_X509_INFO_value (allcerts, i);
@@ -682,7 +1018,8 @@ STACK_OF(X509) *load_certs(BIO *err, char *file, int format)
682 goto end; 1018 goto end;
683 } 1019 }
684 else { 1020 else {
685 BIO_printf(err,"bad input format specified for input cert\n"); 1021 BIO_printf(err,"bad input format specified for %s\n",
1022 cert_descrip);
686 goto end; 1023 goto end;
687 } 1024 }
688end: 1025end:
@@ -696,16 +1033,48 @@ end:
696 return(othercerts); 1033 return(othercerts);
697 } 1034 }
698 1035
699typedef struct { 1036
700 char *name; 1037#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
701 unsigned long flag; 1038/* Return error for unknown extensions */
702 unsigned long mask; 1039#define X509V3_EXT_DEFAULT 0
703} NAME_EX_TBL; 1040/* Print error for unknown extensions */
1041#define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
1042/* ASN1 parse unknown extensions */
1043#define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
1044/* BIO_dump unknown extensions */
1045#define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
1046
1047#define X509_FLAG_CA (X509_FLAG_NO_ISSUER | X509_FLAG_NO_PUBKEY | \
1048 X509_FLAG_NO_HEADER | X509_FLAG_NO_VERSION)
1049
1050int set_cert_ex(unsigned long *flags, const char *arg)
1051{
1052 static const NAME_EX_TBL cert_tbl[] = {
1053 { "compatible", X509_FLAG_COMPAT, 0xffffffffl},
1054 { "ca_default", X509_FLAG_CA, 0xffffffffl},
1055 { "no_header", X509_FLAG_NO_HEADER, 0},
1056 { "no_version", X509_FLAG_NO_VERSION, 0},
1057 { "no_serial", X509_FLAG_NO_SERIAL, 0},
1058 { "no_signame", X509_FLAG_NO_SIGNAME, 0},
1059 { "no_validity", X509_FLAG_NO_VALIDITY, 0},
1060 { "no_subject", X509_FLAG_NO_SUBJECT, 0},
1061 { "no_issuer", X509_FLAG_NO_ISSUER, 0},
1062 { "no_pubkey", X509_FLAG_NO_PUBKEY, 0},
1063 { "no_extensions", X509_FLAG_NO_EXTENSIONS, 0},
1064 { "no_sigdump", X509_FLAG_NO_SIGDUMP, 0},
1065 { "no_aux", X509_FLAG_NO_AUX, 0},
1066 { "ext_default", X509V3_EXT_DEFAULT, X509V3_EXT_UNKNOWN_MASK},
1067 { "ext_error", X509V3_EXT_ERROR_UNKNOWN, X509V3_EXT_UNKNOWN_MASK},
1068 { "ext_parse", X509V3_EXT_PARSE_UNKNOWN, X509V3_EXT_UNKNOWN_MASK},
1069 { "ext_dump", X509V3_EXT_DUMP_UNKNOWN, X509V3_EXT_UNKNOWN_MASK},
1070 { NULL, 0, 0}
1071 };
1072 return set_multi_opts(flags, arg, cert_tbl);
1073}
704 1074
705int set_name_ex(unsigned long *flags, const char *arg) 1075int set_name_ex(unsigned long *flags, const char *arg)
706{ 1076{
707 char c; 1077 static const NAME_EX_TBL ex_tbl[] = {
708 const NAME_EX_TBL *ptbl, ex_tbl[] = {
709 { "esc_2253", ASN1_STRFLGS_ESC_2253, 0}, 1078 { "esc_2253", ASN1_STRFLGS_ESC_2253, 0},
710 { "esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0}, 1079 { "esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0},
711 { "esc_msb", ASN1_STRFLGS_ESC_MSB, 0}, 1080 { "esc_msb", ASN1_STRFLGS_ESC_MSB, 0},
@@ -725,15 +1094,95 @@ int set_name_ex(unsigned long *flags, const char *arg)
725 { "nofname", XN_FLAG_FN_NONE, XN_FLAG_FN_MASK}, 1094 { "nofname", XN_FLAG_FN_NONE, XN_FLAG_FN_MASK},
726 { "sname", XN_FLAG_FN_SN, XN_FLAG_FN_MASK}, 1095 { "sname", XN_FLAG_FN_SN, XN_FLAG_FN_MASK},
727 { "lname", XN_FLAG_FN_LN, XN_FLAG_FN_MASK}, 1096 { "lname", XN_FLAG_FN_LN, XN_FLAG_FN_MASK},
1097 { "align", XN_FLAG_FN_ALIGN, 0},
728 { "oid", XN_FLAG_FN_OID, XN_FLAG_FN_MASK}, 1098 { "oid", XN_FLAG_FN_OID, XN_FLAG_FN_MASK},
729 { "space_eq", XN_FLAG_SPC_EQ, 0}, 1099 { "space_eq", XN_FLAG_SPC_EQ, 0},
730 { "dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0}, 1100 { "dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0},
731 { "RFC2253", XN_FLAG_RFC2253, 0xffffffffL}, 1101 { "RFC2253", XN_FLAG_RFC2253, 0xffffffffL},
732 { "oneline", XN_FLAG_ONELINE, 0xffffffffL}, 1102 { "oneline", XN_FLAG_ONELINE, 0xffffffffL},
733 { "multiline", XN_FLAG_MULTILINE, 0xffffffffL}, 1103 { "multiline", XN_FLAG_MULTILINE, 0xffffffffL},
1104 { "ca_default", XN_FLAG_MULTILINE, 0xffffffffL},
734 { NULL, 0, 0} 1105 { NULL, 0, 0}
735 }; 1106 };
1107 return set_multi_opts(flags, arg, ex_tbl);
1108}
1109
1110int set_ext_copy(int *copy_type, const char *arg)
1111{
1112 if (!strcasecmp(arg, "none"))
1113 *copy_type = EXT_COPY_NONE;
1114 else if (!strcasecmp(arg, "copy"))
1115 *copy_type = EXT_COPY_ADD;
1116 else if (!strcasecmp(arg, "copyall"))
1117 *copy_type = EXT_COPY_ALL;
1118 else
1119 return 0;
1120 return 1;
1121}
1122
1123int copy_extensions(X509 *x, X509_REQ *req, int copy_type)
1124{
1125 STACK_OF(X509_EXTENSION) *exts = NULL;
1126 X509_EXTENSION *ext, *tmpext;
1127 ASN1_OBJECT *obj;
1128 int i, idx, ret = 0;
1129 if (!x || !req || (copy_type == EXT_COPY_NONE))
1130 return 1;
1131 exts = X509_REQ_get_extensions(req);
1132
1133 for(i = 0; i < sk_X509_EXTENSION_num(exts); i++) {
1134 ext = sk_X509_EXTENSION_value(exts, i);
1135 obj = X509_EXTENSION_get_object(ext);
1136 idx = X509_get_ext_by_OBJ(x, obj, -1);
1137 /* Does extension exist? */
1138 if (idx != -1) {
1139 /* If normal copy don't override existing extension */
1140 if (copy_type == EXT_COPY_ADD)
1141 continue;
1142 /* Delete all extensions of same type */
1143 do {
1144 tmpext = X509_get_ext(x, idx);
1145 X509_delete_ext(x, idx);
1146 X509_EXTENSION_free(tmpext);
1147 idx = X509_get_ext_by_OBJ(x, obj, -1);
1148 } while (idx != -1);
1149 }
1150 if (!X509_add_ext(x, ext, -1))
1151 goto end;
1152 }
1153
1154 ret = 1;
1155
1156 end:
1157
1158 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
736 1159
1160 return ret;
1161}
1162
1163
1164
1165
1166static int set_multi_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl)
1167{
1168 STACK_OF(CONF_VALUE) *vals;
1169 CONF_VALUE *val;
1170 int i, ret = 1;
1171 if(!arg) return 0;
1172 vals = X509V3_parse_list(arg);
1173 for (i = 0; i < sk_CONF_VALUE_num(vals); i++) {
1174 val = sk_CONF_VALUE_value(vals, i);
1175 if (!set_table_opts(flags, val->name, in_tbl))
1176 ret = 0;
1177 }
1178 sk_CONF_VALUE_pop_free(vals, X509V3_conf_free);
1179 return ret;
1180}
1181
1182static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl)
1183{
1184 char c;
1185 const NAME_EX_TBL *ptbl;
737 c = arg[0]; 1186 c = arg[0];
738 1187
739 if(c == '-') { 1188 if(c == '-') {
@@ -744,8 +1193,8 @@ int set_name_ex(unsigned long *flags, const char *arg)
744 arg++; 1193 arg++;
745 } else c = 1; 1194 } else c = 1;
746 1195
747 for(ptbl = ex_tbl; ptbl->name; ptbl++) { 1196 for(ptbl = in_tbl; ptbl->name; ptbl++) {
748 if(!strcmp(arg, ptbl->name)) { 1197 if(!strcasecmp(arg, ptbl->name)) {
749 *flags &= ~ptbl->mask; 1198 *flags &= ~ptbl->mask;
750 if(c) *flags |= ptbl->flag; 1199 if(c) *flags |= ptbl->flag;
751 else *flags &= ~ptbl->flag; 1200 else *flags &= ~ptbl->flag;
@@ -776,3 +1225,107 @@ void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags)
776 } 1225 }
777} 1226}
778 1227
1228X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
1229{
1230 X509_STORE *store;
1231 X509_LOOKUP *lookup;
1232 if(!(store = X509_STORE_new())) goto end;
1233 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
1234 if (lookup == NULL) goto end;
1235 if (CAfile) {
1236 if(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {
1237 BIO_printf(bp, "Error loading file %s\n", CAfile);
1238 goto end;
1239 }
1240 } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
1241
1242 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
1243 if (lookup == NULL) goto end;
1244 if (CApath) {
1245 if(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {
1246 BIO_printf(bp, "Error loading directory %s\n", CApath);
1247 goto end;
1248 }
1249 } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
1250
1251 ERR_clear_error();
1252 return store;
1253 end:
1254 X509_STORE_free(store);
1255 return NULL;
1256}
1257
1258/* Try to load an engine in a shareable library */
1259ENGINE *try_load_engine(BIO *err, const char *engine, int debug)
1260 {
1261 ENGINE *e = ENGINE_by_id("dynamic");
1262 if (e)
1263 {
1264 if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine, 0)
1265 || !ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))
1266 {
1267 ENGINE_free(e);
1268 e = NULL;
1269 }
1270 }
1271 return e;
1272 }
1273
1274ENGINE *setup_engine(BIO *err, const char *engine, int debug)
1275 {
1276 ENGINE *e = NULL;
1277
1278 if (engine)
1279 {
1280 if(strcmp(engine, "auto") == 0)
1281 {
1282 BIO_printf(err,"enabling auto ENGINE support\n");
1283 ENGINE_register_all_complete();
1284 return NULL;
1285 }
1286 if((e = ENGINE_by_id(engine)) == NULL
1287 && (e = try_load_engine(err, engine, debug)) == NULL)
1288 {
1289 BIO_printf(err,"invalid engine \"%s\"\n", engine);
1290 ERR_print_errors(err);
1291 return NULL;
1292 }
1293 if (debug)
1294 {
1295 ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
1296 0, err, 0);
1297 }
1298 ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, ui_method, 0, 1);
1299 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
1300 {
1301 BIO_printf(err,"can't use that engine\n");
1302 ERR_print_errors(err);
1303 ENGINE_free(e);
1304 return NULL;
1305 }
1306
1307 BIO_printf(err,"engine \"%s\" set.\n", ENGINE_get_id(e));
1308
1309 /* Free our "structural" reference. */
1310 ENGINE_free(e);
1311 }
1312 return e;
1313 }
1314
1315int load_config(BIO *err, CONF *cnf)
1316 {
1317 if (!cnf)
1318 cnf = config;
1319 if (!cnf)
1320 return 1;
1321
1322 OPENSSL_load_builtin_modules();
1323
1324 if (CONF_modules_load(cnf, NULL, 0) <= 0)
1325 {
1326 BIO_printf(err, "Error configuring OpenSSL\n");
1327 ERR_print_errors(err);
1328 return 0;
1329 }
1330 return 1;
1331 }
diff --git a/src/lib/libssl/src/apps/apps.h b/src/lib/libssl/src/apps/apps.h
index 74d479e91d..a05ba712be 100644
--- a/src/lib/libssl/src/apps/apps.h
+++ b/src/lib/libssl/src/apps/apps.h
@@ -55,11 +55,64 @@
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#ifndef HEADER_APPS_H 112#ifndef HEADER_APPS_H
60#define HEADER_APPS_H 113#define HEADER_APPS_H
61 114
62#include "openssl/e_os.h" 115#include "e_os.h"
63 116
64#include <openssl/buffer.h> 117#include <openssl/buffer.h>
65#include <openssl/bio.h> 118#include <openssl/bio.h>
@@ -67,6 +120,9 @@
67#include <openssl/x509.h> 120#include <openssl/x509.h>
68#include <openssl/lhash.h> 121#include <openssl/lhash.h>
69#include <openssl/conf.h> 122#include <openssl/conf.h>
123#include <openssl/txt_db.h>
124#include <openssl/engine.h>
125#include <openssl/ossl_typ.h>
70 126
71int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn); 127int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
72int app_RAND_write_file(const char *file, BIO *bio_e); 128int app_RAND_write_file(const char *file, BIO *bio_e);
@@ -78,11 +134,11 @@ long app_RAND_load_files(char *file); /* `file' is a list of files to read,
78 * (see e_os.h). The string is 134 * (see e_os.h). The string is
79 * destroyed! */ 135 * destroyed! */
80 136
81#ifdef NO_STDIO 137#ifdef OPENSSL_NO_STDIO
82BIO_METHOD *BIO_s_file(); 138BIO_METHOD *BIO_s_file();
83#endif 139#endif
84 140
85#ifdef WIN32 141#ifdef OPENSSL_SYS_WIN32
86#define rename(from,to) WIN32_rename((from),(to)) 142#define rename(from,to) WIN32_rename((from),(to))
87int WIN32_rename(char *oldname,char *newname); 143int WIN32_rename(char *oldname,char *newname);
88#endif 144#endif
@@ -100,7 +156,7 @@ extern BIO *bio_err;
100#else 156#else
101 157
102#define MAIN(a,v) PROG(a,v) 158#define MAIN(a,v) PROG(a,v)
103extern LHASH *config; 159extern CONF *config;
104extern char *default_config_file; 160extern char *default_config_file;
105extern BIO *bio_err; 161extern BIO *bio_err;
106 162
@@ -115,21 +171,34 @@ extern BIO *bio_err;
115#endif 171#endif
116 172
117#if defined(MONOLITH) && !defined(OPENSSL_C) 173#if defined(MONOLITH) && !defined(OPENSSL_C)
118# define apps_startup() do_pipe_sig() 174# define apps_startup() \
175 do_pipe_sig()
176# define apps_shutdown()
119#else 177#else
120# if defined(MSDOS) || defined(WIN16) || defined(WIN32) 178# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN16) || \
179 defined(OPENSSL_SYS_WIN32)
121# ifdef _O_BINARY 180# ifdef _O_BINARY
122# define apps_startup() \ 181# define apps_startup() \
123 _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \ 182 do { _fmode=_O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
124 SSLeay_add_all_algorithms() 183 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
184 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
125# else 185# else
126# define apps_startup() \ 186# define apps_startup() \
127 _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \ 187 do { _fmode=O_BINARY; do_pipe_sig(); CRYPTO_malloc_init(); \
128 SSLeay_add_all_algorithms() 188 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
189 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
129# endif 190# endif
130# else 191# else
131# define apps_startup() do_pipe_sig(); SSLeay_add_all_algorithms(); 192# define apps_startup() \
193 do { do_pipe_sig(); OpenSSL_add_all_algorithms(); \
194 ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); \
195 setup_ui_method(); } while(0)
132# endif 196# endif
197# define apps_shutdown() \
198 do { CONF_modules_unload(1); destroy_ui_method(); \
199 EVP_cleanup(); ENGINE_cleanup(); \
200 CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); \
201 ERR_free_strings(); } while(0)
133#endif 202#endif
134 203
135typedef struct args_st 204typedef struct args_st
@@ -138,6 +207,19 @@ typedef struct args_st
138 int count; 207 int count;
139 } ARGS; 208 } ARGS;
140 209
210#define PW_MIN_LENGTH 4
211typedef struct pw_cb_data
212 {
213 const void *password;
214 const char *prompt_info;
215 } PW_CB_DATA;
216
217int password_callback(char *buf, int bufsiz, int verify,
218 PW_CB_DATA *cb_data);
219
220int setup_ui_method();
221void destroy_ui_method();
222
141int should_retry(int i); 223int should_retry(int i);
142int args_from_file(char *file, int *argc, char **argv[]); 224int args_from_file(char *file, int *argc, char **argv[]);
143int str2fmt(char *s); 225int str2fmt(char *s);
@@ -147,13 +229,29 @@ int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
147int dump_cert_text(BIO *out, X509 *x); 229int dump_cert_text(BIO *out, X509 *x);
148void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags); 230void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags);
149#endif 231#endif
232int set_cert_ex(unsigned long *flags, const char *arg);
150int set_name_ex(unsigned long *flags, const char *arg); 233int set_name_ex(unsigned long *flags, const char *arg);
234int set_ext_copy(int *copy_type, const char *arg);
235int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
151int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2); 236int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
152int add_oid_section(BIO *err, LHASH *conf); 237int add_oid_section(BIO *err, CONF *conf);
153X509 *load_cert(BIO *err, char *file, int format); 238X509 *load_cert(BIO *err, const char *file, int format,
154EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass); 239 const char *pass, ENGINE *e, const char *cert_descrip);
155EVP_PKEY *load_pubkey(BIO *err, char *file, int format); 240EVP_PKEY *load_key(BIO *err, const char *file, int format,
156STACK_OF(X509) *load_certs(BIO *err, char *file, int format); 241 const char *pass, ENGINE *e, const char *key_descrip);
242EVP_PKEY *load_pubkey(BIO *err, const char *file, int format,
243 const char *pass, ENGINE *e, const char *key_descrip);
244STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
245 const char *pass, ENGINE *e, const char *cert_descrip);
246X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
247ENGINE *setup_engine(BIO *err, const char *engine, int debug);
248
249int load_config(BIO *err, CONF *cnf);
250
251/* Functions defined in ca.c and also used in ocsp.c */
252int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
253 ASN1_GENERALIZEDTIME **pinvtm, char *str);
254int make_serial_index(TXT_DB *db);
157 255
158#define FORMAT_UNDEF 0 256#define FORMAT_UNDEF 0
159#define FORMAT_ASN1 1 257#define FORMAT_ASN1 1
@@ -162,8 +260,13 @@ STACK_OF(X509) *load_certs(BIO *err, char *file, int format);
162#define FORMAT_NETSCAPE 4 260#define FORMAT_NETSCAPE 4
163#define FORMAT_PKCS12 5 261#define FORMAT_PKCS12 5
164#define FORMAT_SMIME 6 262#define FORMAT_SMIME 6
165/* Since this is currently inofficial, let's give it a high number */ 263#define FORMAT_ENGINE 7
166#define FORMAT_ENGINE 127 264#define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid
265 * adding yet another param to load_*key() */
266
267#define EXT_COPY_NONE 0
268#define EXT_COPY_ADD 1
269#define EXT_COPY_ALL 2
167 270
168#define NETSCAPE_CERT_HDR "certificate" 271#define NETSCAPE_CERT_HDR "certificate"
169 272
diff --git a/src/lib/libssl/src/apps/asn1pars.c b/src/lib/libssl/src/apps/asn1pars.c
index f25c9f84e8..0e6167d2d4 100644
--- a/src/lib/libssl/src/apps/asn1pars.c
+++ b/src/lib/libssl/src/apps/asn1pars.c
@@ -103,6 +103,9 @@ int MAIN(int argc, char **argv)
103 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 103 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
104 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 104 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
105 105
106 if (!load_config(bio_err, NULL))
107 goto end;
108
106 prog=argv[0]; 109 prog=argv[0];
107 argc--; 110 argc--;
108 argv++; 111 argv++;
@@ -206,7 +209,7 @@ bad:
206 goto end; 209 goto end;
207 } 210 }
208 BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT); 211 BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
209#ifdef VMS 212#ifdef OPENSSL_SYS_VMS
210 { 213 {
211 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 214 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
212 out = BIO_push(tmpbio, out); 215 out = BIO_push(tmpbio, out);
@@ -329,6 +332,7 @@ end:
329 if (at != NULL) ASN1_TYPE_free(at); 332 if (at != NULL) ASN1_TYPE_free(at);
330 if (osk != NULL) sk_free(osk); 333 if (osk != NULL) sk_free(osk);
331 OBJ_cleanup(); 334 OBJ_cleanup();
335 apps_shutdown();
332 EXIT(ret); 336 EXIT(ret);
333 } 337 }
334 338
diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c
index f3fb45b7b4..8be557c956 100644
--- a/src/lib/libssl/src/apps/ca.c
+++ b/src/lib/libssl/src/apps/ca.c
@@ -61,6 +61,7 @@
61#include <stdio.h> 61#include <stdio.h>
62#include <stdlib.h> 62#include <stdlib.h>
63#include <string.h> 63#include <string.h>
64#include <ctype.h>
64#include <sys/types.h> 65#include <sys/types.h>
65#include <sys/stat.h> 66#include <sys/stat.h>
66#include "apps.h" 67#include "apps.h"
@@ -73,17 +74,23 @@
73#include <openssl/x509.h> 74#include <openssl/x509.h>
74#include <openssl/x509v3.h> 75#include <openssl/x509v3.h>
75#include <openssl/objects.h> 76#include <openssl/objects.h>
77#include <openssl/ocsp.h>
76#include <openssl/pem.h> 78#include <openssl/pem.h>
77#include <openssl/engine.h> 79
80#ifdef OPENSSL_SYS_WINDOWS
81#define strcasecmp _stricmp
82#else
83#include <strings.h>
84#endif
78 85
79#ifndef W_OK 86#ifndef W_OK
80# ifdef VMS 87# ifdef OPENSSL_SYS_VMS
81# if defined(__DECC) 88# if defined(__DECC)
82# include <unistd.h> 89# include <unistd.h>
83# else 90# else
84# include <unixlib.h> 91# include <unixlib.h>
85# endif 92# endif
86# else 93# elif !defined(OPENSSL_SYS_VXWORKS)
87# include <sys/file.h> 94# include <sys/file.h>
88# endif 95# endif
89#endif 96#endif
@@ -119,11 +126,15 @@
119#define ENV_DEFAULT_CRL_DAYS "default_crl_days" 126#define ENV_DEFAULT_CRL_DAYS "default_crl_days"
120#define ENV_DEFAULT_CRL_HOURS "default_crl_hours" 127#define ENV_DEFAULT_CRL_HOURS "default_crl_hours"
121#define ENV_DEFAULT_MD "default_md" 128#define ENV_DEFAULT_MD "default_md"
129#define ENV_DEFAULT_EMAIL_DN "email_in_dn"
122#define ENV_PRESERVE "preserve" 130#define ENV_PRESERVE "preserve"
123#define ENV_POLICY "policy" 131#define ENV_POLICY "policy"
124#define ENV_EXTENSIONS "x509_extensions" 132#define ENV_EXTENSIONS "x509_extensions"
125#define ENV_CRLEXT "crl_extensions" 133#define ENV_CRLEXT "crl_extensions"
126#define ENV_MSIE_HACK "msie_hack" 134#define ENV_MSIE_HACK "msie_hack"
135#define ENV_NAMEOPT "name_opt"
136#define ENV_CERTOPT "cert_opt"
137#define ENV_EXTCOPY "copy_extensions"
127 138
128#define ENV_DATABASE "database" 139#define ENV_DATABASE "database"
129 140
@@ -139,6 +150,14 @@
139#define DB_TYPE_EXP 'E' 150#define DB_TYPE_EXP 'E'
140#define DB_TYPE_VAL 'V' 151#define DB_TYPE_VAL 'V'
141 152
153/* Additional revocation information types */
154
155#define REV_NONE 0 /* No addditional information */
156#define REV_CRL_REASON 1 /* Value is CRL reason code */
157#define REV_HOLD 2 /* Value is hold instruction */
158#define REV_KEY_COMPROMISE 3 /* Value is cert key compromise time */
159#define REV_CA_COMPROMISE 4 /* Value is CA key compromise time */
160
142static char *ca_usage[]={ 161static char *ca_usage[]={
143"usage: ca args\n", 162"usage: ca args\n",
144"\n", 163"\n",
@@ -153,7 +172,8 @@ static char *ca_usage[]={
153" -days arg - number of days to certify the certificate for\n", 172" -days arg - number of days to certify the certificate for\n",
154" -md arg - md to use, one of md2, md5, sha or sha1\n", 173" -md arg - md to use, one of md2, md5, sha or sha1\n",
155" -policy arg - The CA 'policy' to support\n", 174" -policy arg - The CA 'policy' to support\n",
156" -keyfile arg - PEM private key file\n", 175" -keyfile arg - private key file\n",
176" -keyform arg - private key file format (PEM or ENGINE)\n",
157" -key arg - key to decode the private key if it is encrypted\n", 177" -key arg - key to decode the private key if it is encrypted\n",
158" -cert file - The CA certificate\n", 178" -cert file - The CA certificate\n",
159" -in file - The input PEM encoded certificate request(s)\n", 179" -in file - The input PEM encoded certificate request(s)\n",
@@ -163,12 +183,17 @@ static char *ca_usage[]={
163" -spkac file - File contains DN and signed public key and challenge\n", 183" -spkac file - File contains DN and signed public key and challenge\n",
164" -ss_cert file - File contains a self signed cert to sign\n", 184" -ss_cert file - File contains a self signed cert to sign\n",
165" -preserveDN - Don't re-order the DN\n", 185" -preserveDN - Don't re-order the DN\n",
186" -noemailDN - Don't add the EMAIL field into certificate' subject\n",
166" -batch - Don't ask questions\n", 187" -batch - Don't ask questions\n",
167" -msie_hack - msie modifications to handle all those universal strings\n", 188" -msie_hack - msie modifications to handle all those universal strings\n",
168" -revoke file - Revoke a certificate (given in file)\n", 189" -revoke file - Revoke a certificate (given in file)\n",
190" -subj arg - Use arg instead of request's subject\n",
169" -extensions .. - Extension section (override value in config file)\n", 191" -extensions .. - Extension section (override value in config file)\n",
192" -extfile file - Configuration file with X509v3 extentions to add\n",
170" -crlexts .. - CRL extension section (override value in config file)\n", 193" -crlexts .. - CRL extension section (override value in config file)\n",
171" -engine e - use engine e, possibly a hardware device.\n", 194" -engine e - use engine e, possibly a hardware device.\n",
195" -status serial - Shows certificate status given the serial number\n",
196" -updatedb - Updates db for expired certificates\n",
172NULL 197NULL
173}; 198};
174 199
@@ -179,55 +204,78 @@ extern int EF_ALIGNMENT;
179#endif 204#endif
180 205
181static void lookup_fail(char *name,char *tag); 206static void lookup_fail(char *name,char *tag);
182static unsigned long index_serial_hash(char **a); 207static unsigned long index_serial_hash(const char **a);
183static int index_serial_cmp(char **a, char **b); 208static int index_serial_cmp(const char **a, const char **b);
184static unsigned long index_name_hash(char **a); 209static unsigned long index_name_hash(const char **a);
185static int index_name_qual(char **a); 210static int index_name_qual(char **a);
186static int index_name_cmp(char **a,char **b); 211static int index_name_cmp(const char **a,const char **b);
187static BIGNUM *load_serial(char *serialfile); 212static BIGNUM *load_serial(char *serialfile);
188static int save_serial(char *serialfile, BIGNUM *serial); 213static int save_serial(char *serialfile, BIGNUM *serial);
189static int certify(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509, 214static int certify(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
190 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,TXT_DB *db, 215 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,TXT_DB *db,
191 BIGNUM *serial, char *startdate,char *enddate, int days, 216 BIGNUM *serial, char *subj, int email_dn, char *startdate,
192 int batch, char *ext_sect, LHASH *conf,int verbose); 217 char *enddate, long days, int batch, char *ext_sect, CONF *conf,
218 int verbose, unsigned long certopt, unsigned long nameopt,
219 int default_op, int ext_copy);
193static int certify_cert(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509, 220static int certify_cert(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
194 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy, 221 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,
195 TXT_DB *db, BIGNUM *serial,char *startdate, 222 TXT_DB *db, BIGNUM *serial, char *subj, int email_dn,
196 char *enddate, int days, int batch, char *ext_sect, 223 char *startdate, char *enddate, long days, int batch,
197 LHASH *conf,int verbose); 224 char *ext_sect, CONF *conf,int verbose, unsigned long certopt,
225 unsigned long nameopt, int default_op, int ext_copy,
226 ENGINE *e);
198static int certify_spkac(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509, 227static int certify_spkac(X509 **xret, char *infile,EVP_PKEY *pkey,X509 *x509,
199 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy, 228 const EVP_MD *dgst,STACK_OF(CONF_VALUE) *policy,
200 TXT_DB *db, BIGNUM *serial,char *startdate, 229 TXT_DB *db, BIGNUM *serial,char *subj, int email_dn,
201 char *enddate, int days, char *ext_sect,LHASH *conf, 230 char *startdate, char *enddate, long days, char *ext_sect,
202 int verbose); 231 CONF *conf, int verbose, unsigned long certopt,
232 unsigned long nameopt, int default_op, int ext_copy);
203static int fix_data(int nid, int *type); 233static int fix_data(int nid, int *type);
204static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext); 234static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext);
205static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, 235static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
206 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial, 236 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial,char *subj,
207 char *startdate, char *enddate, int days, int batch, int verbose, 237 int email_dn, char *startdate, char *enddate, long days, int batch,
208 X509_REQ *req, char *ext_sect, LHASH *conf); 238 int verbose, X509_REQ *req, char *ext_sect, CONF *conf,
209static int do_revoke(X509 *x509, TXT_DB *db); 239 unsigned long certopt, unsigned long nameopt, int default_op,
240 int ext_copy);
241static X509_NAME *do_subject(char *subject);
242static int do_revoke(X509 *x509, TXT_DB *db, int ext, char *extval);
243static int get_certificate_status(const char *ser_status, TXT_DB *db);
244static int do_updatedb(TXT_DB *db);
210static int check_time_format(char *str); 245static int check_time_format(char *str);
211static LHASH *conf=NULL; 246char *make_revocation_str(int rev_type, char *rev_arg);
247int make_revoked(X509_REVOKED *rev, char *str);
248int old_entry_print(BIO *bp, ASN1_OBJECT *obj, ASN1_STRING *str);
249static CONF *conf=NULL;
250static CONF *extconf=NULL;
212static char *section=NULL; 251static char *section=NULL;
213 252
214static int preserve=0; 253static int preserve=0;
215static int msie_hack=0; 254static int msie_hack=0;
216 255
256static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
257static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
258static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
259static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
260
261
217int MAIN(int, char **); 262int MAIN(int, char **);
218 263
219int MAIN(int argc, char **argv) 264int MAIN(int argc, char **argv)
220 { 265 {
221 ENGINE *e = NULL; 266 ENGINE *e = NULL;
222 char *key=NULL,*passargin=NULL; 267 char *key=NULL,*passargin=NULL;
268 int free_key = 0;
223 int total=0; 269 int total=0;
224 int total_done=0; 270 int total_done=0;
225 int badops=0; 271 int badops=0;
226 int ret=1; 272 int ret=1;
273 int email_dn=1;
227 int req=0; 274 int req=0;
228 int verbose=0; 275 int verbose=0;
229 int gencrl=0; 276 int gencrl=0;
230 int dorevoke=0; 277 int dorevoke=0;
278 int doupdatedb=0;
231 long crldays=0; 279 long crldays=0;
232 long crlhours=0; 280 long crlhours=0;
233 long errorline= -1; 281 long errorline= -1;
@@ -236,37 +284,47 @@ int MAIN(int argc, char **argv)
236 char *policy=NULL; 284 char *policy=NULL;
237 char *keyfile=NULL; 285 char *keyfile=NULL;
238 char *certfile=NULL; 286 char *certfile=NULL;
287 int keyform=FORMAT_PEM;
239 char *infile=NULL; 288 char *infile=NULL;
240 char *spkac_file=NULL; 289 char *spkac_file=NULL;
241 char *ss_cert_file=NULL; 290 char *ss_cert_file=NULL;
291 char *ser_status=NULL;
242 EVP_PKEY *pkey=NULL; 292 EVP_PKEY *pkey=NULL;
243 int output_der = 0; 293 int output_der = 0;
244 char *outfile=NULL; 294 char *outfile=NULL;
245 char *outdir=NULL; 295 char *outdir=NULL;
246 char *serialfile=NULL; 296 char *serialfile=NULL;
247 char *extensions=NULL; 297 char *extensions=NULL;
298 char *extfile=NULL;
299 char *subj=NULL;
300 char *tmp_email_dn=NULL;
248 char *crl_ext=NULL; 301 char *crl_ext=NULL;
302 int rev_type = REV_NONE;
303 char *rev_arg = NULL;
249 BIGNUM *serial=NULL; 304 BIGNUM *serial=NULL;
250 char *startdate=NULL; 305 char *startdate=NULL;
251 char *enddate=NULL; 306 char *enddate=NULL;
252 int days=0; 307 long days=0;
253 int batch=0; 308 int batch=0;
254 int notext=0; 309 int notext=0;
310 unsigned long nameopt = 0, certopt = 0;
311 int default_op = 1;
312 int ext_copy = EXT_COPY_NONE;
255 X509 *x509=NULL; 313 X509 *x509=NULL;
256 X509 *x=NULL; 314 X509 *x=NULL;
257 BIO *in=NULL,*out=NULL,*Sout=NULL,*Cout=NULL; 315 BIO *in=NULL,*out=NULL,*Sout=NULL,*Cout=NULL;
258 char *dbfile=NULL; 316 char *dbfile=NULL;
259 TXT_DB *db=NULL; 317 TXT_DB *db=NULL;
260 X509_CRL *crl=NULL; 318 X509_CRL *crl=NULL;
261 X509_CRL_INFO *ci=NULL;
262 X509_REVOKED *r=NULL; 319 X509_REVOKED *r=NULL;
320 ASN1_TIME *tmptm;
321 ASN1_INTEGER *tmpser;
263 char **pp,*p,*f; 322 char **pp,*p,*f;
264 int i,j; 323 int i,j;
265 long l; 324 long l;
266 const EVP_MD *dgst=NULL; 325 const EVP_MD *dgst=NULL;
267 STACK_OF(CONF_VALUE) *attribs=NULL; 326 STACK_OF(CONF_VALUE) *attribs=NULL;
268 STACK_OF(X509) *cert_sk=NULL; 327 STACK_OF(X509) *cert_sk=NULL;
269 BIO *hex=NULL;
270#undef BSIZE 328#undef BSIZE
271#define BSIZE 256 329#define BSIZE 256
272 MS_STATIC char buf[3][BSIZE]; 330 MS_STATIC char buf[3][BSIZE];
@@ -307,6 +365,12 @@ EF_ALIGNMENT=0;
307 if (--argc < 1) goto bad; 365 if (--argc < 1) goto bad;
308 section= *(++argv); 366 section= *(++argv);
309 } 367 }
368 else if (strcmp(*argv,"-subj") == 0)
369 {
370 if (--argc < 1) goto bad;
371 subj= *(++argv);
372 /* preserve=1; */
373 }
310 else if (strcmp(*argv,"-startdate") == 0) 374 else if (strcmp(*argv,"-startdate") == 0)
311 { 375 {
312 if (--argc < 1) goto bad; 376 if (--argc < 1) goto bad;
@@ -337,6 +401,11 @@ EF_ALIGNMENT=0;
337 if (--argc < 1) goto bad; 401 if (--argc < 1) goto bad;
338 keyfile= *(++argv); 402 keyfile= *(++argv);
339 } 403 }
404 else if (strcmp(*argv,"-keyform") == 0)
405 {
406 if (--argc < 1) goto bad;
407 keyform=str2fmt(*(++argv));
408 }
340 else if (strcmp(*argv,"-passin") == 0) 409 else if (strcmp(*argv,"-passin") == 0)
341 { 410 {
342 if (--argc < 1) goto bad; 411 if (--argc < 1) goto bad;
@@ -374,6 +443,8 @@ EF_ALIGNMENT=0;
374 batch=1; 443 batch=1;
375 else if (strcmp(*argv,"-preserveDN") == 0) 444 else if (strcmp(*argv,"-preserveDN") == 0)
376 preserve=1; 445 preserve=1;
446 else if (strcmp(*argv,"-noemailDN") == 0)
447 email_dn=0;
377 else if (strcmp(*argv,"-gencrl") == 0) 448 else if (strcmp(*argv,"-gencrl") == 0)
378 gencrl=1; 449 gencrl=1;
379 else if (strcmp(*argv,"-msie_hack") == 0) 450 else if (strcmp(*argv,"-msie_hack") == 0)
@@ -418,11 +489,49 @@ EF_ALIGNMENT=0;
418 if (--argc < 1) goto bad; 489 if (--argc < 1) goto bad;
419 extensions= *(++argv); 490 extensions= *(++argv);
420 } 491 }
492 else if (strcmp(*argv,"-extfile") == 0)
493 {
494 if (--argc < 1) goto bad;
495 extfile= *(++argv);
496 }
497 else if (strcmp(*argv,"-status") == 0)
498 {
499 if (--argc < 1) goto bad;
500 ser_status= *(++argv);
501 }
502 else if (strcmp(*argv,"-updatedb") == 0)
503 {
504 doupdatedb=1;
505 }
421 else if (strcmp(*argv,"-crlexts") == 0) 506 else if (strcmp(*argv,"-crlexts") == 0)
422 { 507 {
423 if (--argc < 1) goto bad; 508 if (--argc < 1) goto bad;
424 crl_ext= *(++argv); 509 crl_ext= *(++argv);
425 } 510 }
511 else if (strcmp(*argv,"-crl_reason") == 0)
512 {
513 if (--argc < 1) goto bad;
514 rev_arg = *(++argv);
515 rev_type = REV_CRL_REASON;
516 }
517 else if (strcmp(*argv,"-crl_hold") == 0)
518 {
519 if (--argc < 1) goto bad;
520 rev_arg = *(++argv);
521 rev_type = REV_HOLD;
522 }
523 else if (strcmp(*argv,"-crl_compromise") == 0)
524 {
525 if (--argc < 1) goto bad;
526 rev_arg = *(++argv);
527 rev_type = REV_KEY_COMPROMISE;
528 }
529 else if (strcmp(*argv,"-crl_CA_compromise") == 0)
530 {
531 if (--argc < 1) goto bad;
532 rev_arg = *(++argv);
533 rev_type = REV_CA_COMPROMISE;
534 }
426 else if (strcmp(*argv,"-engine") == 0) 535 else if (strcmp(*argv,"-engine") == 0)
427 { 536 {
428 if (--argc < 1) goto bad; 537 if (--argc < 1) goto bad;
@@ -442,29 +551,13 @@ bad:
442 if (badops) 551 if (badops)
443 { 552 {
444 for (pp=ca_usage; (*pp != NULL); pp++) 553 for (pp=ca_usage; (*pp != NULL); pp++)
445 BIO_printf(bio_err,*pp); 554 BIO_printf(bio_err,"%s",*pp);
446 goto err; 555 goto err;
447 } 556 }
448 557
449 ERR_load_crypto_strings(); 558 ERR_load_crypto_strings();
450 559
451 if (engine != NULL) 560 e = setup_engine(bio_err, engine, 0);
452 {
453 if((e = ENGINE_by_id(engine)) == NULL)
454 {
455 BIO_printf(bio_err,"invalid engine \"%s\"\n",
456 engine);
457 goto err;
458 }
459 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
460 {
461 BIO_printf(bio_err,"can't use that engine\n");
462 goto err;
463 }
464 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
465 /* Free our "structural" reference. */
466 ENGINE_free(e);
467 }
468 561
469 /*****************************************************************/ 562 /*****************************************************************/
470 if (configfile == NULL) configfile = getenv("OPENSSL_CONF"); 563 if (configfile == NULL) configfile = getenv("OPENSSL_CONF");
@@ -472,12 +565,13 @@ bad:
472 if (configfile == NULL) 565 if (configfile == NULL)
473 { 566 {
474 /* We will just use 'buf[0]' as a temporary buffer. */ 567 /* We will just use 'buf[0]' as a temporary buffer. */
475#ifdef VMS 568#ifdef OPENSSL_SYS_VMS
476 strncpy(buf[0],X509_get_default_cert_area(), 569 strncpy(buf[0],X509_get_default_cert_area(),
477 sizeof(buf[0])-1-sizeof(CONFIG_FILE)); 570 sizeof(buf[0])-1-sizeof(CONFIG_FILE));
478#else 571#else
479 strncpy(buf[0],X509_get_default_cert_area(), 572 strncpy(buf[0],X509_get_default_cert_area(),
480 sizeof(buf[0])-2-sizeof(CONFIG_FILE)); 573 sizeof(buf[0])-2-sizeof(CONFIG_FILE));
574 buf[0][sizeof(buf[0])-2-sizeof(CONFIG_FILE)]='\0';
481 strcat(buf[0],"/"); 575 strcat(buf[0],"/");
482#endif 576#endif
483 strcat(buf[0],CONFIG_FILE); 577 strcat(buf[0],CONFIG_FILE);
@@ -485,7 +579,8 @@ bad:
485 } 579 }
486 580
487 BIO_printf(bio_err,"Using configuration from %s\n",configfile); 581 BIO_printf(bio_err,"Using configuration from %s\n",configfile);
488 if ((conf=CONF_load(NULL,configfile,&errorline)) == NULL) 582 conf = NCONF_new(NULL);
583 if (NCONF_load(conf,configfile,&errorline) <= 0)
489 { 584 {
490 if (errorline <= 0) 585 if (errorline <= 0)
491 BIO_printf(bio_err,"error loading the config file '%s'\n", 586 BIO_printf(bio_err,"error loading the config file '%s'\n",
@@ -496,10 +591,13 @@ bad:
496 goto err; 591 goto err;
497 } 592 }
498 593
594 if (!load_config(bio_err, conf))
595 goto err;
596
499 /* Lets get the config section we are using */ 597 /* Lets get the config section we are using */
500 if (section == NULL) 598 if (section == NULL)
501 { 599 {
502 section=CONF_get_string(conf,BASE_SECTION,ENV_DEFAULT_CA); 600 section=NCONF_get_string(conf,BASE_SECTION,ENV_DEFAULT_CA);
503 if (section == NULL) 601 if (section == NULL)
504 { 602 {
505 lookup_fail(BASE_SECTION,ENV_DEFAULT_CA); 603 lookup_fail(BASE_SECTION,ENV_DEFAULT_CA);
@@ -509,7 +607,9 @@ bad:
509 607
510 if (conf != NULL) 608 if (conf != NULL)
511 { 609 {
512 p=CONF_get_string(conf,NULL,"oid_file"); 610 p=NCONF_get_string(conf,NULL,"oid_file");
611 if (p == NULL)
612 ERR_clear_error();
513 if (p != NULL) 613 if (p != NULL)
514 { 614 {
515 BIO *oid_bio; 615 BIO *oid_bio;
@@ -529,14 +629,16 @@ bad:
529 BIO_free(oid_bio); 629 BIO_free(oid_bio);
530 } 630 }
531 } 631 }
532 if(!add_oid_section(bio_err,conf)) 632 if (!add_oid_section(bio_err,conf))
533 { 633 {
534 ERR_print_errors(bio_err); 634 ERR_print_errors(bio_err);
535 goto err; 635 goto err;
536 } 636 }
537 } 637 }
538 638
539 randfile = CONF_get_string(conf, BASE_SECTION, "RANDFILE"); 639 randfile = NCONF_get_string(conf, BASE_SECTION, "RANDFILE");
640 if (randfile == NULL)
641 ERR_clear_error();
540 app_RAND_load_file(randfile, bio_err, 0); 642 app_RAND_load_file(randfile, bio_err, 0);
541 643
542 in=BIO_new(BIO_s_file()); 644 in=BIO_new(BIO_s_file());
@@ -550,53 +652,71 @@ bad:
550 } 652 }
551 653
552 /*****************************************************************/ 654 /*****************************************************************/
553 /* we definitely need an public key, so lets get it */ 655 /* report status of cert with serial number given on command line */
656 if (ser_status)
657 {
658 if ((dbfile=NCONF_get_string(conf,section,ENV_DATABASE)) == NULL)
659 {
660 lookup_fail(section,ENV_DATABASE);
661 goto err;
662 }
663 if (BIO_read_filename(in,dbfile) <= 0)
664 {
665 perror(dbfile);
666 BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
667 goto err;
668 }
669 db=TXT_DB_read(in,DB_NUMBER);
670 if (db == NULL) goto err;
554 671
555 if ((keyfile == NULL) && ((keyfile=CONF_get_string(conf, 672 if (!make_serial_index(db))
673 goto err;
674
675 if (get_certificate_status(ser_status,db) != 1)
676 BIO_printf(bio_err,"Error verifying serial %s!\n",
677 ser_status);
678 goto err;
679 }
680
681 /*****************************************************************/
682 /* we definitely need a public key, so let's get it */
683
684 if ((keyfile == NULL) && ((keyfile=NCONF_get_string(conf,
556 section,ENV_PRIVATE_KEY)) == NULL)) 685 section,ENV_PRIVATE_KEY)) == NULL))
557 { 686 {
558 lookup_fail(section,ENV_PRIVATE_KEY); 687 lookup_fail(section,ENV_PRIVATE_KEY);
559 goto err; 688 goto err;
560 } 689 }
561 if(!key && !app_passwd(bio_err, passargin, NULL, &key, NULL)) 690 if (!key)
562 {
563 BIO_printf(bio_err,"Error getting password\n");
564 goto err;
565 }
566 if (BIO_read_filename(in,keyfile) <= 0)
567 { 691 {
568 perror(keyfile); 692 free_key = 1;
569 BIO_printf(bio_err,"trying to load CA private key\n"); 693 if (!app_passwd(bio_err, passargin, NULL, &key, NULL))
570 goto err; 694 {
695 BIO_printf(bio_err,"Error getting password\n");
696 goto err;
697 }
571 } 698 }
572 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,key); 699 pkey = load_key(bio_err, keyfile, keyform, key, e,
573 if(key) memset(key,0,strlen(key)); 700 "CA private key");
701 if (key) memset(key,0,strlen(key));
574 if (pkey == NULL) 702 if (pkey == NULL)
575 { 703 {
576 BIO_printf(bio_err,"unable to load CA private key\n"); 704 /* load_key() has already printed an appropriate message */
577 goto err; 705 goto err;
578 } 706 }
579 707
580 /*****************************************************************/ 708 /*****************************************************************/
581 /* we need a certificate */ 709 /* we need a certificate */
582 if ((certfile == NULL) && ((certfile=CONF_get_string(conf, 710 if ((certfile == NULL) && ((certfile=NCONF_get_string(conf,
583 section,ENV_CERTIFICATE)) == NULL)) 711 section,ENV_CERTIFICATE)) == NULL))
584 { 712 {
585 lookup_fail(section,ENV_CERTIFICATE); 713 lookup_fail(section,ENV_CERTIFICATE);
586 goto err; 714 goto err;
587 } 715 }
588 if (BIO_read_filename(in,certfile) <= 0) 716 x509=load_cert(bio_err, certfile, FORMAT_PEM, NULL, e,
589 { 717 "CA certificate");
590 perror(certfile);
591 BIO_printf(bio_err,"trying to load CA certificate\n");
592 goto err;
593 }
594 x509=PEM_read_bio_X509(in,NULL,NULL,NULL);
595 if (x509 == NULL) 718 if (x509 == NULL)
596 {
597 BIO_printf(bio_err,"unable to load CA certificate\n");
598 goto err; 719 goto err;
599 }
600 720
601 if (!X509_check_private_key(x509,pkey)) 721 if (!X509_check_private_key(x509,pkey))
602 { 722 {
@@ -604,26 +724,72 @@ bad:
604 goto err; 724 goto err;
605 } 725 }
606 726
607 f=CONF_get_string(conf,BASE_SECTION,ENV_PRESERVE); 727 f=NCONF_get_string(conf,BASE_SECTION,ENV_PRESERVE);
728 if (f == NULL)
729 ERR_clear_error();
608 if ((f != NULL) && ((*f == 'y') || (*f == 'Y'))) 730 if ((f != NULL) && ((*f == 'y') || (*f == 'Y')))
609 preserve=1; 731 preserve=1;
610 f=CONF_get_string(conf,BASE_SECTION,ENV_MSIE_HACK); 732 f=NCONF_get_string(conf,BASE_SECTION,ENV_MSIE_HACK);
733 if (f == NULL)
734 ERR_clear_error();
611 if ((f != NULL) && ((*f == 'y') || (*f == 'Y'))) 735 if ((f != NULL) && ((*f == 'y') || (*f == 'Y')))
612 msie_hack=1; 736 msie_hack=1;
613 737
738 f=NCONF_get_string(conf,section,ENV_NAMEOPT);
739
740 if (f)
741 {
742 if (!set_name_ex(&nameopt, f))
743 {
744 BIO_printf(bio_err, "Invalid name options: \"%s\"\n", f);
745 goto err;
746 }
747 default_op = 0;
748 }
749 else
750 ERR_clear_error();
751
752 f=NCONF_get_string(conf,section,ENV_CERTOPT);
753
754 if (f)
755 {
756 if (!set_cert_ex(&certopt, f))
757 {
758 BIO_printf(bio_err, "Invalid certificate options: \"%s\"\n", f);
759 goto err;
760 }
761 default_op = 0;
762 }
763 else
764 ERR_clear_error();
765
766 f=NCONF_get_string(conf,section,ENV_EXTCOPY);
767
768 if (f)
769 {
770 if (!set_ext_copy(&ext_copy, f))
771 {
772 BIO_printf(bio_err, "Invalid extension copy option: \"%s\"\n", f);
773 goto err;
774 }
775 }
776 else
777 ERR_clear_error();
778
614 /*****************************************************************/ 779 /*****************************************************************/
615 /* lookup where to write new certificates */ 780 /* lookup where to write new certificates */
616 if ((outdir == NULL) && (req)) 781 if ((outdir == NULL) && (req))
617 { 782 {
618 struct stat sb; 783 struct stat sb;
619 784
620 if ((outdir=CONF_get_string(conf,section,ENV_NEW_CERTS_DIR)) 785 if ((outdir=NCONF_get_string(conf,section,ENV_NEW_CERTS_DIR))
621 == NULL) 786 == NULL)
622 { 787 {
623 BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n"); 788 BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n");
624 goto err; 789 goto err;
625 } 790 }
626#ifndef VMS /* outdir is a directory spec, but access() for VMS demands a 791#ifndef OPENSSL_SYS_VMS
792 /* outdir is a directory spec, but access() for VMS demands a
627 filename. In any case, stat(), below, will catch the problem 793 filename. In any case, stat(), below, will catch the problem
628 if outdir is not a directory spec, and the fopen() or open() 794 if outdir is not a directory spec, and the fopen() or open()
629 will catch an error if there is no write access. 795 will catch an error if there is no write access.
@@ -632,7 +798,7 @@ bad:
632 C routines to convert the directory syntax to Unixly, and give 798 C routines to convert the directory syntax to Unixly, and give
633 that to access(). However, time's too short to do that just 799 that to access(). However, time's too short to do that just
634 now. 800 now.
635 */ 801 */
636 if (access(outdir,R_OK|W_OK|X_OK) != 0) 802 if (access(outdir,R_OK|W_OK|X_OK) != 0)
637 { 803 {
638 BIO_printf(bio_err,"I am unable to access the %s directory\n",outdir); 804 BIO_printf(bio_err,"I am unable to access the %s directory\n",outdir);
@@ -659,7 +825,7 @@ bad:
659 825
660 /*****************************************************************/ 826 /*****************************************************************/
661 /* we need to load the database file */ 827 /* we need to load the database file */
662 if ((dbfile=CONF_get_string(conf,section,ENV_DATABASE)) == NULL) 828 if ((dbfile=NCONF_get_string(conf,section,ENV_DATABASE)) == NULL)
663 { 829 {
664 lookup_fail(section,ENV_DATABASE); 830 lookup_fail(section,ENV_DATABASE);
665 goto err; 831 goto err;
@@ -684,10 +850,9 @@ bad:
684 goto err; 850 goto err;
685 } 851 }
686 if ((pp[DB_type][0] == DB_TYPE_REV) && 852 if ((pp[DB_type][0] == DB_TYPE_REV) &&
687 !check_time_format(pp[DB_rev_date])) 853 !make_revoked(NULL, pp[DB_rev_date]))
688 { 854 {
689 BIO_printf(bio_err,"entry %d: invalid revocation date\n", 855 BIO_printf(bio_err," in entry %d\n", i+1);
690 i+1);
691 goto err; 856 goto err;
692 } 857 }
693 if (!check_time_format(pp[DB_exp_date])) 858 if (!check_time_format(pp[DB_exp_date]))
@@ -697,6 +862,11 @@ bad:
697 } 862 }
698 p=pp[DB_serial]; 863 p=pp[DB_serial];
699 j=strlen(p); 864 j=strlen(p);
865 if (*p == '-')
866 {
867 p++;
868 j--;
869 }
700 if ((j&1) || (j < 2)) 870 if ((j&1) || (j < 2))
701 { 871 {
702 BIO_printf(bio_err,"entry %d: bad serial number length (%d)\n",i+1,j); 872 BIO_printf(bio_err,"entry %d: bad serial number length (%d)\n",i+1,j);
@@ -717,7 +887,7 @@ bad:
717 if (verbose) 887 if (verbose)
718 { 888 {
719 BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT); /* cannot fail */ 889 BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT); /* cannot fail */
720#ifdef VMS 890#ifdef OPENSSL_SYS_VMS
721 { 891 {
722 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 892 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
723 out = BIO_push(tmpbio, out); 893 out = BIO_push(tmpbio, out);
@@ -729,15 +899,12 @@ bad:
729 BIO_printf(bio_err,"generating index\n"); 899 BIO_printf(bio_err,"generating index\n");
730 } 900 }
731 901
732 if (!TXT_DB_create_index(db,DB_serial,NULL,index_serial_hash, 902 if (!make_serial_index(db))
733 index_serial_cmp))
734 {
735 BIO_printf(bio_err,"error creating serial number index:(%ld,%ld,%ld)\n",db->error,db->arg1,db->arg2);
736 goto err; 903 goto err;
737 }
738 904
739 if (!TXT_DB_create_index(db,DB_name,index_name_qual,index_name_hash, 905 if (!TXT_DB_create_index(db, DB_name, index_name_qual,
740 index_name_cmp)) 906 LHASH_HASH_FN(index_name_hash),
907 LHASH_COMP_FN(index_name_cmp)))
741 { 908 {
742 BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n", 909 BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
743 db->error,db->arg1,db->arg2); 910 db->error,db->arg1,db->arg2);
@@ -745,11 +912,119 @@ bad:
745 } 912 }
746 913
747 /*****************************************************************/ 914 /*****************************************************************/
915 /* Update the db file for expired certificates */
916 if (doupdatedb)
917 {
918 if (verbose)
919 BIO_printf(bio_err, "Updating %s ...\n",
920 dbfile);
921
922 i = do_updatedb(db);
923 if (i == -1)
924 {
925 BIO_printf(bio_err,"Malloc failure\n");
926 goto err;
927 }
928 else if (i == 0)
929 {
930 if (verbose) BIO_printf(bio_err,
931 "No entries found to mark expired\n");
932 }
933 else
934 {
935 out = BIO_new(BIO_s_file());
936 if (out == NULL)
937 {
938 ERR_print_errors(bio_err);
939 goto err;
940 }
941
942#ifndef OPENSSL_SYS_VMS
943 j = BIO_snprintf(buf[0], sizeof buf[0], "%s.new", dbfile);
944#else
945 j = BIO_snprintf(buf[0], sizeof buf[0], "%s-new", dbfile);
946#endif
947 if (j < 0 || j >= sizeof buf[0])
948 {
949 BIO_printf(bio_err, "file name too long\n");
950 goto err;
951 }
952 if (BIO_write_filename(out,buf[0]) <= 0)
953 {
954 perror(dbfile);
955 BIO_printf(bio_err,"unable to open '%s'\n",
956 dbfile);
957 goto err;
958 }
959 j=TXT_DB_write(out,db);
960 if (j <= 0) goto err;
961
962 BIO_free(out);
963 out = NULL;
964#ifndef OPENSSL_SYS_VMS
965 j = BIO_snprintf(buf[1], sizeof buf[1], "%s.old", dbfile);
966#else
967 j = BIO_snprintf(buf[1], sizeof buf[1], "%s-old", dbfile);
968#endif
969 if (j < 0 || j >= sizeof buf[1])
970 {
971 BIO_printf(bio_err, "file name too long\n");
972 goto err;
973 }
974 if (rename(dbfile,buf[1]) < 0)
975 {
976 BIO_printf(bio_err,
977 "unable to rename %s to %s\n",
978 dbfile, buf[1]);
979 perror("reason");
980 goto err;
981 }
982 if (rename(buf[0],dbfile) < 0)
983 {
984 BIO_printf(bio_err,
985 "unable to rename %s to %s\n",
986 buf[0],dbfile);
987 perror("reason");
988 rename(buf[1],dbfile);
989 goto err;
990 }
991
992 if (verbose) BIO_printf(bio_err,
993 "Done. %d entries marked as expired\n",i);
994 }
995 goto err;
996 }
997
998 /*****************************************************************/
999 /* Read extentions config file */
1000 if (extfile)
1001 {
1002 extconf = NCONF_new(NULL);
1003 if (NCONF_load(extconf,extfile,&errorline) <= 0)
1004 {
1005 if (errorline <= 0)
1006 BIO_printf(bio_err, "ERROR: loading the config file '%s'\n",
1007 extfile);
1008 else
1009 BIO_printf(bio_err, "ERROR: on line %ld of config file '%s'\n",
1010 errorline,extfile);
1011 ret = 1;
1012 goto err;
1013 }
1014
1015 if (verbose)
1016 BIO_printf(bio_err, "Succesfully loaded extensions file %s\n", extfile);
1017
1018 /* We can have sections in the ext file */
1019 if (!extensions && !(extensions = NCONF_get_string(extconf, "default", "extensions")))
1020 extensions = "default";
1021 }
1022
1023 /*****************************************************************/
748 if (req || gencrl) 1024 if (req || gencrl)
749 { 1025 {
750 if (outfile != NULL) 1026 if (outfile != NULL)
751 { 1027 {
752
753 if (BIO_write_filename(Sout,outfile) <= 0) 1028 if (BIO_write_filename(Sout,outfile) <= 0)
754 { 1029 {
755 perror(outfile); 1030 perror(outfile);
@@ -759,7 +1034,7 @@ bad:
759 else 1034 else
760 { 1035 {
761 BIO_set_fp(Sout,stdout,BIO_NOCLOSE|BIO_FP_TEXT); 1036 BIO_set_fp(Sout,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
762#ifdef VMS 1037#ifdef OPENSSL_SYS_VMS
763 { 1038 {
764 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 1039 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
765 Sout = BIO_push(tmpbio, Sout); 1040 Sout = BIO_push(tmpbio, Sout);
@@ -770,12 +1045,18 @@ bad:
770 1045
771 if (req) 1046 if (req)
772 { 1047 {
773 if ((md == NULL) && ((md=CONF_get_string(conf, 1048 if ((md == NULL) && ((md=NCONF_get_string(conf,
774 section,ENV_DEFAULT_MD)) == NULL)) 1049 section,ENV_DEFAULT_MD)) == NULL))
775 { 1050 {
776 lookup_fail(section,ENV_DEFAULT_MD); 1051 lookup_fail(section,ENV_DEFAULT_MD);
777 goto err; 1052 goto err;
778 } 1053 }
1054 if ((email_dn == 1) && ((tmp_email_dn=NCONF_get_string(conf,
1055 section,ENV_DEFAULT_EMAIL_DN)) != NULL ))
1056 {
1057 if(strcmp(tmp_email_dn,"no") == 0)
1058 email_dn=0;
1059 }
779 if ((dgst=EVP_get_digestbyname(md)) == NULL) 1060 if ((dgst=EVP_get_digestbyname(md)) == NULL)
780 { 1061 {
781 BIO_printf(bio_err,"%s is an unsupported message digest type\n",md); 1062 BIO_printf(bio_err,"%s is an unsupported message digest type\n",md);
@@ -784,7 +1065,7 @@ bad:
784 if (verbose) 1065 if (verbose)
785 BIO_printf(bio_err,"message digest is %s\n", 1066 BIO_printf(bio_err,"message digest is %s\n",
786 OBJ_nid2ln(dgst->type)); 1067 OBJ_nid2ln(dgst->type));
787 if ((policy == NULL) && ((policy=CONF_get_string(conf, 1068 if ((policy == NULL) && ((policy=NCONF_get_string(conf,
788 section,ENV_POLICY)) == NULL)) 1069 section,ENV_POLICY)) == NULL))
789 { 1070 {
790 lookup_fail(section,ENV_POLICY); 1071 lookup_fail(section,ENV_POLICY);
@@ -793,32 +1074,48 @@ bad:
793 if (verbose) 1074 if (verbose)
794 BIO_printf(bio_err,"policy is %s\n",policy); 1075 BIO_printf(bio_err,"policy is %s\n",policy);
795 1076
796 if ((serialfile=CONF_get_string(conf,section,ENV_SERIAL)) 1077 if ((serialfile=NCONF_get_string(conf,section,ENV_SERIAL))
797 == NULL) 1078 == NULL)
798 { 1079 {
799 lookup_fail(section,ENV_SERIAL); 1080 lookup_fail(section,ENV_SERIAL);
800 goto err; 1081 goto err;
801 } 1082 }
802 if(!extensions) 1083
803 extensions=CONF_get_string(conf,section,ENV_EXTENSIONS); 1084 if (!extconf)
804 if(extensions) { 1085 {
805 /* Check syntax of file */ 1086 /* no '-extfile' option, so we look for extensions
806 X509V3_CTX ctx; 1087 * in the main configuration file */
807 X509V3_set_ctx_test(&ctx); 1088 if (!extensions)
808 X509V3_set_conf_lhash(&ctx, conf); 1089 {
809 if(!X509V3_EXT_add_conf(conf, &ctx, extensions, NULL)) { 1090 extensions=NCONF_get_string(conf,section,
810 BIO_printf(bio_err, 1091 ENV_EXTENSIONS);
811 "Error Loading extension section %s\n", 1092 if (!extensions)
1093 ERR_clear_error();
1094 }
1095 if (extensions)
1096 {
1097 /* Check syntax of file */
1098 X509V3_CTX ctx;
1099 X509V3_set_ctx_test(&ctx);
1100 X509V3_set_nconf(&ctx, conf);
1101 if (!X509V3_EXT_add_nconf(conf, &ctx, extensions,
1102 NULL))
1103 {
1104 BIO_printf(bio_err,
1105 "Error Loading extension section %s\n",
812 extensions); 1106 extensions);
813 ret = 1; 1107 ret = 1;
814 goto err; 1108 goto err;
1109 }
1110 }
815 } 1111 }
816 }
817 1112
818 if (startdate == NULL) 1113 if (startdate == NULL)
819 { 1114 {
820 startdate=CONF_get_string(conf,section, 1115 startdate=NCONF_get_string(conf,section,
821 ENV_DEFAULT_STARTDATE); 1116 ENV_DEFAULT_STARTDATE);
1117 if (startdate == NULL)
1118 ERR_clear_error();
822 } 1119 }
823 if (startdate && !ASN1_UTCTIME_set_string(NULL,startdate)) 1120 if (startdate && !ASN1_UTCTIME_set_string(NULL,startdate))
824 { 1121 {
@@ -829,8 +1126,10 @@ bad:
829 1126
830 if (enddate == NULL) 1127 if (enddate == NULL)
831 { 1128 {
832 enddate=CONF_get_string(conf,section, 1129 enddate=NCONF_get_string(conf,section,
833 ENV_DEFAULT_ENDDATE); 1130 ENV_DEFAULT_ENDDATE);
1131 if (enddate == NULL)
1132 ERR_clear_error();
834 } 1133 }
835 if (enddate && !ASN1_UTCTIME_set_string(NULL,enddate)) 1134 if (enddate && !ASN1_UTCTIME_set_string(NULL,enddate))
836 { 1135 {
@@ -840,8 +1139,8 @@ bad:
840 1139
841 if (days == 0) 1140 if (days == 0)
842 { 1141 {
843 days=(int)CONF_get_number(conf,section, 1142 if(!NCONF_get_number(conf,section, ENV_DEFAULT_DAYS, &days))
844 ENV_DEFAULT_DAYS); 1143 days = 0;
845 } 1144 }
846 if (!enddate && (days == 0)) 1145 if (!enddate && (days == 0))
847 { 1146 {
@@ -861,7 +1160,7 @@ bad:
861 OPENSSL_free(f); 1160 OPENSSL_free(f);
862 } 1161 }
863 1162
864 if ((attribs=CONF_get_section(conf,policy)) == NULL) 1163 if ((attribs=NCONF_get_section(conf,policy)) == NULL)
865 { 1164 {
866 BIO_printf(bio_err,"unable to find 'section' for %s\n",policy); 1165 BIO_printf(bio_err,"unable to find 'section' for %s\n",policy);
867 goto err; 1166 goto err;
@@ -876,8 +1175,8 @@ bad:
876 { 1175 {
877 total++; 1176 total++;
878 j=certify_spkac(&x,spkac_file,pkey,x509,dgst,attribs,db, 1177 j=certify_spkac(&x,spkac_file,pkey,x509,dgst,attribs,db,
879 serial,startdate,enddate, days,extensions,conf, 1178 serial,subj,email_dn,startdate,enddate,days,extensions,
880 verbose); 1179 conf,verbose,certopt,nameopt,default_op,ext_copy);
881 if (j < 0) goto err; 1180 if (j < 0) goto err;
882 if (j > 0) 1181 if (j > 0)
883 { 1182 {
@@ -900,8 +1199,9 @@ bad:
900 { 1199 {
901 total++; 1200 total++;
902 j=certify_cert(&x,ss_cert_file,pkey,x509,dgst,attribs, 1201 j=certify_cert(&x,ss_cert_file,pkey,x509,dgst,attribs,
903 db,serial,startdate,enddate,days,batch, 1202 db,serial,subj,email_dn,startdate,enddate,days,batch,
904 extensions,conf,verbose); 1203 extensions,conf,verbose, certopt, nameopt,
1204 default_op, ext_copy, e);
905 if (j < 0) goto err; 1205 if (j < 0) goto err;
906 if (j > 0) 1206 if (j > 0)
907 { 1207 {
@@ -919,8 +1219,9 @@ bad:
919 { 1219 {
920 total++; 1220 total++;
921 j=certify(&x,infile,pkey,x509,dgst,attribs,db, 1221 j=certify(&x,infile,pkey,x509,dgst,attribs,db,
922 serial,startdate,enddate,days,batch, 1222 serial,subj,email_dn,startdate,enddate,days,batch,
923 extensions,conf,verbose); 1223 extensions,conf,verbose, certopt, nameopt,
1224 default_op, ext_copy);
924 if (j < 0) goto err; 1225 if (j < 0) goto err;
925 if (j > 0) 1226 if (j > 0)
926 { 1227 {
@@ -938,8 +1239,9 @@ bad:
938 { 1239 {
939 total++; 1240 total++;
940 j=certify(&x,argv[i],pkey,x509,dgst,attribs,db, 1241 j=certify(&x,argv[i],pkey,x509,dgst,attribs,db,
941 serial,startdate,enddate,days,batch, 1242 serial,subj,email_dn,startdate,enddate,days,batch,
942 extensions,conf,verbose); 1243 extensions,conf,verbose, certopt, nameopt,
1244 default_op, ext_copy);
943 if (j < 0) goto err; 1245 if (j < 0) goto err;
944 if (j > 0) 1246 if (j > 0)
945 { 1247 {
@@ -976,8 +1278,9 @@ bad:
976 BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk)); 1278 BIO_printf(bio_err,"Write out database with %d new entries\n",sk_X509_num(cert_sk));
977 1279
978 strncpy(buf[0],serialfile,BSIZE-4); 1280 strncpy(buf[0],serialfile,BSIZE-4);
1281 buf[0][BSIZE-4]='\0';
979 1282
980#ifdef VMS 1283#ifdef OPENSSL_SYS_VMS
981 strcat(buf[0],"-new"); 1284 strcat(buf[0],"-new");
982#else 1285#else
983 strcat(buf[0],".new"); 1286 strcat(buf[0],".new");
@@ -986,8 +1289,9 @@ bad:
986 if (!save_serial(buf[0],serial)) goto err; 1289 if (!save_serial(buf[0],serial)) goto err;
987 1290
988 strncpy(buf[1],dbfile,BSIZE-4); 1291 strncpy(buf[1],dbfile,BSIZE-4);
1292 buf[1][BSIZE-4]='\0';
989 1293
990#ifdef VMS 1294#ifdef OPENSSL_SYS_VMS
991 strcat(buf[1],"-new"); 1295 strcat(buf[1],"-new");
992#else 1296#else
993 strcat(buf[1],".new"); 1297 strcat(buf[1],".new");
@@ -1016,8 +1320,9 @@ bad:
1016 p=(char *)x->cert_info->serialNumber->data; 1320 p=(char *)x->cert_info->serialNumber->data;
1017 1321
1018 strncpy(buf[2],outdir,BSIZE-(j*2)-6); 1322 strncpy(buf[2],outdir,BSIZE-(j*2)-6);
1323 buf[2][BSIZE-(j*2)-6]='\0';
1019 1324
1020#ifndef VMS 1325#ifndef OPENSSL_SYS_VMS
1021 strcat(buf[2],"/"); 1326 strcat(buf[2],"/");
1022#endif 1327#endif
1023 1328
@@ -1053,8 +1358,9 @@ bad:
1053 { 1358 {
1054 /* Rename the database and the serial file */ 1359 /* Rename the database and the serial file */
1055 strncpy(buf[2],serialfile,BSIZE-4); 1360 strncpy(buf[2],serialfile,BSIZE-4);
1361 buf[2][BSIZE-4]='\0';
1056 1362
1057#ifdef VMS 1363#ifdef OPENSSL_SYS_VMS
1058 strcat(buf[2],"-old"); 1364 strcat(buf[2],"-old");
1059#else 1365#else
1060 strcat(buf[2],".old"); 1366 strcat(buf[2],".old");
@@ -1081,8 +1387,9 @@ bad:
1081 } 1387 }
1082 1388
1083 strncpy(buf[2],dbfile,BSIZE-4); 1389 strncpy(buf[2],dbfile,BSIZE-4);
1390 buf[2][BSIZE-4]='\0';
1084 1391
1085#ifdef VMS 1392#ifdef OPENSSL_SYS_VMS
1086 strcat(buf[2],"-old"); 1393 strcat(buf[2],"-old");
1087#else 1394#else
1088 strcat(buf[2],".old"); 1395 strcat(buf[2],".old");
@@ -1110,28 +1417,37 @@ bad:
1110 /*****************************************************************/ 1417 /*****************************************************************/
1111 if (gencrl) 1418 if (gencrl)
1112 { 1419 {
1113 if(!crl_ext) crl_ext=CONF_get_string(conf,section,ENV_CRLEXT); 1420 int crl_v2 = 0;
1114 if(crl_ext) { 1421 if (!crl_ext)
1422 {
1423 crl_ext=NCONF_get_string(conf,section,ENV_CRLEXT);
1424 if (!crl_ext)
1425 ERR_clear_error();
1426 }
1427 if (crl_ext)
1428 {
1115 /* Check syntax of file */ 1429 /* Check syntax of file */
1116 X509V3_CTX ctx; 1430 X509V3_CTX ctx;
1117 X509V3_set_ctx_test(&ctx); 1431 X509V3_set_ctx_test(&ctx);
1118 X509V3_set_conf_lhash(&ctx, conf); 1432 X509V3_set_nconf(&ctx, conf);
1119 if(!X509V3_EXT_add_conf(conf, &ctx, crl_ext, NULL)) { 1433 if (!X509V3_EXT_add_nconf(conf, &ctx, crl_ext, NULL))
1434 {
1120 BIO_printf(bio_err, 1435 BIO_printf(bio_err,
1121 "Error Loading CRL extension section %s\n", 1436 "Error Loading CRL extension section %s\n",
1122 crl_ext); 1437 crl_ext);
1123 ret = 1; 1438 ret = 1;
1124 goto err; 1439 goto err;
1440 }
1125 } 1441 }
1126 }
1127 if ((hex=BIO_new(BIO_s_mem())) == NULL) goto err;
1128 1442
1129 if (!crldays && !crlhours) 1443 if (!crldays && !crlhours)
1130 { 1444 {
1131 crldays=CONF_get_number(conf,section, 1445 if (!NCONF_get_number(conf,section,
1132 ENV_DEFAULT_CRL_DAYS); 1446 ENV_DEFAULT_CRL_DAYS, &crldays))
1133 crlhours=CONF_get_number(conf,section, 1447 crldays = 0;
1134 ENV_DEFAULT_CRL_HOURS); 1448 if (!NCONF_get_number(conf,section,
1449 ENV_DEFAULT_CRL_HOURS, &crlhours))
1450 crlhours = 0;
1135 } 1451 }
1136 if ((crldays == 0) && (crlhours == 0)) 1452 if ((crldays == 0) && (crlhours == 0))
1137 { 1453 {
@@ -1141,15 +1457,16 @@ bad:
1141 1457
1142 if (verbose) BIO_printf(bio_err,"making CRL\n"); 1458 if (verbose) BIO_printf(bio_err,"making CRL\n");
1143 if ((crl=X509_CRL_new()) == NULL) goto err; 1459 if ((crl=X509_CRL_new()) == NULL) goto err;
1144 ci=crl->crl; 1460 if (!X509_CRL_set_issuer_name(crl, X509_get_issuer_name(x509))) goto err;
1145 X509_NAME_free(ci->issuer);
1146 ci->issuer=X509_NAME_dup(x509->cert_info->subject);
1147 if (ci->issuer == NULL) goto err;
1148 1461
1149 X509_gmtime_adj(ci->lastUpdate,0); 1462 tmptm = ASN1_TIME_new();
1150 if (ci->nextUpdate == NULL) 1463 if (!tmptm) goto err;
1151 ci->nextUpdate=ASN1_UTCTIME_new(); 1464 X509_gmtime_adj(tmptm,0);
1152 X509_gmtime_adj(ci->nextUpdate,(crldays*24+crlhours)*60*60); 1465 X509_CRL_set_lastUpdate(crl, tmptm);
1466 X509_gmtime_adj(tmptm,(crldays*24+crlhours)*60*60);
1467 X509_CRL_set_nextUpdate(crl, tmptm);
1468
1469 ASN1_TIME_free(tmptm);
1153 1470
1154 for (i=0; i<sk_num(db->data); i++) 1471 for (i=0; i<sk_num(db->data); i++)
1155 { 1472 {
@@ -1157,29 +1474,25 @@ bad:
1157 if (pp[DB_type][0] == DB_TYPE_REV) 1474 if (pp[DB_type][0] == DB_TYPE_REV)
1158 { 1475 {
1159 if ((r=X509_REVOKED_new()) == NULL) goto err; 1476 if ((r=X509_REVOKED_new()) == NULL) goto err;
1160 ASN1_STRING_set((ASN1_STRING *) 1477 j = make_revoked(r, pp[DB_rev_date]);
1161 r->revocationDate, 1478 if (!j) goto err;
1162 (unsigned char *)pp[DB_rev_date], 1479 if (j == 2) crl_v2 = 1;
1163 strlen(pp[DB_rev_date])); 1480 if (!BN_hex2bn(&serial, pp[DB_serial]))
1164 /* strcpy(r->revocationDate,pp[DB_rev_date]);*/
1165
1166 (void)BIO_reset(hex);
1167 if (!BIO_puts(hex,pp[DB_serial]))
1168 goto err; 1481 goto err;
1169 if (!a2i_ASN1_INTEGER(hex,r->serialNumber, 1482 tmpser = BN_to_ASN1_INTEGER(serial, NULL);
1170 buf[0],BSIZE)) goto err; 1483 BN_free(serial);
1171 1484 serial = NULL;
1172 sk_X509_REVOKED_push(ci->revoked,r); 1485 if (!tmpser)
1486 goto err;
1487 X509_REVOKED_set_serialNumber(r, tmpser);
1488 ASN1_INTEGER_free(tmpser);
1489 X509_CRL_add0_revoked(crl,r);
1173 } 1490 }
1174 } 1491 }
1492
1175 /* sort the data so it will be written in serial 1493 /* sort the data so it will be written in serial
1176 * number order */ 1494 * number order */
1177 sk_X509_REVOKED_sort(ci->revoked); 1495 X509_CRL_sort(crl);
1178 for (i=0; i<sk_X509_REVOKED_num(ci->revoked); i++)
1179 {
1180 r=sk_X509_REVOKED_value(ci->revoked,i);
1181 r->sequence=i;
1182 }
1183 1496
1184 /* we now have a CRL */ 1497 /* we now have a CRL */
1185 if (verbose) BIO_printf(bio_err,"signing CRL\n"); 1498 if (verbose) BIO_printf(bio_err,"signing CRL\n");
@@ -1192,28 +1505,31 @@ bad:
1192 } 1505 }
1193 } 1506 }
1194 else 1507 else
1195 { 1508 {
1196#ifndef NO_DSA 1509#ifndef OPENSSL_NO_DSA
1197 if (pkey->type == EVP_PKEY_DSA) 1510 if (pkey->type == EVP_PKEY_DSA)
1198 dgst=EVP_dss1(); 1511 dgst=EVP_dss1();
1199 else 1512 else
1200#endif 1513#endif
1201 dgst=EVP_md5(); 1514 dgst=EVP_md5();
1202 } 1515 }
1203 1516
1204 /* Add any extensions asked for */ 1517 /* Add any extensions asked for */
1205 1518
1206 if(crl_ext) { 1519 if (crl_ext)
1207 X509V3_CTX crlctx; 1520 {
1208 if (ci->version == NULL) 1521 X509V3_CTX crlctx;
1209 if ((ci->version=ASN1_INTEGER_new()) == NULL) goto err; 1522 X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0);
1210 ASN1_INTEGER_set(ci->version,1); /* version 2 CRL */ 1523 X509V3_set_nconf(&crlctx, conf);
1211 X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0);
1212 X509V3_set_conf_lhash(&crlctx, conf);
1213 1524
1214 if(!X509V3_EXT_CRL_add_conf(conf, &crlctx, 1525 if (!X509V3_EXT_CRL_add_nconf(conf, &crlctx,
1215 crl_ext, crl)) goto err; 1526 crl_ext, crl)) goto err;
1216 } 1527 }
1528 if (crl_ext || crl_v2)
1529 {
1530 if (!X509_CRL_set_version(crl, 1))
1531 goto err; /* version 2 CRL */
1532 }
1217 1533
1218 if (!X509_CRL_sign(crl,pkey,dgst)) goto err; 1534 if (!X509_CRL_sign(crl,pkey,dgst)) goto err;
1219 1535
@@ -1230,24 +1546,17 @@ bad:
1230 else 1546 else
1231 { 1547 {
1232 X509 *revcert; 1548 X509 *revcert;
1233 if (BIO_read_filename(in,infile) <= 0) 1549 revcert=load_cert(bio_err, infile, FORMAT_PEM,
1234 { 1550 NULL, e, infile);
1235 perror(infile);
1236 BIO_printf(bio_err,"error trying to load '%s' certificate\n",infile);
1237 goto err;
1238 }
1239 revcert=PEM_read_bio_X509(in,NULL,NULL,NULL);
1240 if (revcert == NULL) 1551 if (revcert == NULL)
1241 {
1242 BIO_printf(bio_err,"unable to load '%s' certificate\n",infile);
1243 goto err; 1552 goto err;
1244 } 1553 j=do_revoke(revcert,db, rev_type, rev_arg);
1245 j=do_revoke(revcert,db);
1246 if (j <= 0) goto err; 1554 if (j <= 0) goto err;
1247 X509_free(revcert); 1555 X509_free(revcert);
1248 1556
1249 strncpy(buf[0],dbfile,BSIZE-4); 1557 strncpy(buf[0],dbfile,BSIZE-4);
1250#ifndef VMS 1558 buf[0][BSIZE-4]='\0';
1559#ifndef OPENSSL_SYS_VMS
1251 strcat(buf[0],".new"); 1560 strcat(buf[0],".new");
1252#else 1561#else
1253 strcat(buf[0],"-new"); 1562 strcat(buf[0],"-new");
@@ -1260,8 +1569,13 @@ bad:
1260 } 1569 }
1261 j=TXT_DB_write(out,db); 1570 j=TXT_DB_write(out,db);
1262 if (j <= 0) goto err; 1571 if (j <= 0) goto err;
1572 BIO_free_all(out);
1573 out = NULL;
1574 BIO_free_all(in);
1575 in = NULL;
1263 strncpy(buf[1],dbfile,BSIZE-4); 1576 strncpy(buf[1],dbfile,BSIZE-4);
1264#ifndef VMS 1577 buf[1][BSIZE-4]='\0';
1578#ifndef OPENSSL_SYS_VMS
1265 strcat(buf[1],".old"); 1579 strcat(buf[1],".old");
1266#else 1580#else
1267 strcat(buf[1],"-old"); 1581 strcat(buf[1],"-old");
@@ -1285,23 +1599,25 @@ bad:
1285 /*****************************************************************/ 1599 /*****************************************************************/
1286 ret=0; 1600 ret=0;
1287err: 1601err:
1288 BIO_free(hex);
1289 BIO_free_all(Cout); 1602 BIO_free_all(Cout);
1290 BIO_free_all(Sout); 1603 BIO_free_all(Sout);
1291 BIO_free_all(out); 1604 BIO_free_all(out);
1292 BIO_free(in); 1605 BIO_free_all(in);
1293 1606
1294 sk_X509_pop_free(cert_sk,X509_free); 1607 sk_X509_pop_free(cert_sk,X509_free);
1295 1608
1296 if (ret) ERR_print_errors(bio_err); 1609 if (ret) ERR_print_errors(bio_err);
1297 app_RAND_write_file(randfile, bio_err); 1610 app_RAND_write_file(randfile, bio_err);
1611 if (free_key)
1612 OPENSSL_free(key);
1298 BN_free(serial); 1613 BN_free(serial);
1299 TXT_DB_free(db); 1614 TXT_DB_free(db);
1300 EVP_PKEY_free(pkey); 1615 EVP_PKEY_free(pkey);
1301 X509_free(x509); 1616 X509_free(x509);
1302 X509_CRL_free(crl); 1617 X509_CRL_free(crl);
1303 CONF_free(conf); 1618 NCONF_free(conf);
1304 OBJ_cleanup(); 1619 OBJ_cleanup();
1620 apps_shutdown();
1305 EXIT(ret); 1621 EXIT(ret);
1306 } 1622 }
1307 1623
@@ -1310,31 +1626,31 @@ static void lookup_fail(char *name, char *tag)
1310 BIO_printf(bio_err,"variable lookup failed for %s::%s\n",name,tag); 1626 BIO_printf(bio_err,"variable lookup failed for %s::%s\n",name,tag);
1311 } 1627 }
1312 1628
1313static unsigned long index_serial_hash(char **a) 1629static unsigned long index_serial_hash(const char **a)
1314 { 1630 {
1315 char *n; 1631 const char *n;
1316 1632
1317 n=a[DB_serial]; 1633 n=a[DB_serial];
1318 while (*n == '0') n++; 1634 while (*n == '0') n++;
1319 return(lh_strhash(n)); 1635 return(lh_strhash(n));
1320 } 1636 }
1321 1637
1322static int index_serial_cmp(char **a, char **b) 1638static int index_serial_cmp(const char **a, const char **b)
1323 { 1639 {
1324 char *aa,*bb; 1640 const char *aa,*bb;
1325 1641
1326 for (aa=a[DB_serial]; *aa == '0'; aa++); 1642 for (aa=a[DB_serial]; *aa == '0'; aa++);
1327 for (bb=b[DB_serial]; *bb == '0'; bb++); 1643 for (bb=b[DB_serial]; *bb == '0'; bb++);
1328 return(strcmp(aa,bb)); 1644 return(strcmp(aa,bb));
1329 } 1645 }
1330 1646
1331static unsigned long index_name_hash(char **a) 1647static unsigned long index_name_hash(const char **a)
1332 { return(lh_strhash(a[DB_name])); } 1648 { return(lh_strhash(a[DB_name])); }
1333 1649
1334static int index_name_qual(char **a) 1650static int index_name_qual(char **a)
1335 { return(a[0][0] == 'V'); } 1651 { return(a[0][0] == 'V'); }
1336 1652
1337static int index_name_cmp(char **a, char **b) 1653static int index_name_cmp(const char **a, const char **b)
1338 { return(strcmp(a[DB_name], 1654 { return(strcmp(a[DB_name],
1339 b[DB_name])); } 1655 b[DB_name])); }
1340 1656
@@ -1410,8 +1726,10 @@ err:
1410 1726
1411static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509, 1727static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1412 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db, 1728 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
1413 BIGNUM *serial, char *startdate, char *enddate, int days, 1729 BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
1414 int batch, char *ext_sect, LHASH *lconf, int verbose) 1730 long days, int batch, char *ext_sect, CONF *lconf, int verbose,
1731 unsigned long certopt, unsigned long nameopt, int default_op,
1732 int ext_copy)
1415 { 1733 {
1416 X509_REQ *req=NULL; 1734 X509_REQ *req=NULL;
1417 BIO *in=NULL; 1735 BIO *in=NULL;
@@ -1458,8 +1776,9 @@ static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1458 else 1776 else
1459 BIO_printf(bio_err,"Signature ok\n"); 1777 BIO_printf(bio_err,"Signature ok\n");
1460 1778
1461 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate, enddate, 1779 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj, email_dn,
1462 days,batch,verbose,req,ext_sect,lconf); 1780 startdate,enddate,days,batch,verbose,req,ext_sect,lconf,
1781 certopt, nameopt, default_op, ext_copy);
1463 1782
1464err: 1783err:
1465 if (req != NULL) X509_REQ_free(req); 1784 if (req != NULL) X509_REQ_free(req);
@@ -1469,27 +1788,18 @@ err:
1469 1788
1470static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509, 1789static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1471 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db, 1790 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
1472 BIGNUM *serial, char *startdate, char *enddate, int days, 1791 BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
1473 int batch, char *ext_sect, LHASH *lconf, int verbose) 1792 long days, int batch, char *ext_sect, CONF *lconf, int verbose,
1793 unsigned long certopt, unsigned long nameopt, int default_op,
1794 int ext_copy, ENGINE *e)
1474 { 1795 {
1475 X509 *req=NULL; 1796 X509 *req=NULL;
1476 X509_REQ *rreq=NULL; 1797 X509_REQ *rreq=NULL;
1477 BIO *in=NULL;
1478 EVP_PKEY *pktmp=NULL; 1798 EVP_PKEY *pktmp=NULL;
1479 int ok= -1,i; 1799 int ok= -1,i;
1480 1800
1481 in=BIO_new(BIO_s_file()); 1801 if ((req=load_cert(bio_err, infile, FORMAT_PEM, NULL, e, infile)) == NULL)
1482
1483 if (BIO_read_filename(in,infile) <= 0)
1484 {
1485 perror(infile);
1486 goto err; 1802 goto err;
1487 }
1488 if ((req=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL)
1489 {
1490 BIO_printf(bio_err,"Error reading self signed certificate in %s\n",infile);
1491 goto err;
1492 }
1493 if (verbose) 1803 if (verbose)
1494 X509_print(bio_err,req); 1804 X509_print(bio_err,req);
1495 1805
@@ -1520,22 +1830,24 @@ static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1520 if ((rreq=X509_to_X509_REQ(req,NULL,EVP_md5())) == NULL) 1830 if ((rreq=X509_to_X509_REQ(req,NULL,EVP_md5())) == NULL)
1521 goto err; 1831 goto err;
1522 1832
1523 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,enddate,days, 1833 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj,email_dn,startdate,enddate,
1524 batch,verbose,rreq,ext_sect,lconf); 1834 days,batch,verbose,rreq,ext_sect,lconf, certopt, nameopt, default_op,
1835 ext_copy);
1525 1836
1526err: 1837err:
1527 if (rreq != NULL) X509_REQ_free(rreq); 1838 if (rreq != NULL) X509_REQ_free(rreq);
1528 if (req != NULL) X509_free(req); 1839 if (req != NULL) X509_free(req);
1529 if (in != NULL) BIO_free(in);
1530 return(ok); 1840 return(ok);
1531 } 1841 }
1532 1842
1533static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, 1843static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
1534 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial, 1844 STACK_OF(CONF_VALUE) *policy, TXT_DB *db, BIGNUM *serial, char *subj,
1535 char *startdate, char *enddate, int days, int batch, int verbose, 1845 int email_dn, char *startdate, char *enddate, long days, int batch,
1536 X509_REQ *req, char *ext_sect, LHASH *lconf) 1846 int verbose, X509_REQ *req, char *ext_sect, CONF *lconf,
1847 unsigned long certopt, unsigned long nameopt, int default_op,
1848 int ext_copy)
1537 { 1849 {
1538 X509_NAME *name=NULL,*CAname=NULL,*subject=NULL; 1850 X509_NAME *name=NULL,*CAname=NULL,*subject=NULL, *dn_subject=NULL;
1539 ASN1_UTCTIME *tm,*tmptm; 1851 ASN1_UTCTIME *tm,*tmptm;
1540 ASN1_STRING *str,*str2; 1852 ASN1_STRING *str,*str2;
1541 ASN1_OBJECT *obj; 1853 ASN1_OBJECT *obj;
@@ -1548,7 +1860,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
1548 char *p; 1860 char *p;
1549 CONF_VALUE *cv; 1861 CONF_VALUE *cv;
1550 char *row[DB_NUMBER],**rrow,**irow=NULL; 1862 char *row[DB_NUMBER],**rrow,**irow=NULL;
1551 char buf[25],*pbuf; 1863 char buf[25];
1552 1864
1553 tmptm=ASN1_UTCTIME_new(); 1865 tmptm=ASN1_UTCTIME_new();
1554 if (tmptm == NULL) 1866 if (tmptm == NULL)
@@ -1560,20 +1872,29 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
1560 for (i=0; i<DB_NUMBER; i++) 1872 for (i=0; i<DB_NUMBER; i++)
1561 row[i]=NULL; 1873 row[i]=NULL;
1562 1874
1563 BIO_printf(bio_err,"The Subjects Distinguished Name is as follows\n"); 1875 if (subj)
1876 {
1877 X509_NAME *n = do_subject(subj);
1878
1879 if (!n)
1880 {
1881 ERR_print_errors(bio_err);
1882 goto err;
1883 }
1884 X509_REQ_set_subject_name(req,n);
1885 req->req_info->enc.modified = 1;
1886 X509_NAME_free(n);
1887 }
1888
1889 if (default_op)
1890 BIO_printf(bio_err,"The Subject's Distinguished Name is as follows\n");
1891
1564 name=X509_REQ_get_subject_name(req); 1892 name=X509_REQ_get_subject_name(req);
1565 for (i=0; i<X509_NAME_entry_count(name); i++) 1893 for (i=0; i<X509_NAME_entry_count(name); i++)
1566 { 1894 {
1567 ne=(X509_NAME_ENTRY *)X509_NAME_get_entry(name,i); 1895 ne= X509_NAME_get_entry(name,i);
1568 obj=X509_NAME_ENTRY_get_object(ne);
1569 j=i2a_ASN1_OBJECT(bio_err,obj);
1570 str=X509_NAME_ENTRY_get_data(ne); 1896 str=X509_NAME_ENTRY_get_data(ne);
1571 pbuf=buf; 1897 obj=X509_NAME_ENTRY_get_object(ne);
1572 for (j=22-j; j>0; j--)
1573 *(pbuf++)=' ';
1574 *(pbuf++)=':';
1575 *(pbuf++)='\0';
1576 BIO_puts(bio_err,buf);
1577 1898
1578 if (msie_hack) 1899 if (msie_hack)
1579 { 1900 {
@@ -1592,16 +1913,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
1592 str->type=V_ASN1_IA5STRING; 1913 str->type=V_ASN1_IA5STRING;
1593 } 1914 }
1594 1915
1595 if (str->type == V_ASN1_PRINTABLESTRING) 1916 /* If no EMAIL is wanted in the subject */
1596 BIO_printf(bio_err,"PRINTABLE:'"); 1917 if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && (!email_dn))
1597 else if (str->type == V_ASN1_T61STRING) 1918 continue;
1598 BIO_printf(bio_err,"T61STRING:'");
1599 else if (str->type == V_ASN1_IA5STRING)
1600 BIO_printf(bio_err,"IA5STRING:'");
1601 else if (str->type == V_ASN1_UNIVERSALSTRING)
1602 BIO_printf(bio_err,"UNIVERSALSTRING:'");
1603 else
1604 BIO_printf(bio_err,"ASN.1 %2d:'",str->type);
1605 1919
1606 /* check some things */ 1920 /* check some things */
1607 if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && 1921 if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) &&
@@ -1610,29 +1924,21 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
1610 BIO_printf(bio_err,"\nemailAddress type needs to be of type IA5STRING\n"); 1924 BIO_printf(bio_err,"\nemailAddress type needs to be of type IA5STRING\n");
1611 goto err; 1925 goto err;
1612 } 1926 }
1613 j=ASN1_PRINTABLE_type(str->data,str->length); 1927 if ((str->type != V_ASN1_BMPSTRING) && (str->type != V_ASN1_UTF8STRING))
1614 if ( ((j == V_ASN1_T61STRING) &&
1615 (str->type != V_ASN1_T61STRING)) ||
1616 ((j == V_ASN1_IA5STRING) &&
1617 (str->type == V_ASN1_PRINTABLESTRING)))
1618 { 1928 {
1619 BIO_printf(bio_err,"\nThe string contains characters that are illegal for the ASN.1 type\n"); 1929 j=ASN1_PRINTABLE_type(str->data,str->length);
1620 goto err; 1930 if ( ((j == V_ASN1_T61STRING) &&
1621 } 1931 (str->type != V_ASN1_T61STRING)) ||
1622 1932 ((j == V_ASN1_IA5STRING) &&
1623 p=(char *)str->data; 1933 (str->type == V_ASN1_PRINTABLESTRING)))
1624 for (j=str->length; j>0; j--) 1934 {
1625 { 1935 BIO_printf(bio_err,"\nThe string contains characters that are illegal for the ASN.1 type\n");
1626 if ((*p >= ' ') && (*p <= '~')) 1936 goto err;
1627 BIO_printf(bio_err,"%c",*p); 1937 }
1628 else if (*p & 0x80)
1629 BIO_printf(bio_err,"\\0x%02X",*p);
1630 else if ((unsigned char)*p == 0xf7)
1631 BIO_printf(bio_err,"^?");
1632 else BIO_printf(bio_err,"^%c",*p+'@');
1633 p++;
1634 } 1938 }
1635 BIO_printf(bio_err,"'\n"); 1939
1940 if (default_op)
1941 old_entry_print(bio_err, obj, str);
1636 } 1942 }
1637 1943
1638 /* Ok, now we check the 'policy' stuff. */ 1944 /* Ok, now we check the 'policy' stuff. */
@@ -1747,14 +2053,40 @@ again2:
1747 if (preserve) 2053 if (preserve)
1748 { 2054 {
1749 X509_NAME_free(subject); 2055 X509_NAME_free(subject);
1750 subject=X509_NAME_dup(X509_REQ_get_subject_name(req)); 2056 /* subject=X509_NAME_dup(X509_REQ_get_subject_name(req)); */
2057 subject=X509_NAME_dup(name);
1751 if (subject == NULL) goto err; 2058 if (subject == NULL) goto err;
1752 } 2059 }
1753 2060
1754 if (verbose) 2061 if (verbose)
1755 BIO_printf(bio_err,"The subject name appears to be ok, checking data base for clashes\n"); 2062 BIO_printf(bio_err,"The subject name appears to be ok, checking data base for clashes\n");
1756 2063
1757 row[DB_name]=X509_NAME_oneline(subject,NULL,0); 2064 /* Build the correct Subject if no e-mail is wanted in the subject */
2065 /* and add it later on because of the method extensions are added (altName) */
2066
2067 if (email_dn)
2068 dn_subject = subject;
2069 else
2070 {
2071 X509_NAME_ENTRY *tmpne;
2072 /* Its best to dup the subject DN and then delete any email
2073 * addresses because this retains its structure.
2074 */
2075 if (!(dn_subject = X509_NAME_dup(subject)))
2076 {
2077 BIO_printf(bio_err,"Memory allocation failure\n");
2078 goto err;
2079 }
2080 while((i = X509_NAME_get_index_by_NID(dn_subject,
2081 NID_pkcs9_emailAddress, -1)) >= 0)
2082 {
2083 tmpne = X509_NAME_get_entry(dn_subject, i);
2084 X509_NAME_delete_entry(dn_subject, i);
2085 X509_NAME_ENTRY_free(tmpne);
2086 }
2087 }
2088
2089 row[DB_name]=X509_NAME_oneline(dn_subject,NULL,0);
1758 row[DB_serial]=BN_bn2hex(serial); 2090 row[DB_serial]=BN_bn2hex(serial);
1759 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) 2091 if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
1760 { 2092 {
@@ -1826,7 +2158,6 @@ again2:
1826 if (!X509_set_issuer_name(ret,X509_get_subject_name(x509))) 2158 if (!X509_set_issuer_name(ret,X509_get_subject_name(x509)))
1827 goto err; 2159 goto err;
1828 2160
1829 BIO_printf(bio_err,"Certificate is to be certified until ");
1830 if (strcmp(startdate,"today") == 0) 2161 if (strcmp(startdate,"today") == 0)
1831 X509_gmtime_adj(X509_get_notBefore(ret),0); 2162 X509_gmtime_adj(X509_get_notBefore(ret),0);
1832 else ASN1_UTCTIME_set_string(X509_get_notBefore(ret),startdate); 2163 else ASN1_UTCTIME_set_string(X509_get_notBefore(ret),startdate);
@@ -1835,10 +2166,6 @@ again2:
1835 X509_gmtime_adj(X509_get_notAfter(ret),(long)60*60*24*days); 2166 X509_gmtime_adj(X509_get_notAfter(ret),(long)60*60*24*days);
1836 else ASN1_UTCTIME_set_string(X509_get_notAfter(ret),enddate); 2167 else ASN1_UTCTIME_set_string(X509_get_notAfter(ret),enddate);
1837 2168
1838 ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ret));
1839 if(days) BIO_printf(bio_err," (%d days)",days);
1840 BIO_printf(bio_err, "\n");
1841
1842 if (!X509_set_subject_name(ret,subject)) goto err; 2169 if (!X509_set_subject_name(ret,subject)) goto err;
1843 2170
1844 pktmp=X509_REQ_get_pubkey(req); 2171 pktmp=X509_REQ_get_pubkey(req);
@@ -1863,16 +2190,80 @@ again2:
1863 2190
1864 ci->extensions = NULL; 2191 ci->extensions = NULL;
1865 2192
2193 /* Initialize the context structure */
1866 X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0); 2194 X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0);
1867 X509V3_set_conf_lhash(&ctx, lconf);
1868 2195
1869 if(!X509V3_EXT_add_conf(lconf, &ctx, ext_sect, ret)) goto err; 2196 if (extconf)
2197 {
2198 if (verbose)
2199 BIO_printf(bio_err, "Extra configuration file found\n");
2200
2201 /* Use the extconf configuration db LHASH */
2202 X509V3_set_nconf(&ctx, extconf);
2203
2204 /* Test the structure (needed?) */
2205 /* X509V3_set_ctx_test(&ctx); */
2206
2207 /* Adds exts contained in the configuration file */
2208 if (!X509V3_EXT_add_nconf(extconf, &ctx, ext_sect,ret))
2209 {
2210 BIO_printf(bio_err,
2211 "ERROR: adding extensions in section %s\n",
2212 ext_sect);
2213 ERR_print_errors(bio_err);
2214 goto err;
2215 }
2216 if (verbose)
2217 BIO_printf(bio_err, "Successfully added extensions from file.\n");
2218 }
2219 else if (ext_sect)
2220 {
2221 /* We found extensions to be set from config file */
2222 X509V3_set_nconf(&ctx, lconf);
2223
2224 if(!X509V3_EXT_add_nconf(lconf, &ctx, ext_sect, ret))
2225 {
2226 BIO_printf(bio_err, "ERROR: adding extensions in section %s\n", ext_sect);
2227 ERR_print_errors(bio_err);
2228 goto err;
2229 }
2230
2231 if (verbose)
2232 BIO_printf(bio_err, "Successfully added extensions from config\n");
2233 }
2234 }
2235
2236 /* Copy extensions from request (if any) */
2237
2238 if (!copy_extensions(ret, req, ext_copy))
2239 {
2240 BIO_printf(bio_err, "ERROR: adding extensions from request\n");
2241 ERR_print_errors(bio_err);
2242 goto err;
2243 }
2244
2245 /* Set the right value for the noemailDN option */
2246 if( email_dn == 0 )
2247 {
2248 if (!X509_set_subject_name(ret,dn_subject)) goto err;
2249 }
1870 2250
2251 if (!default_op)
2252 {
2253 BIO_printf(bio_err, "Certificate Details:\n");
2254 /* Never print signature details because signature not present */
2255 certopt |= X509_FLAG_NO_SIGDUMP | X509_FLAG_NO_SIGNAME;
2256 X509_print_ex(bio_err, ret, nameopt, certopt);
1871 } 2257 }
1872 2258
2259 BIO_printf(bio_err,"Certificate is to be certified until ");
2260 ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ret));
2261 if (days) BIO_printf(bio_err," (%d days)",days);
2262 BIO_printf(bio_err, "\n");
1873 2263
1874 if (!batch) 2264 if (!batch)
1875 { 2265 {
2266
1876 BIO_printf(bio_err,"Sign the certificate? [y/n]:"); 2267 BIO_printf(bio_err,"Sign the certificate? [y/n]:");
1877 (void)BIO_flush(bio_err); 2268 (void)BIO_flush(bio_err);
1878 buf[0]='\0'; 2269 buf[0]='\0';
@@ -1886,7 +2277,7 @@ again2:
1886 } 2277 }
1887 2278
1888 2279
1889#ifndef NO_DSA 2280#ifndef OPENSSL_NO_DSA
1890 if (pkey->type == EVP_PKEY_DSA) dgst=EVP_dss1(); 2281 if (pkey->type == EVP_PKEY_DSA) dgst=EVP_dss1();
1891 pktmp=X509_get_pubkey(ret); 2282 pktmp=X509_get_pubkey(ret);
1892 if (EVP_PKEY_missing_parameters(pktmp) && 2283 if (EVP_PKEY_missing_parameters(pktmp) &&
@@ -1950,6 +2341,8 @@ err:
1950 X509_NAME_free(CAname); 2341 X509_NAME_free(CAname);
1951 if (subject != NULL) 2342 if (subject != NULL)
1952 X509_NAME_free(subject); 2343 X509_NAME_free(subject);
2344 if ((dn_subject != NULL) && !email_dn)
2345 X509_NAME_free(dn_subject);
1953 if (tmptm != NULL) 2346 if (tmptm != NULL)
1954 ASN1_UTCTIME_free(tmptm); 2347 ASN1_UTCTIME_free(tmptm);
1955 if (ok <= 0) 2348 if (ok <= 0)
@@ -1982,14 +2375,15 @@ static void write_new_certificate(BIO *bp, X509 *x, int output_der, int notext)
1982 i2a_ASN1_INTEGER(bp,x->cert_info->serialNumber); 2375 i2a_ASN1_INTEGER(bp,x->cert_info->serialNumber);
1983 BIO_puts(bp,"\n\n"); 2376 BIO_puts(bp,"\n\n");
1984#endif 2377#endif
1985 if(!notext)X509_print(bp,x); 2378 if (!notext)X509_print(bp,x);
1986 PEM_write_bio_X509(bp,x); 2379 PEM_write_bio_X509(bp,x);
1987 } 2380 }
1988 2381
1989static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509, 2382static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
1990 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db, 2383 const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, TXT_DB *db,
1991 BIGNUM *serial, char *startdate, char *enddate, int days, 2384 BIGNUM *serial, char *subj, int email_dn, char *startdate, char *enddate,
1992 char *ext_sect, LHASH *lconf, int verbose) 2385 long days, char *ext_sect, CONF *lconf, int verbose, unsigned long certopt,
2386 unsigned long nameopt, int default_op, int ext_copy)
1993 { 2387 {
1994 STACK_OF(CONF_VALUE) *sk=NULL; 2388 STACK_OF(CONF_VALUE) *sk=NULL;
1995 LHASH *parms=NULL; 2389 LHASH *parms=NULL;
@@ -2055,12 +2449,13 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2055 /* Skip past any leading X. X: X, etc to allow for 2449 /* Skip past any leading X. X: X, etc to allow for
2056 * multiple instances 2450 * multiple instances
2057 */ 2451 */
2058 for(buf = cv->name; *buf ; buf++) 2452 for (buf = cv->name; *buf ; buf++)
2059 if ((*buf == ':') || (*buf == ',') || (*buf == '.')) { 2453 if ((*buf == ':') || (*buf == ',') || (*buf == '.'))
2060 buf++; 2454 {
2061 if(*buf) type = buf; 2455 buf++;
2062 break; 2456 if (*buf) type = buf;
2063 } 2457 break;
2458 }
2064 2459
2065 buf=cv->value; 2460 buf=cv->value;
2066 if ((nid=OBJ_txt2nid(type)) == NID_undef) 2461 if ((nid=OBJ_txt2nid(type)) == NID_undef)
@@ -2078,6 +2473,11 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2078 continue; 2473 continue;
2079 } 2474 }
2080 2475
2476 /*
2477 if ((nid == NID_pkcs9_emailAddress) && (email_dn == 0))
2478 continue;
2479 */
2480
2081 j=ASN1_PRINTABLE_type((unsigned char *)buf,-1); 2481 j=ASN1_PRINTABLE_type((unsigned char *)buf,-1);
2082 if (fix_data(nid, &j) == 0) 2482 if (fix_data(nid, &j) == 0)
2083 { 2483 {
@@ -2122,8 +2522,9 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
2122 2522
2123 X509_REQ_set_pubkey(req,pktmp); 2523 X509_REQ_set_pubkey(req,pktmp);
2124 EVP_PKEY_free(pktmp); 2524 EVP_PKEY_free(pktmp);
2125 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,enddate, 2525 ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj,email_dn,startdate,enddate,
2126 days,1,verbose,req,ext_sect,lconf); 2526 days,1,verbose,req,ext_sect,lconf, certopt, nameopt, default_op,
2527 ext_copy);
2127err: 2528err:
2128 if (req != NULL) X509_REQ_free(req); 2529 if (req != NULL) X509_REQ_free(req);
2129 if (parms != NULL) CONF_free(parms); 2530 if (parms != NULL) CONF_free(parms);
@@ -2158,10 +2559,11 @@ static int check_time_format(char *str)
2158 return(ASN1_UTCTIME_check(&tm)); 2559 return(ASN1_UTCTIME_check(&tm));
2159 } 2560 }
2160 2561
2161static int do_revoke(X509 *x509, TXT_DB *db) 2562static int do_revoke(X509 *x509, TXT_DB *db, int type, char *value)
2162{ 2563 {
2163 ASN1_UTCTIME *tm=NULL, *revtm=NULL; 2564 ASN1_UTCTIME *tm=NULL;
2164 char *row[DB_NUMBER],**rrow,**irow; 2565 char *row[DB_NUMBER],**rrow,**irow;
2566 char *rev_str = NULL;
2165 BIGNUM *bn = NULL; 2567 BIGNUM *bn = NULL;
2166 int ok=-1,i; 2568 int ok=-1,i;
2167 2569
@@ -2230,12 +2632,12 @@ static int do_revoke(X509 *x509, TXT_DB *db)
2230 } 2632 }
2231 2633
2232 /* Revoke Certificate */ 2634 /* Revoke Certificate */
2233 ok = do_revoke(x509,db); 2635 ok = do_revoke(x509,db, type, value);
2234 2636
2235 goto err; 2637 goto err;
2236 2638
2237 } 2639 }
2238 else if (index_name_cmp(row,rrow)) 2640 else if (index_name_cmp((const char **)row,(const char **)rrow))
2239 { 2641 {
2240 BIO_printf(bio_err,"ERROR:name does not match %s\n", 2642 BIO_printf(bio_err,"ERROR:name does not match %s\n",
2241 row[DB_name]); 2643 row[DB_name]);
@@ -2250,14 +2652,15 @@ static int do_revoke(X509 *x509, TXT_DB *db)
2250 else 2652 else
2251 { 2653 {
2252 BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]); 2654 BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]);
2253 revtm = ASN1_UTCTIME_new(); 2655 rev_str = make_revocation_str(type, value);
2254 revtm=X509_gmtime_adj(revtm,0); 2656 if (!rev_str)
2657 {
2658 BIO_printf(bio_err, "Error in revocation arguments\n");
2659 goto err;
2660 }
2255 rrow[DB_type][0]='R'; 2661 rrow[DB_type][0]='R';
2256 rrow[DB_type][1]='\0'; 2662 rrow[DB_type][1]='\0';
2257 rrow[DB_rev_date]=(char *)OPENSSL_malloc(revtm->length+1); 2663 rrow[DB_rev_date] = rev_str;
2258 memcpy(rrow[DB_rev_date],revtm->data,revtm->length);
2259 rrow[DB_rev_date][revtm->length]='\0';
2260 ASN1_UTCTIME_free(revtm);
2261 } 2664 }
2262 ok=1; 2665 ok=1;
2263err: 2666err:
@@ -2267,5 +2670,618 @@ err:
2267 OPENSSL_free(row[i]); 2670 OPENSSL_free(row[i]);
2268 } 2671 }
2269 return(ok); 2672 return(ok);
2673 }
2674
2675static int get_certificate_status(const char *serial, TXT_DB *db)
2676 {
2677 char *row[DB_NUMBER],**rrow;
2678 int ok=-1,i;
2679
2680 /* Free Resources */
2681 for (i=0; i<DB_NUMBER; i++)
2682 row[i]=NULL;
2683
2684 /* Malloc needed char spaces */
2685 row[DB_serial] = OPENSSL_malloc(strlen(serial) + 2);
2686 if (row[DB_serial] == NULL)
2687 {
2688 BIO_printf(bio_err,"Malloc failure\n");
2689 goto err;
2690 }
2691
2692 if (strlen(serial) % 2)
2693 {
2694 /* Set the first char to 0 */;
2695 row[DB_serial][0]='0';
2696
2697 /* Copy String from serial to row[DB_serial] */
2698 memcpy(row[DB_serial]+1, serial, strlen(serial));
2699 row[DB_serial][strlen(serial)+1]='\0';
2700 }
2701 else
2702 {
2703 /* Copy String from serial to row[DB_serial] */
2704 memcpy(row[DB_serial], serial, strlen(serial));
2705 row[DB_serial][strlen(serial)]='\0';
2706 }
2707
2708 /* Make it Upper Case */
2709 for (i=0; row[DB_serial][i] != '\0'; i++)
2710 row[DB_serial][i] = toupper(row[DB_serial][i]);
2711
2712
2713 ok=1;
2714
2715 /* Search for the certificate */
2716 rrow=TXT_DB_get_by_index(db,DB_serial,row);
2717 if (rrow == NULL)
2718 {
2719 BIO_printf(bio_err,"Serial %s not present in db.\n",
2720 row[DB_serial]);
2721 ok=-1;
2722 goto err;
2723 }
2724 else if (rrow[DB_type][0]=='V')
2725 {
2726 BIO_printf(bio_err,"%s=Valid (%c)\n",
2727 row[DB_serial], rrow[DB_type][0]);
2728 goto err;
2729 }
2730 else if (rrow[DB_type][0]=='R')
2731 {
2732 BIO_printf(bio_err,"%s=Revoked (%c)\n",
2733 row[DB_serial], rrow[DB_type][0]);
2734 goto err;
2735 }
2736 else if (rrow[DB_type][0]=='E')
2737 {
2738 BIO_printf(bio_err,"%s=Expired (%c)\n",
2739 row[DB_serial], rrow[DB_type][0]);
2740 goto err;
2741 }
2742 else if (rrow[DB_type][0]=='S')
2743 {
2744 BIO_printf(bio_err,"%s=Suspended (%c)\n",
2745 row[DB_serial], rrow[DB_type][0]);
2746 goto err;
2747 }
2748 else
2749 {
2750 BIO_printf(bio_err,"%s=Unknown (%c).\n",
2751 row[DB_serial], rrow[DB_type][0]);
2752 ok=-1;
2753 }
2754err:
2755 for (i=0; i<DB_NUMBER; i++)
2756 {
2757 if (row[i] != NULL)
2758 OPENSSL_free(row[i]);
2759 }
2760 return(ok);
2761 }
2762
2763static int do_updatedb (TXT_DB *db)
2764 {
2765 ASN1_UTCTIME *a_tm = NULL;
2766 int i, cnt = 0;
2767 int db_y2k, a_y2k; /* flags = 1 if y >= 2000 */
2768 char **rrow, *a_tm_s;
2769
2770 a_tm = ASN1_UTCTIME_new();
2771
2772 /* get actual time and make a string */
2773 a_tm = X509_gmtime_adj(a_tm, 0);
2774 a_tm_s = (char *) OPENSSL_malloc(a_tm->length+1);
2775 if (a_tm_s == NULL)
2776 {
2777 cnt = -1;
2778 goto err;
2779 }
2780
2781 memcpy(a_tm_s, a_tm->data, a_tm->length);
2782 a_tm_s[a_tm->length] = '\0';
2783
2784 if (strncmp(a_tm_s, "49", 2) <= 0)
2785 a_y2k = 1;
2786 else
2787 a_y2k = 0;
2788
2789 for (i = 0; i < sk_num(db->data); i++)
2790 {
2791 rrow = (char **) sk_value(db->data, i);
2792
2793 if (rrow[DB_type][0] == 'V')
2794 {
2795 /* ignore entries that are not valid */
2796 if (strncmp(rrow[DB_exp_date], "49", 2) <= 0)
2797 db_y2k = 1;
2798 else
2799 db_y2k = 0;
2800
2801 if (db_y2k == a_y2k)
2802 {
2803 /* all on the same y2k side */
2804 if (strcmp(rrow[DB_exp_date], a_tm_s) <= 0)
2805 {
2806 rrow[DB_type][0] = 'E';
2807 rrow[DB_type][1] = '\0';
2808 cnt++;
2809
2810 BIO_printf(bio_err, "%s=Expired\n",
2811 rrow[DB_serial]);
2812 }
2813 }
2814 else if (db_y2k < a_y2k)
2815 {
2816 rrow[DB_type][0] = 'E';
2817 rrow[DB_type][1] = '\0';
2818 cnt++;
2819
2820 BIO_printf(bio_err, "%s=Expired\n",
2821 rrow[DB_serial]);
2822 }
2823
2824 }
2825 }
2826
2827err:
2828
2829 ASN1_UTCTIME_free(a_tm);
2830 OPENSSL_free(a_tm_s);
2831
2832 return (cnt);
2833 }
2834
2835static char *crl_reasons[] = {
2836 /* CRL reason strings */
2837 "unspecified",
2838 "keyCompromise",
2839 "CACompromise",
2840 "affiliationChanged",
2841 "superseded",
2842 "cessationOfOperation",
2843 "certificateHold",
2844 "removeFromCRL",
2845 /* Additional pseudo reasons */
2846 "holdInstruction",
2847 "keyTime",
2848 "CAkeyTime"
2849};
2850
2851#define NUM_REASONS (sizeof(crl_reasons) / sizeof(char *))
2852
2853/* Given revocation information convert to a DB string.
2854 * The format of the string is:
2855 * revtime[,reason,extra]. Where 'revtime' is the
2856 * revocation time (the current time). 'reason' is the
2857 * optional CRL reason and 'extra' is any additional
2858 * argument
2859 */
2860
2861char *make_revocation_str(int rev_type, char *rev_arg)
2862 {
2863 char *reason = NULL, *other = NULL, *str;
2864 ASN1_OBJECT *otmp;
2865 ASN1_UTCTIME *revtm = NULL;
2866 int i;
2867 switch (rev_type)
2868 {
2869 case REV_NONE:
2870 break;
2871
2872 case REV_CRL_REASON:
2873 for (i = 0; i < 8; i++)
2874 {
2875 if (!strcasecmp(rev_arg, crl_reasons[i]))
2876 {
2877 reason = crl_reasons[i];
2878 break;
2879 }
2880 }
2881 if (reason == NULL)
2882 {
2883 BIO_printf(bio_err, "Unknown CRL reason %s\n", rev_arg);
2884 return NULL;
2885 }
2886 break;
2887
2888 case REV_HOLD:
2889 /* Argument is an OID */
2890
2891 otmp = OBJ_txt2obj(rev_arg, 0);
2892 ASN1_OBJECT_free(otmp);
2893
2894 if (otmp == NULL)
2895 {
2896 BIO_printf(bio_err, "Invalid object identifier %s\n", rev_arg);
2897 return NULL;
2898 }
2899
2900 reason = "holdInstruction";
2901 other = rev_arg;
2902 break;
2903
2904 case REV_KEY_COMPROMISE:
2905 case REV_CA_COMPROMISE:
2906
2907 /* Argument is the key compromise time */
2908 if (!ASN1_GENERALIZEDTIME_set_string(NULL, rev_arg))
2909 {
2910 BIO_printf(bio_err, "Invalid time format %s. Need YYYYMMDDHHMMSSZ\n", rev_arg);
2911 return NULL;
2912 }
2913 other = rev_arg;
2914 if (rev_type == REV_KEY_COMPROMISE)
2915 reason = "keyTime";
2916 else
2917 reason = "CAkeyTime";
2918
2919 break;
2920
2921 }
2922
2923 revtm = X509_gmtime_adj(NULL, 0);
2924
2925 i = revtm->length + 1;
2926
2927 if (reason) i += strlen(reason) + 1;
2928 if (other) i += strlen(other) + 1;
2929
2930 str = OPENSSL_malloc(i);
2931
2932 if (!str) return NULL;
2933
2934 strcpy(str, (char *)revtm->data);
2935 if (reason)
2936 {
2937 strcat(str, ",");
2938 strcat(str, reason);
2939 }
2940 if (other)
2941 {
2942 strcat(str, ",");
2943 strcat(str, other);
2944 }
2945 ASN1_UTCTIME_free(revtm);
2946 return str;
2947 }
2948
2949/* Convert revocation field to X509_REVOKED entry
2950 * return code:
2951 * 0 error
2952 * 1 OK
2953 * 2 OK and some extensions added (i.e. V2 CRL)
2954 */
2955
2956
2957int make_revoked(X509_REVOKED *rev, char *str)
2958 {
2959 char *tmp = NULL;
2960 int reason_code = -1;
2961 int i, ret = 0;
2962 ASN1_OBJECT *hold = NULL;
2963 ASN1_GENERALIZEDTIME *comp_time = NULL;
2964 ASN1_ENUMERATED *rtmp = NULL;
2965
2966 ASN1_TIME *revDate = NULL;
2967
2968 i = unpack_revinfo(&revDate, &reason_code, &hold, &comp_time, str);
2969
2970 if (i == 0)
2971 goto err;
2972
2973 if (rev && !X509_REVOKED_set_revocationDate(rev, revDate))
2974 goto err;
2975
2976 if (rev && (reason_code != OCSP_REVOKED_STATUS_NOSTATUS))
2977 {
2978 rtmp = ASN1_ENUMERATED_new();
2979 if (!rtmp || !ASN1_ENUMERATED_set(rtmp, reason_code))
2980 goto err;
2981 if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
2982 goto err;
2983 }
2984
2985 if (rev && comp_time)
2986 {
2987 if (!X509_REVOKED_add1_ext_i2d(rev, NID_invalidity_date, comp_time, 0, 0))
2988 goto err;
2989 }
2990 if (rev && hold)
2991 {
2992 if (!X509_REVOKED_add1_ext_i2d(rev, NID_hold_instruction_code, hold, 0, 0))
2993 goto err;
2994 }
2995
2996 if (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)
2997 ret = 2;
2998 else ret = 1;
2999
3000 err:
3001
3002 if (tmp) OPENSSL_free(tmp);
3003 ASN1_OBJECT_free(hold);
3004 ASN1_GENERALIZEDTIME_free(comp_time);
3005 ASN1_ENUMERATED_free(rtmp);
3006 ASN1_TIME_free(revDate);
3007
3008 return ret;
3009 }
3010
3011/*
3012 * subject is expected to be in the format /type0=value0/type1=value1/type2=...
3013 * where characters may be escaped by \
3014 */
3015static X509_NAME *do_subject(char *subject)
3016 {
3017 size_t buflen = strlen (subject)+1; /* to copy the types and values into. due to escaping, the copy can only become shorter */
3018 char *buf = malloc (buflen);
3019 size_t max_ne = buflen / 2 + 1; /* maximum number of name elements */
3020 char **ne_types = malloc (max_ne * sizeof (char *));
3021 char **ne_values = malloc (max_ne * sizeof (char *));
3022
3023 char *sp = subject, *bp = buf;
3024 int i, ne_num = 0;
3025
3026 X509_NAME *n = NULL;
3027 int nid;
3028
3029 if (!buf || !ne_types || !ne_values)
3030 {
3031 BIO_printf(bio_err, "malloc error\n");
3032 goto error0;
3033 }
3034
3035 if (*subject != '/')
3036 {
3037 BIO_printf(bio_err, "Subject does not start with '/'.\n");
3038 goto error0;
3039 }
3040 sp++; /* skip leading / */
3041
3042 while (*sp)
3043 {
3044 /* collect type */
3045 ne_types[ne_num] = bp;
3046 while (*sp)
3047 {
3048 if (*sp == '\\') /* is there anything to escape in the type...? */
3049 if (*++sp)
3050 *bp++ = *sp++;
3051 else
3052 {
3053 BIO_printf(bio_err, "escape character at end of string\n");
3054 goto error0;
3055 }
3056 else if (*sp == '=')
3057 {
3058 sp++;
3059 *bp++ = '\0';
3060 break;
3061 }
3062 else
3063 *bp++ = *sp++;
3064 }
3065 if (!*sp)
3066 {
3067 BIO_printf(bio_err, "end of string encountered while processing type of subject name element #%d\n", ne_num);
3068 goto error0;
3069 }
3070 ne_values[ne_num] = bp;
3071 while (*sp)
3072 {
3073 if (*sp == '\\')
3074 if (*++sp)
3075 *bp++ = *sp++;
3076 else
3077 {
3078 BIO_printf(bio_err, "escape character at end of string\n");
3079 goto error0;
3080 }
3081 else if (*sp == '/')
3082 {
3083 sp++;
3084 *bp++ = '\0';
3085 break;
3086 }
3087 else
3088 *bp++ = *sp++;
3089 }
3090 *bp++ = '\0';
3091 ne_num++;
3092 }
3093
3094 if (!(n = X509_NAME_new()))
3095 goto error0;
3096
3097 for (i = 0; i < ne_num; i++)
3098 {
3099 if ((nid=OBJ_txt2nid(ne_types[i])) == NID_undef)
3100 {
3101 BIO_printf(bio_err, "Subject Attribute %s has no known NID, skipped\n", ne_types[i]);
3102 continue;
3103 }
3104
3105 if (!*ne_values[i])
3106 {
3107 BIO_printf(bio_err, "No value provided for Subject Attribute %s, skipped\n", ne_types[i]);
3108 continue;
3109 }
3110
3111 if (!X509_NAME_add_entry_by_NID(n, nid, MBSTRING_ASC, (unsigned char*)ne_values[i], -1,-1,0))
3112 goto error1;
3113 }
3114
3115 free (ne_values);
3116 free (ne_types);
3117 free (buf);
3118 return n;
3119
3120error1:
3121 X509_NAME_free(n);
3122error0:
3123 free (ne_values);
3124 free (ne_types);
3125 free (buf);
3126 return NULL;
2270} 3127}
2271 3128
3129
3130int old_entry_print(BIO *bp, ASN1_OBJECT *obj, ASN1_STRING *str)
3131 {
3132 char buf[25],*pbuf, *p;
3133 int j;
3134 j=i2a_ASN1_OBJECT(bp,obj);
3135 pbuf=buf;
3136 for (j=22-j; j>0; j--)
3137 *(pbuf++)=' ';
3138 *(pbuf++)=':';
3139 *(pbuf++)='\0';
3140 BIO_puts(bp,buf);
3141
3142 if (str->type == V_ASN1_PRINTABLESTRING)
3143 BIO_printf(bp,"PRINTABLE:'");
3144 else if (str->type == V_ASN1_T61STRING)
3145 BIO_printf(bp,"T61STRING:'");
3146 else if (str->type == V_ASN1_IA5STRING)
3147 BIO_printf(bp,"IA5STRING:'");
3148 else if (str->type == V_ASN1_UNIVERSALSTRING)
3149 BIO_printf(bp,"UNIVERSALSTRING:'");
3150 else
3151 BIO_printf(bp,"ASN.1 %2d:'",str->type);
3152
3153 p=(char *)str->data;
3154 for (j=str->length; j>0; j--)
3155 {
3156 if ((*p >= ' ') && (*p <= '~'))
3157 BIO_printf(bp,"%c",*p);
3158 else if (*p & 0x80)
3159 BIO_printf(bp,"\\0x%02X",*p);
3160 else if ((unsigned char)*p == 0xf7)
3161 BIO_printf(bp,"^?");
3162 else BIO_printf(bp,"^%c",*p+'@');
3163 p++;
3164 }
3165 BIO_printf(bp,"'\n");
3166 return 1;
3167 }
3168
3169int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, char *str)
3170 {
3171 char *tmp = NULL;
3172 char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
3173 int reason_code = -1;
3174 int i, ret = 0;
3175 ASN1_OBJECT *hold = NULL;
3176 ASN1_GENERALIZEDTIME *comp_time = NULL;
3177 tmp = BUF_strdup(str);
3178
3179 p = strchr(tmp, ',');
3180
3181 rtime_str = tmp;
3182
3183 if (p)
3184 {
3185 *p = '\0';
3186 p++;
3187 reason_str = p;
3188 p = strchr(p, ',');
3189 if (p)
3190 {
3191 *p = '\0';
3192 arg_str = p + 1;
3193 }
3194 }
3195
3196 if (prevtm)
3197 {
3198 *prevtm = ASN1_UTCTIME_new();
3199 if (!ASN1_UTCTIME_set_string(*prevtm, rtime_str))
3200 {
3201 BIO_printf(bio_err, "invalid revocation date %s\n", rtime_str);
3202 goto err;
3203 }
3204 }
3205 if (reason_str)
3206 {
3207 for (i = 0; i < NUM_REASONS; i++)
3208 {
3209 if(!strcasecmp(reason_str, crl_reasons[i]))
3210 {
3211 reason_code = i;
3212 break;
3213 }
3214 }
3215 if (reason_code == OCSP_REVOKED_STATUS_NOSTATUS)
3216 {
3217 BIO_printf(bio_err, "invalid reason code %s\n", reason_str);
3218 goto err;
3219 }
3220
3221 if (reason_code == 7)
3222 reason_code = OCSP_REVOKED_STATUS_REMOVEFROMCRL;
3223 else if (reason_code == 8) /* Hold instruction */
3224 {
3225 if (!arg_str)
3226 {
3227 BIO_printf(bio_err, "missing hold instruction\n");
3228 goto err;
3229 }
3230 reason_code = OCSP_REVOKED_STATUS_CERTIFICATEHOLD;
3231 hold = OBJ_txt2obj(arg_str, 0);
3232
3233 if (!hold)
3234 {
3235 BIO_printf(bio_err, "invalid object identifier %s\n", arg_str);
3236 goto err;
3237 }
3238 if (phold) *phold = hold;
3239 }
3240 else if ((reason_code == 9) || (reason_code == 10))
3241 {
3242 if (!arg_str)
3243 {
3244 BIO_printf(bio_err, "missing compromised time\n");
3245 goto err;
3246 }
3247 comp_time = ASN1_GENERALIZEDTIME_new();
3248 if (!ASN1_GENERALIZEDTIME_set_string(comp_time, arg_str))
3249 {
3250 BIO_printf(bio_err, "invalid compromised time %s\n", arg_str);
3251 goto err;
3252 }
3253 if (reason_code == 9)
3254 reason_code = OCSP_REVOKED_STATUS_KEYCOMPROMISE;
3255 else
3256 reason_code = OCSP_REVOKED_STATUS_CACOMPROMISE;
3257 }
3258 }
3259
3260 if (preason) *preason = reason_code;
3261 if (pinvtm) *pinvtm = comp_time;
3262 else ASN1_GENERALIZEDTIME_free(comp_time);
3263
3264 ret = 1;
3265
3266 err:
3267
3268 if (tmp) OPENSSL_free(tmp);
3269 if (!phold) ASN1_OBJECT_free(hold);
3270 if (!pinvtm) ASN1_GENERALIZEDTIME_free(comp_time);
3271
3272 return ret;
3273 }
3274
3275int make_serial_index(TXT_DB *db)
3276 {
3277 if (!TXT_DB_create_index(db, DB_serial, NULL,
3278 LHASH_HASH_FN(index_serial_hash),
3279 LHASH_COMP_FN(index_serial_cmp)))
3280 {
3281 BIO_printf(bio_err,
3282 "error creating serial number index:(%ld,%ld,%ld)\n",
3283 db->error,db->arg1,db->arg2);
3284 return 0;
3285 }
3286 return 1;
3287 }
diff --git a/src/lib/libssl/src/apps/ciphers.c b/src/lib/libssl/src/apps/ciphers.c
index b6e2f966d8..2d6e104790 100644
--- a/src/lib/libssl/src/apps/ciphers.c
+++ b/src/lib/libssl/src/apps/ciphers.c
@@ -59,7 +59,7 @@
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 NO_STDIO 62#ifdef OPENSSL_NO_STDIO
63#define APPS_WIN16 63#define APPS_WIN16
64#endif 64#endif
65#include "apps.h" 65#include "apps.h"
@@ -95,11 +95,11 @@ int MAIN(int argc, char **argv)
95 char buf[512]; 95 char buf[512];
96 BIO *STDout=NULL; 96 BIO *STDout=NULL;
97 97
98#if !defined(NO_SSL2) && !defined(NO_SSL3) 98#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
99 meth=SSLv23_server_method(); 99 meth=SSLv23_server_method();
100#elif !defined(NO_SSL3) 100#elif !defined(OPENSSL_NO_SSL3)
101 meth=SSLv3_server_method(); 101 meth=SSLv3_server_method();
102#elif !defined(NO_SSL2) 102#elif !defined(OPENSSL_NO_SSL2)
103 meth=SSLv2_server_method(); 103 meth=SSLv2_server_method();
104#endif 104#endif
105 105
@@ -108,7 +108,7 @@ int MAIN(int argc, char **argv)
108 if (bio_err == NULL) 108 if (bio_err == NULL)
109 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 109 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
110 STDout=BIO_new_fp(stdout,BIO_NOCLOSE); 110 STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
111#ifdef VMS 111#ifdef OPENSSL_SYS_VMS
112 { 112 {
113 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 113 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
114 STDout = BIO_push(tmpbio, STDout); 114 STDout = BIO_push(tmpbio, STDout);
@@ -121,15 +121,15 @@ int MAIN(int argc, char **argv)
121 { 121 {
122 if (strcmp(*argv,"-v") == 0) 122 if (strcmp(*argv,"-v") == 0)
123 verbose=1; 123 verbose=1;
124#ifndef NO_SSL2 124#ifndef OPENSSL_NO_SSL2
125 else if (strcmp(*argv,"-ssl2") == 0) 125 else if (strcmp(*argv,"-ssl2") == 0)
126 meth=SSLv2_client_method(); 126 meth=SSLv2_client_method();
127#endif 127#endif
128#ifndef NO_SSL3 128#ifndef OPENSSL_NO_SSL3
129 else if (strcmp(*argv,"-ssl3") == 0) 129 else if (strcmp(*argv,"-ssl3") == 0)
130 meth=SSLv3_client_method(); 130 meth=SSLv3_client_method();
131#endif 131#endif
132#ifndef NO_TLS1 132#ifndef OPENSSL_NO_TLS1
133 else if (strcmp(*argv,"-tls1") == 0) 133 else if (strcmp(*argv,"-tls1") == 0)
134 meth=TLSv1_client_method(); 134 meth=TLSv1_client_method();
135#endif 135#endif
@@ -150,7 +150,7 @@ int MAIN(int argc, char **argv)
150 if (badops) 150 if (badops)
151 { 151 {
152 for (pp=ciphers_usage; (*pp != NULL); pp++) 152 for (pp=ciphers_usage; (*pp != NULL); pp++)
153 BIO_printf(bio_err,*pp); 153 BIO_printf(bio_err,"%s",*pp);
154 goto end; 154 goto end;
155 } 155 }
156 156
@@ -202,6 +202,7 @@ end:
202 if (ctx != NULL) SSL_CTX_free(ctx); 202 if (ctx != NULL) SSL_CTX_free(ctx);
203 if (ssl != NULL) SSL_free(ssl); 203 if (ssl != NULL) SSL_free(ssl);
204 if (STDout != NULL) BIO_free_all(STDout); 204 if (STDout != NULL) BIO_free_all(STDout);
205 apps_shutdown();
205 EXIT(ret); 206 EXIT(ret);
206 } 207 }
207 208
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c
index 3b5725f23f..00946b4d20 100644
--- a/src/lib/libssl/src/apps/crl.c
+++ b/src/lib/libssl/src/apps/crl.c
@@ -87,6 +87,7 @@ static char *crl_usage[]={
87" -noout - no CRL output\n", 87" -noout - no CRL output\n",
88" -CAfile name - verify CRL using certificates in file \"name\"\n", 88" -CAfile name - verify CRL using certificates in file \"name\"\n",
89" -CApath dir - verify CRL using certificates in \"dir\"\n", 89" -CApath dir - verify CRL using certificates in \"dir\"\n",
90" -nameopt arg - various certificate name options\n",
90NULL 91NULL
91}; 92};
92 93
@@ -97,6 +98,7 @@ int MAIN(int, char **);
97 98
98int MAIN(int argc, char **argv) 99int MAIN(int argc, char **argv)
99 { 100 {
101 unsigned long nmflag = 0;
100 X509_CRL *x=NULL; 102 X509_CRL *x=NULL;
101 char *CAfile = NULL, *CApath = NULL; 103 char *CAfile = NULL, *CApath = NULL;
102 int ret=1,i,num,badops=0; 104 int ret=1,i,num,badops=0;
@@ -105,7 +107,7 @@ int MAIN(int argc, char **argv)
105 char *infile=NULL,*outfile=NULL; 107 char *infile=NULL,*outfile=NULL;
106 int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; 108 int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
107 int fingerprint = 0; 109 int fingerprint = 0;
108 char **pp,buf[256]; 110 char **pp;
109 X509_STORE *store = NULL; 111 X509_STORE *store = NULL;
110 X509_STORE_CTX ctx; 112 X509_STORE_CTX ctx;
111 X509_LOOKUP *lookup = NULL; 113 X509_LOOKUP *lookup = NULL;
@@ -120,11 +122,14 @@ int MAIN(int argc, char **argv)
120 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 122 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
121 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 123 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
122 124
125 if (!load_config(bio_err, NULL))
126 goto end;
127
123 if (bio_out == NULL) 128 if (bio_out == NULL)
124 if ((bio_out=BIO_new(BIO_s_file())) != NULL) 129 if ((bio_out=BIO_new(BIO_s_file())) != NULL)
125 { 130 {
126 BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); 131 BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
127#ifdef VMS 132#ifdef OPENSSL_SYS_VMS
128 { 133 {
129 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 134 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
130 bio_out = BIO_push(tmpbio, bio_out); 135 bio_out = BIO_push(tmpbio, bio_out);
@@ -185,6 +190,11 @@ int MAIN(int argc, char **argv)
185 text = 1; 190 text = 1;
186 else if (strcmp(*argv,"-hash") == 0) 191 else if (strcmp(*argv,"-hash") == 0)
187 hash= ++num; 192 hash= ++num;
193 else if (strcmp(*argv,"-nameopt") == 0)
194 {
195 if (--argc < 1) goto bad;
196 if (!set_name_ex(&nmflag, *(++argv))) goto bad;
197 }
188 else if (strcmp(*argv,"-issuer") == 0) 198 else if (strcmp(*argv,"-issuer") == 0)
189 issuer= ++num; 199 issuer= ++num;
190 else if (strcmp(*argv,"-lastupdate") == 0) 200 else if (strcmp(*argv,"-lastupdate") == 0)
@@ -214,7 +224,7 @@ int MAIN(int argc, char **argv)
214 { 224 {
215bad: 225bad:
216 for (pp=crl_usage; (*pp != NULL); pp++) 226 for (pp=crl_usage; (*pp != NULL); pp++)
217 BIO_printf(bio_err,*pp); 227 BIO_printf(bio_err,"%s",*pp);
218 goto end; 228 goto end;
219 } 229 }
220 230
@@ -235,7 +245,11 @@ bad:
235 X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT); 245 X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
236 ERR_clear_error(); 246 ERR_clear_error();
237 247
238 X509_STORE_CTX_init(&ctx, store, NULL, NULL); 248 if(!X509_STORE_CTX_init(&ctx, store, NULL, NULL)) {
249 BIO_printf(bio_err,
250 "Error initialising X509 store\n");
251 goto end;
252 }
239 253
240 i = X509_STORE_get_by_subject(&ctx, X509_LU_X509, 254 i = X509_STORE_get_by_subject(&ctx, X509_LU_X509,
241 X509_CRL_get_issuer(x), &xobj); 255 X509_CRL_get_issuer(x), &xobj);
@@ -264,9 +278,7 @@ bad:
264 { 278 {
265 if (issuer == i) 279 if (issuer == i)
266 { 280 {
267 X509_NAME_oneline(X509_CRL_get_issuer(x), 281 print_name(bio_out, "issuer=", X509_CRL_get_issuer(x), nmflag);
268 buf,256);
269 BIO_printf(bio_out,"issuer= %s\n",buf);
270 } 282 }
271 283
272 if (hash == i) 284 if (hash == i)
@@ -324,7 +336,7 @@ bad:
324 if (outfile == NULL) 336 if (outfile == NULL)
325 { 337 {
326 BIO_set_fp(out,stdout,BIO_NOCLOSE); 338 BIO_set_fp(out,stdout,BIO_NOCLOSE);
327#ifdef VMS 339#ifdef OPENSSL_SYS_VMS
328 { 340 {
329 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 341 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
330 out = BIO_push(tmpbio, out); 342 out = BIO_push(tmpbio, out);
@@ -364,6 +376,7 @@ end:
364 X509_STORE_CTX_cleanup(&ctx); 376 X509_STORE_CTX_cleanup(&ctx);
365 X509_STORE_free(store); 377 X509_STORE_free(store);
366 } 378 }
379 apps_shutdown();
367 EXIT(ret); 380 EXIT(ret);
368 } 381 }
369 382
diff --git a/src/lib/libssl/src/apps/crl2p7.c b/src/lib/libssl/src/apps/crl2p7.c
index 7f853b65ab..8729068462 100644
--- a/src/lib/libssl/src/apps/crl2p7.c
+++ b/src/lib/libssl/src/apps/crl2p7.c
@@ -166,7 +166,8 @@ bad:
166 BIO_printf(bio_err," -certfile arg certificates file of chain to a trusted CA\n"); 166 BIO_printf(bio_err," -certfile arg certificates file of chain to a trusted CA\n");
167 BIO_printf(bio_err," (can be used more than once)\n"); 167 BIO_printf(bio_err," (can be used more than once)\n");
168 BIO_printf(bio_err," -nocrl no crl to load, just certs from '-certfile'\n"); 168 BIO_printf(bio_err," -nocrl no crl to load, just certs from '-certfile'\n");
169 EXIT(1); 169 ret = 1;
170 goto end;
170 } 171 }
171 172
172 ERR_load_crypto_strings(); 173 ERR_load_crypto_strings();
@@ -241,7 +242,7 @@ bad:
241 if (outfile == NULL) 242 if (outfile == NULL)
242 { 243 {
243 BIO_set_fp(out,stdout,BIO_NOCLOSE); 244 BIO_set_fp(out,stdout,BIO_NOCLOSE);
244#ifdef VMS 245#ifdef OPENSSL_SYS_VMS
245 { 246 {
246 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 247 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
247 out = BIO_push(tmpbio, out); 248 out = BIO_push(tmpbio, out);
@@ -278,6 +279,7 @@ end:
278 if (p7 != NULL) PKCS7_free(p7); 279 if (p7 != NULL) PKCS7_free(p7);
279 if (crl != NULL) X509_CRL_free(crl); 280 if (crl != NULL) X509_CRL_free(crl);
280 281
282 apps_shutdown();
281 EXIT(ret); 283 EXIT(ret);
282 } 284 }
283 285
diff --git a/src/lib/libssl/src/apps/dgst.c b/src/lib/libssl/src/apps/dgst.c
index 61b2a0dc4b..0620b32bb4 100644
--- a/src/lib/libssl/src/apps/dgst.c
+++ b/src/lib/libssl/src/apps/dgst.c
@@ -66,7 +66,6 @@
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68#include <openssl/pem.h> 68#include <openssl/pem.h>
69#include <openssl/engine.h>
70 69
71#undef BUFSIZE 70#undef BUFSIZE
72#define BUFSIZE 1024*8 71#define BUFSIZE 1024*8
@@ -89,10 +88,11 @@ int MAIN(int argc, char **argv)
89 BIO *bmd=NULL; 88 BIO *bmd=NULL;
90 BIO *out = NULL; 89 BIO *out = NULL;
91 const char *name; 90 const char *name;
92#define PROG_NAME_SIZE 16 91#define PROG_NAME_SIZE 39
93 char pname[PROG_NAME_SIZE]; 92 char pname[PROG_NAME_SIZE+1];
94 int separator=0; 93 int separator=0;
95 int debug=0; 94 int debug=0;
95 int keyform=FORMAT_PEM;
96 const char *outfile = NULL, *keyfile = NULL; 96 const char *outfile = NULL, *keyfile = NULL;
97 const char *sigfile = NULL, *randfile = NULL; 97 const char *sigfile = NULL, *randfile = NULL;
98 int out_bin = -1, want_pub = 0, do_verify = 0; 98 int out_bin = -1, want_pub = 0, do_verify = 0;
@@ -112,6 +112,9 @@ int MAIN(int argc, char **argv)
112 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 112 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
113 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 113 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
114 114
115 if (!load_config(bio_err, NULL))
116 goto end;
117
115 /* first check the program name */ 118 /* first check the program name */
116 program_name(argv[0],pname,PROG_NAME_SIZE); 119 program_name(argv[0],pname,PROG_NAME_SIZE);
117 120
@@ -157,6 +160,11 @@ int MAIN(int argc, char **argv)
157 if (--argc < 1) break; 160 if (--argc < 1) break;
158 sigfile=*(++argv); 161 sigfile=*(++argv);
159 } 162 }
163 else if (strcmp(*argv,"-keyform") == 0)
164 {
165 if (--argc < 1) break;
166 keyform=str2fmt(*(++argv));
167 }
160 else if (strcmp(*argv,"-engine") == 0) 168 else if (strcmp(*argv,"-engine") == 0)
161 { 169 {
162 if (--argc < 1) break; 170 if (--argc < 1) break;
@@ -196,6 +204,7 @@ int MAIN(int argc, char **argv)
196 BIO_printf(bio_err,"-sign file sign digest using private key in file\n"); 204 BIO_printf(bio_err,"-sign file sign digest using private key in file\n");
197 BIO_printf(bio_err,"-verify file verify a signature using public key in file\n"); 205 BIO_printf(bio_err,"-verify file verify a signature using public key in file\n");
198 BIO_printf(bio_err,"-prverify file verify a signature using private key in file\n"); 206 BIO_printf(bio_err,"-prverify file verify a signature using private key in file\n");
207 BIO_printf(bio_err,"-keyform arg key file format (PEM or ENGINE)\n");
199 BIO_printf(bio_err,"-signature file signature to verify\n"); 208 BIO_printf(bio_err,"-signature file signature to verify\n");
200 BIO_printf(bio_err,"-binary output in binary form\n"); 209 BIO_printf(bio_err,"-binary output in binary form\n");
201 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); 210 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
@@ -218,23 +227,7 @@ int MAIN(int argc, char **argv)
218 goto end; 227 goto end;
219 } 228 }
220 229
221 if (engine != NULL) 230 e = setup_engine(bio_err, engine, 0);
222 {
223 if((e = ENGINE_by_id(engine)) == NULL)
224 {
225 BIO_printf(bio_err,"invalid engine \"%s\"\n",
226 engine);
227 goto end;
228 }
229 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
230 {
231 BIO_printf(bio_err,"can't use that engine\n");
232 goto end;
233 }
234 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
235 /* Free our "structural" reference. */
236 ENGINE_free(e);
237 }
238 231
239 in=BIO_new(BIO_s_file()); 232 in=BIO_new(BIO_s_file());
240 bmd=BIO_new(BIO_f_md()); 233 bmd=BIO_new(BIO_f_md());
@@ -265,7 +258,7 @@ int MAIN(int argc, char **argv)
265 else out = BIO_new_file(outfile, "w"); 258 else out = BIO_new_file(outfile, "w");
266 } else { 259 } else {
267 out = BIO_new_fp(stdout, BIO_NOCLOSE); 260 out = BIO_new_fp(stdout, BIO_NOCLOSE);
268#ifdef VMS 261#ifdef OPENSSL_SYS_VMS
269 { 262 {
270 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 263 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
271 out = BIO_push(tmpbio, out); 264 out = BIO_push(tmpbio, out);
@@ -280,27 +273,21 @@ int MAIN(int argc, char **argv)
280 goto end; 273 goto end;
281 } 274 }
282 275
283 if(keyfile) { 276 if(keyfile)
284 BIO *keybio; 277 {
285 keybio = BIO_new_file(keyfile, "r"); 278 if (want_pub)
286 if(!keybio) { 279 sigkey = load_pubkey(bio_err, keyfile, keyform, NULL,
287 BIO_printf(bio_err, "Error opening key file %s\n", 280 e, "key file");
288 keyfile); 281 else
289 ERR_print_errors(bio_err); 282 sigkey = load_key(bio_err, keyfile, keyform, NULL,
290 goto end; 283 e, "key file");
291 } 284 if (!sigkey)
292 285 {
293 if(want_pub) 286 /* load_[pub]key() has already printed an appropriate
294 sigkey = PEM_read_bio_PUBKEY(keybio, NULL, NULL, NULL); 287 message */
295 else sigkey = PEM_read_bio_PrivateKey(keybio, NULL, NULL, NULL);
296 BIO_free(keybio);
297 if(!sigkey) {
298 BIO_printf(bio_err, "Error reading key file %s\n",
299 keyfile);
300 ERR_print_errors(bio_err);
301 goto end; 288 goto end;
289 }
302 } 290 }
303 }
304 291
305 if(sigfile && sigkey) { 292 if(sigfile && sigkey) {
306 BIO *sigbio; 293 BIO *sigbio;
@@ -362,6 +349,7 @@ end:
362 EVP_PKEY_free(sigkey); 349 EVP_PKEY_free(sigkey);
363 if(sigbuf) OPENSSL_free(sigbuf); 350 if(sigbuf) OPENSSL_free(sigbuf);
364 if (bmd != NULL) BIO_free(bmd); 351 if (bmd != NULL) BIO_free(bmd);
352 apps_shutdown();
365 EXIT(err); 353 EXIT(err);
366 } 354 }
367 355
diff --git a/src/lib/libssl/src/apps/dh.c b/src/lib/libssl/src/apps/dh.c
index 229ba2f63a..27c3dc8df2 100644
--- a/src/lib/libssl/src/apps/dh.c
+++ b/src/lib/libssl/src/apps/dh.c
@@ -57,7 +57,7 @@
57 * [including the GNU Public Licence.] 57 * [including the GNU Public Licence.]
58 */ 58 */
59 59
60#ifndef NO_DH 60#ifndef OPENSSL_NO_DH
61#include <stdio.h> 61#include <stdio.h>
62#include <stdlib.h> 62#include <stdlib.h>
63#include <time.h> 63#include <time.h>
@@ -69,7 +69,6 @@
69#include <openssl/dh.h> 69#include <openssl/dh.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/pem.h> 71#include <openssl/pem.h>
72#include <openssl/engine.h>
73 72
74#undef PROG 73#undef PROG
75#define PROG dh_main 74#define PROG dh_main
@@ -101,6 +100,9 @@ int MAIN(int argc, char **argv)
101 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 100 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
102 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 101 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
103 102
103 if (!load_config(bio_err, NULL))
104 goto end;
105
104 engine=NULL; 106 engine=NULL;
105 infile=NULL; 107 infile=NULL;
106 outfile=NULL; 108 outfile=NULL;
@@ -174,23 +176,7 @@ bad:
174 176
175 ERR_load_crypto_strings(); 177 ERR_load_crypto_strings();
176 178
177 if (engine != NULL) 179 e = setup_engine(bio_err, engine, 0);
178 {
179 if((e = ENGINE_by_id(engine)) == NULL)
180 {
181 BIO_printf(bio_err,"invalid engine \"%s\"\n",
182 engine);
183 goto end;
184 }
185 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
186 {
187 BIO_printf(bio_err,"can't use that engine\n");
188 goto end;
189 }
190 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
191 /* Free our "structural" reference. */
192 ENGINE_free(e);
193 }
194 180
195 in=BIO_new(BIO_s_file()); 181 in=BIO_new(BIO_s_file());
196 out=BIO_new(BIO_s_file()); 182 out=BIO_new(BIO_s_file());
@@ -213,7 +199,7 @@ bad:
213 if (outfile == NULL) 199 if (outfile == NULL)
214 { 200 {
215 BIO_set_fp(out,stdout,BIO_NOCLOSE); 201 BIO_set_fp(out,stdout,BIO_NOCLOSE);
216#ifdef VMS 202#ifdef OPENSSL_SYS_VMS
217 { 203 {
218 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 204 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
219 out = BIO_push(tmpbio, out); 205 out = BIO_push(tmpbio, out);
@@ -346,6 +332,7 @@ end:
346 if (in != NULL) BIO_free(in); 332 if (in != NULL) BIO_free(in);
347 if (out != NULL) BIO_free_all(out); 333 if (out != NULL) BIO_free_all(out);
348 if (dh != NULL) DH_free(dh); 334 if (dh != NULL) DH_free(dh);
335 apps_shutdown();
349 EXIT(ret); 336 EXIT(ret);
350 } 337 }
351#endif 338#endif
diff --git a/src/lib/libssl/src/apps/dhparam.c b/src/lib/libssl/src/apps/dhparam.c
index 9d5705f8bf..ea15ef3236 100644
--- a/src/lib/libssl/src/apps/dhparam.c
+++ b/src/lib/libssl/src/apps/dhparam.c
@@ -109,7 +109,7 @@
109 * 109 *
110 */ 110 */
111 111
112#ifndef NO_DH 112#ifndef OPENSSL_NO_DH
113#include <stdio.h> 113#include <stdio.h>
114#include <stdlib.h> 114#include <stdlib.h>
115#include <time.h> 115#include <time.h>
@@ -121,9 +121,8 @@
121#include <openssl/dh.h> 121#include <openssl/dh.h>
122#include <openssl/x509.h> 122#include <openssl/x509.h>
123#include <openssl/pem.h> 123#include <openssl/pem.h>
124#include <openssl/engine.h>
125 124
126#ifndef NO_DSA 125#ifndef OPENSSL_NO_DSA
127#include <openssl/dsa.h> 126#include <openssl/dsa.h>
128#endif 127#endif
129 128
@@ -152,7 +151,7 @@ int MAIN(int argc, char **argv)
152 ENGINE *e = NULL; 151 ENGINE *e = NULL;
153 DH *dh=NULL; 152 DH *dh=NULL;
154 int i,badops=0,text=0; 153 int i,badops=0,text=0;
155#ifndef NO_DSA 154#ifndef OPENSSL_NO_DSA
156 int dsaparam=0; 155 int dsaparam=0;
157#endif 156#endif
158 BIO *in=NULL,*out=NULL; 157 BIO *in=NULL,*out=NULL;
@@ -167,6 +166,9 @@ int MAIN(int argc, char **argv)
167 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 166 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
168 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 167 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
169 168
169 if (!load_config(bio_err, NULL))
170 goto end;
171
170 infile=NULL; 172 infile=NULL;
171 outfile=NULL; 173 outfile=NULL;
172 informat=FORMAT_PEM; 174 informat=FORMAT_PEM;
@@ -206,7 +208,7 @@ int MAIN(int argc, char **argv)
206 check=1; 208 check=1;
207 else if (strcmp(*argv,"-text") == 0) 209 else if (strcmp(*argv,"-text") == 0)
208 text=1; 210 text=1;
209#ifndef NO_DSA 211#ifndef OPENSSL_NO_DSA
210 else if (strcmp(*argv,"-dsaparam") == 0) 212 else if (strcmp(*argv,"-dsaparam") == 0)
211 dsaparam=1; 213 dsaparam=1;
212#endif 214#endif
@@ -238,7 +240,7 @@ bad:
238 BIO_printf(bio_err," -outform arg output format - one of DER PEM\n"); 240 BIO_printf(bio_err," -outform arg output format - one of DER PEM\n");
239 BIO_printf(bio_err," -in arg input file\n"); 241 BIO_printf(bio_err," -in arg input file\n");
240 BIO_printf(bio_err," -out arg output file\n"); 242 BIO_printf(bio_err," -out arg output file\n");
241#ifndef NO_DSA 243#ifndef OPENSSL_NO_DSA
242 BIO_printf(bio_err," -dsaparam read or generate DSA parameters, convert to DH\n"); 244 BIO_printf(bio_err," -dsaparam read or generate DSA parameters, convert to DH\n");
243#endif 245#endif
244 BIO_printf(bio_err," -check check the DH parameters\n"); 246 BIO_printf(bio_err," -check check the DH parameters\n");
@@ -257,28 +259,12 @@ bad:
257 259
258 ERR_load_crypto_strings(); 260 ERR_load_crypto_strings();
259 261
260 if (engine != NULL) 262 e = setup_engine(bio_err, engine, 0);
261 {
262 if((e = ENGINE_by_id(engine)) == NULL)
263 {
264 BIO_printf(bio_err,"invalid engine \"%s\"\n",
265 engine);
266 goto end;
267 }
268 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
269 {
270 BIO_printf(bio_err,"can't use that engine\n");
271 goto end;
272 }
273 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
274 /* Free our "structural" reference. */
275 ENGINE_free(e);
276 }
277 263
278 if (g && !num) 264 if (g && !num)
279 num = DEFBITS; 265 num = DEFBITS;
280 266
281#ifndef NO_DSA 267#ifndef OPENSSL_NO_DSA
282 if (dsaparam) 268 if (dsaparam)
283 { 269 {
284 if (g) 270 if (g)
@@ -305,7 +291,7 @@ bad:
305 BIO_printf(bio_err,"%ld semi-random bytes loaded\n", 291 BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
306 app_RAND_load_files(inrand)); 292 app_RAND_load_files(inrand));
307 293
308#ifndef NO_DSA 294#ifndef OPENSSL_NO_DSA
309 if (dsaparam) 295 if (dsaparam)
310 { 296 {
311 DSA *dsa; 297 DSA *dsa;
@@ -366,7 +352,7 @@ bad:
366 goto end; 352 goto end;
367 } 353 }
368 354
369#ifndef NO_DSA 355#ifndef OPENSSL_NO_DSA
370 if (dsaparam) 356 if (dsaparam)
371 { 357 {
372 DSA *dsa; 358 DSA *dsa;
@@ -419,7 +405,7 @@ bad:
419 if (outfile == NULL) 405 if (outfile == NULL)
420 { 406 {
421 BIO_set_fp(out,stdout,BIO_NOCLOSE); 407 BIO_set_fp(out,stdout,BIO_NOCLOSE);
422#ifdef VMS 408#ifdef OPENSSL_SYS_VMS
423 { 409 {
424 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 410 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
425 out = BIO_push(tmpbio, out); 411 out = BIO_push(tmpbio, out);
@@ -504,7 +490,7 @@ bad:
504 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n"); 490 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
505 printf("\t\t{ DH_free(dh); return(NULL); }\n"); 491 printf("\t\t{ DH_free(dh); return(NULL); }\n");
506 if (dh->length) 492 if (dh->length)
507 printf("\tdh->length = %d;\n", dh->length); 493 printf("\tdh->length = %ld;\n", dh->length);
508 printf("\treturn(dh);\n\t}\n"); 494 printf("\treturn(dh);\n\t}\n");
509 OPENSSL_free(data); 495 OPENSSL_free(data);
510 } 496 }
@@ -532,6 +518,7 @@ end:
532 if (in != NULL) BIO_free(in); 518 if (in != NULL) BIO_free(in);
533 if (out != NULL) BIO_free_all(out); 519 if (out != NULL) BIO_free_all(out);
534 if (dh != NULL) DH_free(dh); 520 if (dh != NULL) DH_free(dh);
521 apps_shutdown();
535 EXIT(ret); 522 EXIT(ret);
536 } 523 }
537 524
diff --git a/src/lib/libssl/src/apps/dsa.c b/src/lib/libssl/src/apps/dsa.c
index 49ca9003ac..9da1a41645 100644
--- a/src/lib/libssl/src/apps/dsa.c
+++ b/src/lib/libssl/src/apps/dsa.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DSA 59#ifndef OPENSSL_NO_DSA
60#include <stdio.h> 60#include <stdio.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include <string.h> 62#include <string.h>
@@ -68,7 +68,6 @@
68#include <openssl/evp.h> 68#include <openssl/evp.h>
69#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/pem.h> 70#include <openssl/pem.h>
71#include <openssl/engine.h>
72 71
73#undef PROG 72#undef PROG
74#define PROG dsa_main 73#define PROG dsa_main
@@ -80,6 +79,9 @@
80 * -des - encrypt output if PEM format with DES in cbc mode 79 * -des - encrypt output if PEM format with DES in cbc mode
81 * -des3 - encrypt output if PEM format 80 * -des3 - encrypt output if PEM format
82 * -idea - encrypt output if PEM format 81 * -idea - encrypt output if PEM format
82 * -aes128 - encrypt output if PEM format
83 * -aes192 - encrypt output if PEM format
84 * -aes256 - encrypt output if PEM format
83 * -text - print a text version 85 * -text - print a text version
84 * -modulus - print the DSA public key 86 * -modulus - print the DSA public key
85 */ 87 */
@@ -107,6 +109,9 @@ int MAIN(int argc, char **argv)
107 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 109 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
108 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 110 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
109 111
112 if (!load_config(bio_err, NULL))
113 goto end;
114
110 engine=NULL; 115 engine=NULL;
111 infile=NULL; 116 infile=NULL;
112 outfile=NULL; 117 outfile=NULL;
@@ -187,9 +192,13 @@ bad:
187 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 192 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
188 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 193 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
189 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 194 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
190#ifndef NO_IDEA 195#ifndef OPENSSL_NO_IDEA
191 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n"); 196 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n");
192#endif 197#endif
198#ifndef OPENSSL_NO_AES
199 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
200 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
201#endif
193 BIO_printf(bio_err," -text print the key in text\n"); 202 BIO_printf(bio_err," -text print the key in text\n");
194 BIO_printf(bio_err," -noout don't print key out\n"); 203 BIO_printf(bio_err," -noout don't print key out\n");
195 BIO_printf(bio_err," -modulus print the DSA public value\n"); 204 BIO_printf(bio_err," -modulus print the DSA public value\n");
@@ -198,23 +207,7 @@ bad:
198 207
199 ERR_load_crypto_strings(); 208 ERR_load_crypto_strings();
200 209
201 if (engine != NULL) 210 e = setup_engine(bio_err, engine, 0);
202 {
203 if((e = ENGINE_by_id(engine)) == NULL)
204 {
205 BIO_printf(bio_err,"invalid engine \"%s\"\n",
206 engine);
207 goto end;
208 }
209 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
210 {
211 BIO_printf(bio_err,"can't use that engine\n");
212 goto end;
213 }
214 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
215 /* Free our "structural" reference. */
216 ENGINE_free(e);
217 }
218 211
219 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 212 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
220 BIO_printf(bio_err, "Error getting passwords\n"); 213 BIO_printf(bio_err, "Error getting passwords\n");
@@ -262,7 +255,7 @@ bad:
262 if (outfile == NULL) 255 if (outfile == NULL)
263 { 256 {
264 BIO_set_fp(out,stdout,BIO_NOCLOSE); 257 BIO_set_fp(out,stdout,BIO_NOCLOSE);
265#ifdef VMS 258#ifdef OPENSSL_SYS_VMS
266 { 259 {
267 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 260 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
268 out = BIO_push(tmpbio, out); 261 out = BIO_push(tmpbio, out);
@@ -320,6 +313,7 @@ end:
320 if(dsa != NULL) DSA_free(dsa); 313 if(dsa != NULL) DSA_free(dsa);
321 if(passin) OPENSSL_free(passin); 314 if(passin) OPENSSL_free(passin);
322 if(passout) OPENSSL_free(passout); 315 if(passout) OPENSSL_free(passout);
316 apps_shutdown();
323 EXIT(ret); 317 EXIT(ret);
324 } 318 }
325#endif 319#endif
diff --git a/src/lib/libssl/src/apps/dsaparam.c b/src/lib/libssl/src/apps/dsaparam.c
index 34230b2cfb..2f436803e3 100644
--- a/src/lib/libssl/src/apps/dsaparam.c
+++ b/src/lib/libssl/src/apps/dsaparam.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DSA 59#ifndef OPENSSL_NO_DSA
60#include <assert.h> 60#include <assert.h>
61#include <stdio.h> 61#include <stdio.h>
62#include <stdlib.h> 62#include <stdlib.h>
@@ -69,7 +69,6 @@
69#include <openssl/dsa.h> 69#include <openssl/dsa.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/pem.h> 71#include <openssl/pem.h>
72#include <openssl/engine.h>
73 72
74#undef PROG 73#undef PROG
75#define PROG dsaparam_main 74#define PROG dsaparam_main
@@ -96,9 +95,10 @@ int MAIN(int argc, char **argv)
96 int i,badops=0,text=0; 95 int i,badops=0,text=0;
97 BIO *in=NULL,*out=NULL; 96 BIO *in=NULL,*out=NULL;
98 int informat,outformat,noout=0,C=0,ret=1; 97 int informat,outformat,noout=0,C=0,ret=1;
99 char *infile,*outfile,*prog,*inrand=NULL,*engine=NULL; 98 char *infile,*outfile,*prog,*inrand=NULL;
100 int numbits= -1,num,genkey=0; 99 int numbits= -1,num,genkey=0;
101 int need_rand=0; 100 int need_rand=0;
101 char *engine=NULL;
102 102
103 apps_startup(); 103 apps_startup();
104 104
@@ -106,6 +106,9 @@ int MAIN(int argc, char **argv)
106 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 106 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
107 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 107 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
108 108
109 if (!load_config(bio_err, NULL))
110 goto end;
111
109 infile=NULL; 112 infile=NULL;
110 outfile=NULL; 113 outfile=NULL;
111 informat=FORMAT_PEM; 114 informat=FORMAT_PEM;
@@ -136,6 +139,11 @@ int MAIN(int argc, char **argv)
136 if (--argc < 1) goto bad; 139 if (--argc < 1) goto bad;
137 outfile= *(++argv); 140 outfile= *(++argv);
138 } 141 }
142 else if(strcmp(*argv, "-engine") == 0)
143 {
144 if (--argc < 1) goto bad;
145 engine = *(++argv);
146 }
139 else if (strcmp(*argv,"-text") == 0) 147 else if (strcmp(*argv,"-text") == 0)
140 text=1; 148 text=1;
141 else if (strcmp(*argv,"-C") == 0) 149 else if (strcmp(*argv,"-C") == 0)
@@ -178,10 +186,12 @@ bad:
178 BIO_printf(bio_err," -outform arg output format - DER or PEM\n"); 186 BIO_printf(bio_err," -outform arg output format - DER or PEM\n");
179 BIO_printf(bio_err," -in arg input file\n"); 187 BIO_printf(bio_err," -in arg input file\n");
180 BIO_printf(bio_err," -out arg output file\n"); 188 BIO_printf(bio_err," -out arg output file\n");
181 BIO_printf(bio_err," -text print the key in text\n"); 189 BIO_printf(bio_err," -text print as text\n");
182 BIO_printf(bio_err," -C Output C code\n"); 190 BIO_printf(bio_err," -C Output C code\n");
183 BIO_printf(bio_err," -noout no output\n"); 191 BIO_printf(bio_err," -noout no output\n");
192 BIO_printf(bio_err," -genkey generate a DSA key\n");
184 BIO_printf(bio_err," -rand files to use for random number input\n"); 193 BIO_printf(bio_err," -rand files to use for random number input\n");
194 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
185 BIO_printf(bio_err," number number of bits to use for generating private key\n"); 195 BIO_printf(bio_err," number number of bits to use for generating private key\n");
186 goto end; 196 goto end;
187 } 197 }
@@ -209,7 +219,7 @@ bad:
209 if (outfile == NULL) 219 if (outfile == NULL)
210 { 220 {
211 BIO_set_fp(out,stdout,BIO_NOCLOSE); 221 BIO_set_fp(out,stdout,BIO_NOCLOSE);
212#ifdef VMS 222#ifdef OPENSSL_SYS_VMS
213 { 223 {
214 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 224 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
215 out = BIO_push(tmpbio, out); 225 out = BIO_push(tmpbio, out);
@@ -225,6 +235,8 @@ bad:
225 } 235 }
226 } 236 }
227 237
238 e = setup_engine(bio_err, engine, 0);
239
228 if (need_rand) 240 if (need_rand)
229 { 241 {
230 app_RAND_load_file(NULL, bio_err, (inrand != NULL)); 242 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
@@ -359,6 +371,7 @@ end:
359 if (in != NULL) BIO_free(in); 371 if (in != NULL) BIO_free(in);
360 if (out != NULL) BIO_free_all(out); 372 if (out != NULL) BIO_free_all(out);
361 if (dsa != NULL) DSA_free(dsa); 373 if (dsa != NULL) DSA_free(dsa);
374 apps_shutdown();
362 EXIT(ret); 375 EXIT(ret);
363 } 376 }
364 377
diff --git a/src/lib/libssl/src/apps/enc.c b/src/lib/libssl/src/apps/enc.c
index fcb2581b66..2c3af75170 100644
--- a/src/lib/libssl/src/apps/enc.c
+++ b/src/lib/libssl/src/apps/enc.c
@@ -66,11 +66,8 @@
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68#include <openssl/rand.h> 68#include <openssl/rand.h>
69#ifndef NO_MD5
70#include <openssl/md5.h>
71#endif
72#include <openssl/pem.h> 69#include <openssl/pem.h>
73#include <openssl/engine.h> 70#include <ctype.h>
74 71
75int set_hex(char *in,unsigned char *out,int size); 72int set_hex(char *in,unsigned char *out,int size);
76#undef SIZE 73#undef SIZE
@@ -81,6 +78,24 @@ int set_hex(char *in,unsigned char *out,int size);
81#define BSIZE (8*1024) 78#define BSIZE (8*1024)
82#define PROG enc_main 79#define PROG enc_main
83 80
81void show_ciphers(const OBJ_NAME *name,void *bio_)
82 {
83 BIO *bio=bio_;
84 static int n;
85
86 if(!islower((unsigned char)*name->name))
87 return;
88
89 BIO_printf(bio,"-%-25s",name->name);
90 if(++n == 3)
91 {
92 BIO_printf(bio,"\n");
93 n=0;
94 }
95 else
96 BIO_printf(bio," ");
97 }
98
84int MAIN(int, char **); 99int MAIN(int, char **);
85 100
86int MAIN(int argc, char **argv) 101int MAIN(int argc, char **argv)
@@ -92,7 +107,8 @@ int MAIN(int argc, char **argv)
92 unsigned char *buff=NULL,*bufsize=NULL; 107 unsigned char *buff=NULL,*bufsize=NULL;
93 int bsize=BSIZE,verbose=0; 108 int bsize=BSIZE,verbose=0;
94 int ret=1,inl; 109 int ret=1,inl;
95 unsigned char key[24],iv[MD5_DIGEST_LENGTH]; 110 int nopad = 0;
111 unsigned char key[EVP_MAX_KEY_LENGTH],iv[EVP_MAX_IV_LENGTH];
96 unsigned char salt[PKCS5_SALT_LEN]; 112 unsigned char salt[PKCS5_SALT_LEN];
97 char *str=NULL, *passarg = NULL, *pass = NULL; 113 char *str=NULL, *passarg = NULL, *pass = NULL;
98 char *hkey=NULL,*hiv=NULL,*hsalt = NULL; 114 char *hkey=NULL,*hiv=NULL,*hsalt = NULL;
@@ -101,8 +117,8 @@ int MAIN(int argc, char **argv)
101 const EVP_CIPHER *cipher=NULL,*c; 117 const EVP_CIPHER *cipher=NULL,*c;
102 char *inf=NULL,*outf=NULL; 118 char *inf=NULL,*outf=NULL;
103 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; 119 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
104#define PROG_NAME_SIZE 16 120#define PROG_NAME_SIZE 39
105 char pname[PROG_NAME_SIZE]; 121 char pname[PROG_NAME_SIZE+1];
106 char *engine = NULL; 122 char *engine = NULL;
107 123
108 apps_startup(); 124 apps_startup();
@@ -111,6 +127,9 @@ int MAIN(int argc, char **argv)
111 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 127 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
112 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 128 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
113 129
130 if (!load_config(bio_err, NULL))
131 goto end;
132
114 /* first check the program name */ 133 /* first check the program name */
115 program_name(argv[0],pname,PROG_NAME_SIZE); 134 program_name(argv[0],pname,PROG_NAME_SIZE);
116 if (strcmp(pname,"base64") == 0) 135 if (strcmp(pname,"base64") == 0)
@@ -155,6 +174,8 @@ int MAIN(int argc, char **argv)
155 printkey=1; 174 printkey=1;
156 else if (strcmp(*argv,"-v") == 0) 175 else if (strcmp(*argv,"-v") == 0)
157 verbose=1; 176 verbose=1;
177 else if (strcmp(*argv,"-nopad") == 0)
178 nopad=1;
158 else if (strcmp(*argv,"-salt") == 0) 179 else if (strcmp(*argv,"-salt") == 0)
159 nosalt=0; 180 nosalt=0;
160 else if (strcmp(*argv,"-nosalt") == 0) 181 else if (strcmp(*argv,"-nosalt") == 0)
@@ -252,94 +273,18 @@ bad:
252 BIO_printf(bio_err,"%-14s use engine e, possibly a hardware device.\n","-engine e"); 273 BIO_printf(bio_err,"%-14s use engine e, possibly a hardware device.\n","-engine e");
253 274
254 BIO_printf(bio_err,"Cipher Types\n"); 275 BIO_printf(bio_err,"Cipher Types\n");
255 BIO_printf(bio_err,"des : 56 bit key DES encryption\n"); 276 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
256 BIO_printf(bio_err,"des_ede :112 bit key ede DES encryption\n"); 277 show_ciphers,
257 BIO_printf(bio_err,"des_ede3:168 bit key ede DES encryption\n"); 278 bio_err);
258#ifndef NO_IDEA 279 BIO_printf(bio_err,"\n");
259 BIO_printf(bio_err,"idea :128 bit key IDEA encryption\n");
260#endif
261#ifndef NO_RC4
262 BIO_printf(bio_err,"rc2 :128 bit key RC2 encryption\n");
263#endif
264#ifndef NO_BF
265 BIO_printf(bio_err,"bf :128 bit key Blowfish encryption\n");
266#endif
267#ifndef NO_RC4
268 BIO_printf(bio_err," -%-5s :128 bit key RC4 encryption\n",
269 LN_rc4);
270#endif
271 280
272 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
273 LN_des_ecb,LN_des_cbc,
274 LN_des_cfb64,LN_des_ofb64);
275 BIO_printf(bio_err," -%-4s (%s)\n",
276 "des", LN_des_cbc);
277
278 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
279 LN_des_ede,LN_des_ede_cbc,
280 LN_des_ede_cfb64,LN_des_ede_ofb64);
281 BIO_printf(bio_err," -desx -none\n");
282
283
284 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
285 LN_des_ede3,LN_des_ede3_cbc,
286 LN_des_ede3_cfb64,LN_des_ede3_ofb64);
287 BIO_printf(bio_err," -%-4s (%s)\n",
288 "des3", LN_des_ede3_cbc);
289
290#ifndef NO_IDEA
291 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
292 LN_idea_ecb, LN_idea_cbc,
293 LN_idea_cfb64, LN_idea_ofb64);
294 BIO_printf(bio_err," -%-4s (%s)\n","idea",LN_idea_cbc);
295#endif
296#ifndef NO_RC2
297 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
298 LN_rc2_ecb, LN_rc2_cbc,
299 LN_rc2_cfb64, LN_rc2_ofb64);
300 BIO_printf(bio_err," -%-4s (%s)\n","rc2", LN_rc2_cbc);
301#endif
302#ifndef NO_BF
303 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
304 LN_bf_ecb, LN_bf_cbc,
305 LN_bf_cfb64, LN_bf_ofb64);
306 BIO_printf(bio_err," -%-4s (%s)\n","bf", LN_bf_cbc);
307#endif
308#ifndef NO_CAST
309 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
310 LN_cast5_ecb, LN_cast5_cbc,
311 LN_cast5_cfb64, LN_cast5_ofb64);
312 BIO_printf(bio_err," -%-4s (%s)\n","cast", LN_cast5_cbc);
313#endif
314#ifndef NO_RC5
315 BIO_printf(bio_err," -%-12s -%-12s -%-12s -%-12s",
316 LN_rc5_ecb, LN_rc5_cbc,
317 LN_rc5_cfb64, LN_rc5_ofb64);
318 BIO_printf(bio_err," -%-4s (%s)\n","rc5", LN_rc5_cbc);
319#endif
320 goto end; 281 goto end;
321 } 282 }
322 argc--; 283 argc--;
323 argv++; 284 argv++;
324 } 285 }
325 286
326 if (engine != NULL) 287 e = setup_engine(bio_err, engine, 0);
327 {
328 if((e = ENGINE_by_id(engine)) == NULL)
329 {
330 BIO_printf(bio_err,"invalid engine \"%s\"\n",
331 engine);
332 goto end;
333 }
334 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
335 {
336 BIO_printf(bio_err,"can't use that engine\n");
337 goto end;
338 }
339 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
340 /* Free our "structural" reference. */
341 ENGINE_free(e);
342 }
343 288
344 if (bufsize != NULL) 289 if (bufsize != NULL)
345 { 290 {
@@ -445,7 +390,7 @@ bad:
445 if (outf == NULL) 390 if (outf == NULL)
446 { 391 {
447 BIO_set_fp(out,stdout,BIO_NOCLOSE); 392 BIO_set_fp(out,stdout,BIO_NOCLOSE);
448#ifdef VMS 393#ifdef OPENSSL_SYS_VMS
449 { 394 {
450 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 395 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
451 out = BIO_push(tmpbio, out); 396 out = BIO_push(tmpbio, out);
@@ -483,6 +428,9 @@ bad:
483 428
484 if (cipher != NULL) 429 if (cipher != NULL)
485 { 430 {
431 /* Note that str is NULL if a key was passed on the command
432 * line, so we get no salt in that case. Is this a bug?
433 */
486 if (str != NULL) 434 if (str != NULL)
487 { 435 {
488 /* Salt handling: if encrypting generate a salt and 436 /* Salt handling: if encrypting generate a salt and
@@ -537,7 +485,7 @@ bad:
537 else 485 else
538 memset(str,0,strlen(str)); 486 memset(str,0,strlen(str));
539 } 487 }
540 if ((hiv != NULL) && !set_hex(hiv,iv,8)) 488 if ((hiv != NULL) && !set_hex(hiv,iv,sizeof iv))
541 { 489 {
542 BIO_printf(bio_err,"invalid hex iv value\n"); 490 BIO_printf(bio_err,"invalid hex iv value\n");
543 goto end; 491 goto end;
@@ -550,7 +498,7 @@ bad:
550 BIO_printf(bio_err, "iv undefined\n"); 498 BIO_printf(bio_err, "iv undefined\n");
551 goto end; 499 goto end;
552 } 500 }
553 if ((hkey != NULL) && !set_hex(hkey,key,24)) 501 if ((hkey != NULL) && !set_hex(hkey,key,sizeof key))
554 { 502 {
555 BIO_printf(bio_err,"invalid hex key value\n"); 503 BIO_printf(bio_err,"invalid hex key value\n");
556 goto end; 504 goto end;
@@ -559,6 +507,12 @@ bad:
559 if ((benc=BIO_new(BIO_f_cipher())) == NULL) 507 if ((benc=BIO_new(BIO_f_cipher())) == NULL)
560 goto end; 508 goto end;
561 BIO_set_cipher(benc,cipher,key,iv,enc); 509 BIO_set_cipher(benc,cipher,key,iv,enc);
510 if (nopad)
511 {
512 EVP_CIPHER_CTX *ctx;
513 BIO_get_cipher_ctx(benc, &ctx);
514 EVP_CIPHER_CTX_set_padding(ctx, 0);
515 }
562 if (debug) 516 if (debug)
563 { 517 {
564 BIO_set_callback(benc,BIO_debug_callback); 518 BIO_set_callback(benc,BIO_debug_callback);
@@ -631,6 +585,7 @@ end:
631 if (benc != NULL) BIO_free(benc); 585 if (benc != NULL) BIO_free(benc);
632 if (b64 != NULL) BIO_free(b64); 586 if (b64 != NULL) BIO_free(b64);
633 if(pass) OPENSSL_free(pass); 587 if(pass) OPENSSL_free(pass);
588 apps_shutdown();
634 EXIT(ret); 589 EXIT(ret);
635 } 590 }
636 591
diff --git a/src/lib/libssl/src/apps/engine.c b/src/lib/libssl/src/apps/engine.c
new file mode 100644
index 0000000000..734ecb3e5d
--- /dev/null
+++ b/src/lib/libssl/src/apps/engine.c
@@ -0,0 +1,520 @@
1/* apps/engine.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 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 <stdlib.h>
61#include <string.h>
62#ifdef OPENSSL_NO_STDIO
63#define APPS_WIN16
64#endif
65#include "apps.h"
66#include <openssl/err.h>
67#include <openssl/engine.h>
68#include <openssl/ssl.h>
69
70#undef PROG
71#define PROG engine_main
72
73static char *engine_usage[]={
74"usage: engine opts [engine ...]\n",
75" -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
76" -vv will additionally display each command's description\n",
77" -vvv will also add the input flags for each command\n",
78" -vvvv will also show internal input flags\n",
79" -c - for each engine, also list the capabilities\n",
80" -t - for each engine, check that they are really available\n",
81" -pre <cmd> - runs command 'cmd' against the ENGINE before any attempts\n",
82" to load it (if -t is used)\n",
83" -post <cmd> - runs command 'cmd' against the ENGINE after loading it\n",
84" (only used if -t is also provided)\n",
85" NB: -pre and -post will be applied to all ENGINEs supplied on the command\n",
86" line, or all supported ENGINEs if none are specified.\n",
87" Eg. '-pre \"SO_PATH:/lib/libdriver.so\"' calls command \"SO_PATH\" with\n",
88" argument \"/lib/libdriver.so\".\n",
89NULL
90};
91
92static void identity(void *ptr)
93 {
94 return;
95 }
96
97static int append_buf(char **buf, const char *s, int *size, int step)
98 {
99 int l = strlen(s);
100
101 if (*buf == NULL)
102 {
103 *size = step;
104 *buf = OPENSSL_malloc(*size);
105 if (*buf == NULL)
106 return 0;
107 **buf = '\0';
108 }
109
110 if (**buf != '\0')
111 l += 2; /* ", " */
112
113 if (strlen(*buf) + strlen(s) >= (unsigned int)*size)
114 {
115 *size += step;
116 *buf = OPENSSL_realloc(*buf, *size);
117 }
118
119 if (*buf == NULL)
120 return 0;
121
122 if (**buf != '\0')
123 strcat(*buf, ", ");
124 strcat(*buf, s);
125
126 return 1;
127 }
128
129static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
130 {
131 int started = 0, err = 0;
132 /* Indent before displaying input flags */
133 BIO_printf(bio_out, "%s%s(input flags): ", indent, indent);
134 if(flags == 0)
135 {
136 BIO_printf(bio_out, "<no flags>\n");
137 return 1;
138 }
139 /* If the object is internal, mark it in a way that shows instead of
140 * having it part of all the other flags, even if it really is. */
141 if(flags & ENGINE_CMD_FLAG_INTERNAL)
142 {
143 BIO_printf(bio_out, "[Internal] ");
144 }
145
146 if(flags & ENGINE_CMD_FLAG_NUMERIC)
147 {
148 if(started)
149 {
150 BIO_printf(bio_out, "|");
151 err = 1;
152 }
153 BIO_printf(bio_out, "NUMERIC");
154 started = 1;
155 }
156 /* Now we check that no combinations of the mutually exclusive NUMERIC,
157 * STRING, and NO_INPUT flags have been used. Future flags that can be
158 * OR'd together with these would need to added after these to preserve
159 * the testing logic. */
160 if(flags & ENGINE_CMD_FLAG_STRING)
161 {
162 if(started)
163 {
164 BIO_printf(bio_out, "|");
165 err = 1;
166 }
167 BIO_printf(bio_out, "STRING");
168 started = 1;
169 }
170 if(flags & ENGINE_CMD_FLAG_NO_INPUT)
171 {
172 if(started)
173 {
174 BIO_printf(bio_out, "|");
175 err = 1;
176 }
177 BIO_printf(bio_out, "NO_INPUT");
178 started = 1;
179 }
180 /* Check for unknown flags */
181 flags = flags & ~ENGINE_CMD_FLAG_NUMERIC &
182 ~ENGINE_CMD_FLAG_STRING &
183 ~ENGINE_CMD_FLAG_NO_INPUT &
184 ~ENGINE_CMD_FLAG_INTERNAL;
185 if(flags)
186 {
187 if(started) BIO_printf(bio_out, "|");
188 BIO_printf(bio_out, "<0x%04X>", flags);
189 }
190 if(err)
191 BIO_printf(bio_out, " <illegal flags!>");
192 BIO_printf(bio_out, "\n");
193 return 1;
194 }
195
196static int util_verbose(ENGINE *e, int verbose, BIO *bio_out, const char *indent)
197 {
198 static const int line_wrap = 78;
199 int num;
200 int ret = 0;
201 char *name = NULL;
202 char *desc = NULL;
203 int flags;
204 int xpos = 0;
205 STACK *cmds = NULL;
206 if(!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) ||
207 ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE,
208 0, NULL, NULL)) <= 0))
209 {
210#if 0
211 BIO_printf(bio_out, "%s<no control commands>\n", indent);
212#endif
213 return 1;
214 }
215
216 cmds = sk_new_null();
217
218 if(!cmds)
219 goto err;
220 do {
221 int len;
222 /* Get the command input flags */
223 if((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num,
224 NULL, NULL)) < 0)
225 goto err;
226 if (!(flags & ENGINE_CMD_FLAG_INTERNAL) || verbose >= 4)
227 {
228 /* Get the command name */
229 if((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_LEN_FROM_CMD, num,
230 NULL, NULL)) <= 0)
231 goto err;
232 if((name = OPENSSL_malloc(len + 1)) == NULL)
233 goto err;
234 if(ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_FROM_CMD, num, name,
235 NULL) <= 0)
236 goto err;
237 /* Get the command description */
238 if((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_LEN_FROM_CMD, num,
239 NULL, NULL)) < 0)
240 goto err;
241 if(len > 0)
242 {
243 if((desc = OPENSSL_malloc(len + 1)) == NULL)
244 goto err;
245 if(ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_FROM_CMD, num, desc,
246 NULL) <= 0)
247 goto err;
248 }
249 /* Now decide on the output */
250 if(xpos == 0)
251 /* Do an indent */
252 xpos = BIO_printf(bio_out, indent);
253 else
254 /* Otherwise prepend a ", " */
255 xpos += BIO_printf(bio_out, ", ");
256 if(verbose == 1)
257 {
258 /* We're just listing names, comma-delimited */
259 if((xpos > (int)strlen(indent)) &&
260 (xpos + (int)strlen(name) > line_wrap))
261 {
262 BIO_printf(bio_out, "\n");
263 xpos = BIO_printf(bio_out, indent);
264 }
265 xpos += BIO_printf(bio_out, "%s", name);
266 }
267 else
268 {
269 /* We're listing names plus descriptions */
270 BIO_printf(bio_out, "%s: %s\n", name,
271 (desc == NULL) ? "<no description>" : desc);
272 /* ... and sometimes input flags */
273 if((verbose >= 3) && !util_flags(bio_out, flags,
274 indent))
275 goto err;
276 xpos = 0;
277 }
278 }
279 OPENSSL_free(name); name = NULL;
280 if(desc) { OPENSSL_free(desc); desc = NULL; }
281 /* Move to the next command */
282 num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE,
283 num, NULL, NULL);
284 } while(num > 0);
285 if(xpos > 0)
286 BIO_printf(bio_out, "\n");
287 ret = 1;
288err:
289 if(cmds) sk_pop_free(cmds, identity);
290 if(name) OPENSSL_free(name);
291 if(desc) OPENSSL_free(desc);
292 return ret;
293 }
294
295static void util_do_cmds(ENGINE *e, STACK *cmds, BIO *bio_out, const char *indent)
296 {
297 int loop, res, num = sk_num(cmds);
298 if(num < 0)
299 {
300 BIO_printf(bio_out, "[Error]: internal stack error\n");
301 return;
302 }
303 for(loop = 0; loop < num; loop++)
304 {
305 char buf[256];
306 const char *cmd, *arg;
307 cmd = sk_value(cmds, loop);
308 res = 1; /* assume success */
309 /* Check if this command has no ":arg" */
310 if((arg = strstr(cmd, ":")) == NULL)
311 {
312 if(!ENGINE_ctrl_cmd_string(e, cmd, NULL, 0))
313 res = 0;
314 }
315 else
316 {
317 if((int)(arg - cmd) > 254)
318 {
319 BIO_printf(bio_out,"[Error]: command name too long\n");
320 return;
321 }
322 memcpy(buf, cmd, (int)(arg - cmd));
323 buf[arg-cmd] = '\0';
324 arg++; /* Move past the ":" */
325 /* Call the command with the argument */
326 if(!ENGINE_ctrl_cmd_string(e, buf, arg, 0))
327 res = 0;
328 }
329 if(res)
330 BIO_printf(bio_out, "[Success]: %s\n", cmd);
331 else
332 {
333 BIO_printf(bio_out, "[Failure]: %s\n", cmd);
334 ERR_print_errors(bio_out);
335 }
336 }
337 }
338
339int MAIN(int, char **);
340
341int MAIN(int argc, char **argv)
342 {
343 int ret=1,i;
344 char **pp;
345 int verbose=0, list_cap=0, test_avail=0;
346 ENGINE *e;
347 STACK *engines = sk_new_null();
348 STACK *pre_cmds = sk_new_null();
349 STACK *post_cmds = sk_new_null();
350 int badops=1;
351 BIO *bio_out=NULL;
352 const char *indent = " ";
353
354 apps_startup();
355 SSL_load_error_strings();
356
357 if (bio_err == NULL)
358 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
359
360 if (!load_config(bio_err, NULL))
361 goto end;
362 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
363#ifdef OPENSSL_SYS_VMS
364 {
365 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
366 bio_out = BIO_push(tmpbio, bio_out);
367 }
368#endif
369
370 argc--;
371 argv++;
372 while (argc >= 1)
373 {
374 if (strncmp(*argv,"-v",2) == 0)
375 {
376 if(strspn(*argv + 1, "v") < strlen(*argv + 1))
377 goto skip_arg_loop;
378 if((verbose=strlen(*argv + 1)) > 4)
379 goto skip_arg_loop;
380 }
381 else if (strcmp(*argv,"-c") == 0)
382 list_cap=1;
383 else if (strcmp(*argv,"-t") == 0)
384 test_avail=1;
385 else if (strcmp(*argv,"-pre") == 0)
386 {
387 argc--; argv++;
388 sk_push(pre_cmds,*argv);
389 }
390 else if (strcmp(*argv,"-post") == 0)
391 {
392 argc--; argv++;
393 sk_push(post_cmds,*argv);
394 }
395 else if ((strncmp(*argv,"-h",2) == 0) ||
396 (strcmp(*argv,"-?") == 0))
397 goto skip_arg_loop;
398 else
399 sk_push(engines,*argv);
400 argc--;
401 argv++;
402 }
403 /* Looks like everything went OK */
404 badops = 0;
405skip_arg_loop:
406
407 if (badops)
408 {
409 for (pp=engine_usage; (*pp != NULL); pp++)
410 BIO_printf(bio_err,"%s",*pp);
411 goto end;
412 }
413
414 if (sk_num(engines) == 0)
415 {
416 for(e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e))
417 {
418 sk_push(engines,(char *)ENGINE_get_id(e));
419 }
420 }
421
422 for (i=0; i<sk_num(engines); i++)
423 {
424 const char *id = sk_value(engines,i);
425 if ((e = ENGINE_by_id(id)) != NULL)
426 {
427 const char *name = ENGINE_get_name(e);
428 /* Do "id" first, then "name". Easier to auto-parse. */
429 BIO_printf(bio_out, "(%s) %s\n", id, name);
430 util_do_cmds(e, pre_cmds, bio_out, indent);
431 if (strcmp(ENGINE_get_id(e), id) != 0)
432 {
433 BIO_printf(bio_out, "Loaded: (%s) %s\n",
434 ENGINE_get_id(e), ENGINE_get_name(e));
435 }
436 if (list_cap)
437 {
438 int cap_size = 256;
439 char *cap_buf = NULL;
440 int k,n;
441 const int *nids;
442 ENGINE_CIPHERS_PTR fn_c;
443 ENGINE_DIGESTS_PTR fn_d;
444
445 if (ENGINE_get_RSA(e) != NULL
446 && !append_buf(&cap_buf, "RSA",
447 &cap_size, 256))
448 goto end;
449 if (ENGINE_get_DSA(e) != NULL
450 && !append_buf(&cap_buf, "DSA",
451 &cap_size, 256))
452 goto end;
453 if (ENGINE_get_DH(e) != NULL
454 && !append_buf(&cap_buf, "DH",
455 &cap_size, 256))
456 goto end;
457 if (ENGINE_get_RAND(e) != NULL
458 && !append_buf(&cap_buf, "RAND",
459 &cap_size, 256))
460 goto end;
461
462 fn_c = ENGINE_get_ciphers(e);
463 if(!fn_c) goto skip_ciphers;
464 n = fn_c(e, NULL, &nids, 0);
465 for(k=0 ; k < n ; ++k)
466 if(!append_buf(&cap_buf,
467 OBJ_nid2sn(nids[k]),
468 &cap_size, 256))
469 goto end;
470
471skip_ciphers:
472 fn_d = ENGINE_get_digests(e);
473 if(!fn_d) goto skip_digests;
474 n = fn_d(e, NULL, &nids, 0);
475 for(k=0 ; k < n ; ++k)
476 if(!append_buf(&cap_buf,
477 OBJ_nid2sn(nids[k]),
478 &cap_size, 256))
479 goto end;
480
481skip_digests:
482 if (cap_buf && (*cap_buf != '\0'))
483 BIO_printf(bio_out, " [%s]\n", cap_buf);
484
485 OPENSSL_free(cap_buf);
486 }
487 if(test_avail)
488 {
489 BIO_printf(bio_out, "%s", indent);
490 if (ENGINE_init(e))
491 {
492 BIO_printf(bio_out, "[ available ]\n");
493 util_do_cmds(e, post_cmds, bio_out, indent);
494 ENGINE_finish(e);
495 }
496 else
497 {
498 BIO_printf(bio_out, "[ unavailable ]\n");
499 ERR_print_errors_fp(stdout);
500 ERR_clear_error();
501 }
502 }
503 if((verbose > 0) && !util_verbose(e, verbose, bio_out, indent))
504 goto end;
505 ENGINE_free(e);
506 }
507 else
508 ERR_print_errors(bio_err);
509 }
510
511 ret=0;
512end:
513 ERR_print_errors(bio_err);
514 sk_pop_free(engines, identity);
515 sk_pop_free(pre_cmds, identity);
516 sk_pop_free(post_cmds, identity);
517 if (bio_out != NULL) BIO_free_all(bio_out);
518 apps_shutdown();
519 EXIT(ret);
520 }
diff --git a/src/lib/libssl/src/apps/errstr.c b/src/lib/libssl/src/apps/errstr.c
index e392328f93..fedb568d68 100644
--- a/src/lib/libssl/src/apps/errstr.c
+++ b/src/lib/libssl/src/apps/errstr.c
@@ -91,7 +91,7 @@ int MAIN(int argc, char **argv)
91 out=BIO_new(BIO_s_file()); 91 out=BIO_new(BIO_s_file());
92 if ((out != NULL) && BIO_set_fp(out,stdout,BIO_NOCLOSE)) 92 if ((out != NULL) && BIO_set_fp(out,stdout,BIO_NOCLOSE))
93 { 93 {
94#ifdef VMS 94#ifdef OPENSSL_SYS_VMS
95 { 95 {
96 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 96 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
97 out = BIO_push(tmpbio, out); 97 out = BIO_push(tmpbio, out);
@@ -121,5 +121,6 @@ int MAIN(int argc, char **argv)
121 ret++; 121 ret++;
122 } 122 }
123 } 123 }
124 apps_shutdown();
124 EXIT(ret); 125 EXIT(ret);
125 } 126 }
diff --git a/src/lib/libssl/src/apps/gendh.c b/src/lib/libssl/src/apps/gendh.c
index e81109eaac..f2542960bf 100644
--- a/src/lib/libssl/src/apps/gendh.c
+++ b/src/lib/libssl/src/apps/gendh.c
@@ -57,7 +57,7 @@
57 * [including the GNU Public Licence.] 57 * [including the GNU Public Licence.]
58 */ 58 */
59 59
60#ifndef NO_DH 60#ifndef OPENSSL_NO_DH
61#include <stdio.h> 61#include <stdio.h>
62#include <string.h> 62#include <string.h>
63#include <sys/types.h> 63#include <sys/types.h>
@@ -70,7 +70,6 @@
70#include <openssl/dh.h> 70#include <openssl/dh.h>
71#include <openssl/x509.h> 71#include <openssl/x509.h>
72#include <openssl/pem.h> 72#include <openssl/pem.h>
73#include <openssl/engine.h>
74 73
75#define DEFBITS 512 74#define DEFBITS 512
76#undef PROG 75#undef PROG
@@ -97,6 +96,9 @@ int MAIN(int argc, char **argv)
97 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 96 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
98 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 97 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
99 98
99 if (!load_config(bio_err, NULL))
100 goto end;
101
100 argv++; 102 argv++;
101 argc--; 103 argc--;
102 for (;;) 104 for (;;)
@@ -143,23 +145,7 @@ bad:
143 goto end; 145 goto end;
144 } 146 }
145 147
146 if (engine != NULL) 148 e = setup_engine(bio_err, engine, 0);
147 {
148 if((e = ENGINE_by_id(engine)) == NULL)
149 {
150 BIO_printf(bio_err,"invalid engine \"%s\"\n",
151 engine);
152 goto end;
153 }
154 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
155 {
156 BIO_printf(bio_err,"can't use that engine\n");
157 goto end;
158 }
159 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
160 /* Free our "structural" reference. */
161 ENGINE_free(e);
162 }
163 149
164 out=BIO_new(BIO_s_file()); 150 out=BIO_new(BIO_s_file());
165 if (out == NULL) 151 if (out == NULL)
@@ -171,7 +157,7 @@ bad:
171 if (outfile == NULL) 157 if (outfile == NULL)
172 { 158 {
173 BIO_set_fp(out,stdout,BIO_NOCLOSE); 159 BIO_set_fp(out,stdout,BIO_NOCLOSE);
174#ifdef VMS 160#ifdef OPENSSL_SYS_VMS
175 { 161 {
176 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 162 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
177 out = BIO_push(tmpbio, out); 163 out = BIO_push(tmpbio, out);
@@ -211,6 +197,7 @@ end:
211 ERR_print_errors(bio_err); 197 ERR_print_errors(bio_err);
212 if (out != NULL) BIO_free_all(out); 198 if (out != NULL) BIO_free_all(out);
213 if (dh != NULL) DH_free(dh); 199 if (dh != NULL) DH_free(dh);
200 apps_shutdown();
214 EXIT(ret); 201 EXIT(ret);
215 } 202 }
216 203
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c
index 1c0ec371d2..1e1e9f3e4c 100644
--- a/src/lib/libssl/src/apps/gendsa.c
+++ b/src/lib/libssl/src/apps/gendsa.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DSA 59#ifndef OPENSSL_NO_DSA
60#include <stdio.h> 60#include <stdio.h>
61#include <string.h> 61#include <string.h>
62#include <sys/types.h> 62#include <sys/types.h>
@@ -68,7 +68,6 @@
68#include <openssl/dsa.h> 68#include <openssl/dsa.h>
69#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/pem.h> 70#include <openssl/pem.h>
71#include <openssl/engine.h>
72 71
73#define DEFBITS 512 72#define DEFBITS 512
74#undef PROG 73#undef PROG
@@ -85,7 +84,7 @@ int MAIN(int argc, char **argv)
85 char *inrand=NULL,*dsaparams=NULL; 84 char *inrand=NULL,*dsaparams=NULL;
86 char *passargout = NULL, *passout = NULL; 85 char *passargout = NULL, *passout = NULL;
87 BIO *out=NULL,*in=NULL; 86 BIO *out=NULL,*in=NULL;
88 EVP_CIPHER *enc=NULL; 87 const EVP_CIPHER *enc=NULL;
89 char *engine=NULL; 88 char *engine=NULL;
90 89
91 apps_startup(); 90 apps_startup();
@@ -94,6 +93,9 @@ int MAIN(int argc, char **argv)
94 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 93 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
95 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 94 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
96 95
96 if (!load_config(bio_err, NULL))
97 goto end;
98
97 argv++; 99 argv++;
98 argc--; 100 argc--;
99 for (;;) 101 for (;;)
@@ -121,16 +123,24 @@ int MAIN(int argc, char **argv)
121 } 123 }
122 else if (strcmp(*argv,"-") == 0) 124 else if (strcmp(*argv,"-") == 0)
123 goto bad; 125 goto bad;
124#ifndef NO_DES 126#ifndef OPENSSL_NO_DES
125 else if (strcmp(*argv,"-des") == 0) 127 else if (strcmp(*argv,"-des") == 0)
126 enc=EVP_des_cbc(); 128 enc=EVP_des_cbc();
127 else if (strcmp(*argv,"-des3") == 0) 129 else if (strcmp(*argv,"-des3") == 0)
128 enc=EVP_des_ede3_cbc(); 130 enc=EVP_des_ede3_cbc();
129#endif 131#endif
130#ifndef NO_IDEA 132#ifndef OPENSSL_NO_IDEA
131 else if (strcmp(*argv,"-idea") == 0) 133 else if (strcmp(*argv,"-idea") == 0)
132 enc=EVP_idea_cbc(); 134 enc=EVP_idea_cbc();
133#endif 135#endif
136#ifndef OPENSSL_NO_AES
137 else if (strcmp(*argv,"-aes128") == 0)
138 enc=EVP_aes_128_cbc();
139 else if (strcmp(*argv,"-aes192") == 0)
140 enc=EVP_aes_192_cbc();
141 else if (strcmp(*argv,"-aes256") == 0)
142 enc=EVP_aes_256_cbc();
143#endif
134 else if (**argv != '-' && dsaparams == NULL) 144 else if (**argv != '-' && dsaparams == NULL)
135 { 145 {
136 dsaparams = *argv; 146 dsaparams = *argv;
@@ -146,13 +156,17 @@ int MAIN(int argc, char **argv)
146bad: 156bad:
147 BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file\n"); 157 BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file\n");
148 BIO_printf(bio_err," -out file - output the key to 'file'\n"); 158 BIO_printf(bio_err," -out file - output the key to 'file'\n");
149#ifndef NO_DES 159#ifndef OPENSSL_NO_DES
150 BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode\n"); 160 BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode\n");
151 BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); 161 BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
152#endif 162#endif
153#ifndef NO_IDEA 163#ifndef OPENSSL_NO_IDEA
154 BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n"); 164 BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n");
155#endif 165#endif
166#ifndef OPENSSL_NO_AES
167 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
168 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
169#endif
156 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); 170 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
157 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 171 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
158 BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); 172 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
@@ -162,23 +176,7 @@ bad:
162 goto end; 176 goto end;
163 } 177 }
164 178
165 if (engine != NULL) 179 e = setup_engine(bio_err, engine, 0);
166 {
167 if((e = ENGINE_by_id(engine)) == NULL)
168 {
169 BIO_printf(bio_err,"invalid engine \"%s\"\n",
170 engine);
171 goto end;
172 }
173 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
174 {
175 BIO_printf(bio_err,"can't use that engine\n");
176 goto end;
177 }
178 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
179 /* Free our "structural" reference. */
180 ENGINE_free(e);
181 }
182 180
183 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { 181 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
184 BIO_printf(bio_err, "Error getting password\n"); 182 BIO_printf(bio_err, "Error getting password\n");
@@ -207,7 +205,7 @@ bad:
207 if (outfile == NULL) 205 if (outfile == NULL)
208 { 206 {
209 BIO_set_fp(out,stdout,BIO_NOCLOSE); 207 BIO_set_fp(out,stdout,BIO_NOCLOSE);
210#ifdef VMS 208#ifdef OPENSSL_SYS_VMS
211 { 209 {
212 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 210 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
213 out = BIO_push(tmpbio, out); 211 out = BIO_push(tmpbio, out);
@@ -247,6 +245,7 @@ end:
247 if (out != NULL) BIO_free_all(out); 245 if (out != NULL) BIO_free_all(out);
248 if (dsa != NULL) DSA_free(dsa); 246 if (dsa != NULL) DSA_free(dsa);
249 if(passout) OPENSSL_free(passout); 247 if(passout) OPENSSL_free(passout);
248 apps_shutdown();
250 EXIT(ret); 249 EXIT(ret);
251 } 250 }
252#endif 251#endif
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c
index e7445e6a49..515bd7c901 100644
--- a/src/lib/libssl/src/apps/genrsa.c
+++ b/src/lib/libssl/src/apps/genrsa.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 <string.h> 61#include <string.h>
62#include <sys/types.h> 62#include <sys/types.h>
@@ -69,7 +69,7 @@
69#include <openssl/evp.h> 69#include <openssl/evp.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/pem.h> 71#include <openssl/pem.h>
72#include <openssl/engine.h> 72#include <openssl/rand.h>
73 73
74#define DEFBITS 512 74#define DEFBITS 512
75#undef PROG 75#undef PROG
@@ -86,7 +86,7 @@ int MAIN(int argc, char **argv)
86 RSA *rsa=NULL; 86 RSA *rsa=NULL;
87 int i,num=DEFBITS; 87 int i,num=DEFBITS;
88 long l; 88 long l;
89 EVP_CIPHER *enc=NULL; 89 const EVP_CIPHER *enc=NULL;
90 unsigned long f4=RSA_F4; 90 unsigned long f4=RSA_F4;
91 char *outfile=NULL; 91 char *outfile=NULL;
92 char *passargout = NULL, *passout = NULL; 92 char *passargout = NULL, *passout = NULL;
@@ -99,6 +99,9 @@ int MAIN(int argc, char **argv)
99 if (bio_err == NULL) 99 if (bio_err == NULL)
100 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 100 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
101 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 101 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
102
103 if (!load_config(bio_err, NULL))
104 goto err;
102 if ((out=BIO_new(BIO_s_file())) == NULL) 105 if ((out=BIO_new(BIO_s_file())) == NULL)
103 { 106 {
104 BIO_printf(bio_err,"unable to create BIO for output\n"); 107 BIO_printf(bio_err,"unable to create BIO for output\n");
@@ -129,16 +132,24 @@ int MAIN(int argc, char **argv)
129 if (--argc < 1) goto bad; 132 if (--argc < 1) goto bad;
130 inrand= *(++argv); 133 inrand= *(++argv);
131 } 134 }
132#ifndef NO_DES 135#ifndef OPENSSL_NO_DES
133 else if (strcmp(*argv,"-des") == 0) 136 else if (strcmp(*argv,"-des") == 0)
134 enc=EVP_des_cbc(); 137 enc=EVP_des_cbc();
135 else if (strcmp(*argv,"-des3") == 0) 138 else if (strcmp(*argv,"-des3") == 0)
136 enc=EVP_des_ede3_cbc(); 139 enc=EVP_des_ede3_cbc();
137#endif 140#endif
138#ifndef NO_IDEA 141#ifndef OPENSSL_NO_IDEA
139 else if (strcmp(*argv,"-idea") == 0) 142 else if (strcmp(*argv,"-idea") == 0)
140 enc=EVP_idea_cbc(); 143 enc=EVP_idea_cbc();
141#endif 144#endif
145#ifndef OPENSSL_NO_AES
146 else if (strcmp(*argv,"-aes128") == 0)
147 enc=EVP_aes_128_cbc();
148 else if (strcmp(*argv,"-aes192") == 0)
149 enc=EVP_aes_192_cbc();
150 else if (strcmp(*argv,"-aes256") == 0)
151 enc=EVP_aes_256_cbc();
152#endif
142 else if (strcmp(*argv,"-passout") == 0) 153 else if (strcmp(*argv,"-passout") == 0)
143 { 154 {
144 if (--argc < 1) goto bad; 155 if (--argc < 1) goto bad;
@@ -155,9 +166,13 @@ bad:
155 BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n"); 166 BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n");
156 BIO_printf(bio_err," -des encrypt the generated key with DES in cbc mode\n"); 167 BIO_printf(bio_err," -des encrypt the generated key with DES in cbc mode\n");
157 BIO_printf(bio_err," -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); 168 BIO_printf(bio_err," -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
158#ifndef NO_IDEA 169#ifndef OPENSSL_NO_IDEA
159 BIO_printf(bio_err," -idea encrypt the generated key with IDEA in cbc mode\n"); 170 BIO_printf(bio_err," -idea encrypt the generated key with IDEA in cbc mode\n");
160#endif 171#endif
172#ifndef OPENSSL_NO_AES
173 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
174 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
175#endif
161 BIO_printf(bio_err," -out file output the key to 'file\n"); 176 BIO_printf(bio_err," -out file output the key to 'file\n");
162 BIO_printf(bio_err," -passout arg output file pass phrase source\n"); 177 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
163 BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); 178 BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n");
@@ -176,28 +191,12 @@ bad:
176 goto err; 191 goto err;
177 } 192 }
178 193
179 if (engine != NULL) 194 e = setup_engine(bio_err, engine, 0);
180 {
181 if((e = ENGINE_by_id(engine)) == NULL)
182 {
183 BIO_printf(bio_err,"invalid engine \"%s\"\n",
184 engine);
185 goto err;
186 }
187 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
188 {
189 BIO_printf(bio_err,"can't use that engine\n");
190 goto err;
191 }
192 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
193 /* Free our "structural" reference. */
194 ENGINE_free(e);
195 }
196 195
197 if (outfile == NULL) 196 if (outfile == NULL)
198 { 197 {
199 BIO_set_fp(out,stdout,BIO_NOCLOSE); 198 BIO_set_fp(out,stdout,BIO_NOCLOSE);
200#ifdef VMS 199#ifdef OPENSSL_SYS_VMS
201 { 200 {
202 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 201 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
203 out = BIO_push(tmpbio, out); 202 out = BIO_push(tmpbio, out);
@@ -242,8 +241,14 @@ bad:
242 l+=rsa->e->d[i]; 241 l+=rsa->e->d[i];
243 } 242 }
244 BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l); 243 BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l);
245 if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL, passout)) 244 {
245 PW_CB_DATA cb_data;
246 cb_data.password = passout;
247 cb_data.prompt_info = outfile;
248 if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,
249 (pem_password_cb *)password_callback,&cb_data))
246 goto err; 250 goto err;
251 }
247 252
248 ret=0; 253 ret=0;
249err: 254err:
@@ -252,6 +257,7 @@ err:
252 if(passout) OPENSSL_free(passout); 257 if(passout) OPENSSL_free(passout);
253 if (ret != 0) 258 if (ret != 0)
254 ERR_print_errors(bio_err); 259 ERR_print_errors(bio_err);
260 apps_shutdown();
255 EXIT(ret); 261 EXIT(ret);
256 } 262 }
257 263
@@ -269,7 +275,7 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
269 p=n; 275 p=n;
270#endif 276#endif
271 } 277 }
272#else /* !NO_RSA */ 278#else /* !OPENSSL_NO_RSA */
273 279
274# if PEDANTIC 280# if PEDANTIC
275static void *dummy=&dummy; 281static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/apps/makeapps.com b/src/lib/libssl/src/apps/makeapps.com
index 7e9d0ac8d6..219f571d57 100644
--- a/src/lib/libssl/src/apps/makeapps.com
+++ b/src/lib/libssl/src/apps/makeapps.com
@@ -157,13 +157,13 @@ $ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;DHPARAM;ENC;PASSWD;GENDH;ERRSTR;"+-
157 "RSA;RSAUTL;DSA;DSAPARAM;"+- 157 "RSA;RSAUTL;DSA;DSAPARAM;"+-
158 "X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+- 158 "X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+-
159 "S_TIME;APPS;S_CB;S_SOCKET;APP_RAND;VERSION;SESS_ID;"+- 159 "S_TIME;APPS;S_CB;S_SOCKET;APP_RAND;VERSION;SESS_ID;"+-
160 "CIPHERS;NSEQ;PKCS12;PKCS8;SPKAC;SMIME;RAND" 160 "CIPHERS;NSEQ;PKCS12;PKCS8;SPKAC;SMIME;RAND;ENGINE;OCSP"
161$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,DHPARAM.OBJ,ENC.OBJ,PASSWD.OBJ,GENDH.OBJ,ERRSTR.OBJ,- 161$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,DHPARAM.OBJ,ENC.OBJ,PASSWD.OBJ,GENDH.OBJ,ERRSTR.OBJ,-
162 CA.OBJ,PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,- 162 CA.OBJ,PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,-
163 RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,- 163 RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,-
164 X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,- 164 X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,-
165 S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,APP_RAND.OBJ,VERSION.OBJ,SESS_ID.OBJ,- 165 S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,APP_RAND.OBJ,VERSION.OBJ,SESS_ID.OBJ,-
166 CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ,RAND.OBJ 166 CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ,RAND.OBJ,ENGINE.OBJ,OCSP.OBJ
167$ TCPIP_PROGRAMS = ",," 167$ TCPIP_PROGRAMS = ",,"
168$ IF COMPILER .EQS. "VAXC" THEN - 168$ IF COMPILER .EQS. "VAXC" THEN -
169 TCPIP_PROGRAMS = ",OPENSSL," 169 TCPIP_PROGRAMS = ",OPENSSL,"
@@ -581,6 +581,7 @@ $ CHECK_OPTIONS:
581$! 581$!
582$! Check To See If P1 Is Blank. 582$! Check To See If P1 Is Blank.
583$! 583$!
584$ P1 = "NORSAREF"
584$ IF (P1.EQS."NORSAREF") 585$ IF (P1.EQS."NORSAREF")
585$ THEN 586$ THEN
586$! 587$!
@@ -805,31 +806,7 @@ $ ENDIF
805$! 806$!
806$! Set Up Initial CC Definitions, Possibly With User Ones 807$! Set Up Initial CC Definitions, Possibly With User Ones
807$! 808$!
808$ CCDEFS = "VMS=1,MONOLITH" 809$ CCDEFS = "MONOLITH"
809$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
810$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
811$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
812$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
813$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
814$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
815$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
816$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
817$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
818$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
819$ IF F$TRNLNM("OPENSSL_NO_DES")
820$ THEN
821$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
822$ ELSE
823$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
824$ ENDIF
825$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
826$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
827$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
828$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
829$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
830$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
831$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
832$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
833$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 810$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
834$ CCEXTRAFLAGS = "" 811$ CCEXTRAFLAGS = ""
835$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 812$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -861,7 +838,8 @@ $ CC = "CC"
861$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" - 838$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
862 THEN CC = "CC/DECC" 839 THEN CC = "CC/DECC"
863$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 840$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
864 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS 841 "/NOLIST/PREFIX=ALL" + -
842 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
865$! 843$!
866$! Define The Linker Options File Name. 844$! Define The Linker Options File Name.
867$! 845$!
@@ -892,7 +870,8 @@ $ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
892$ EXIT 870$ EXIT
893$ ENDIF 871$ ENDIF
894$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 872$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
895$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 873$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
874 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
896$ CCDEFS = CCDEFS + ",""VAXC""" 875$ CCDEFS = CCDEFS + ",""VAXC"""
897$! 876$!
898$! Define <sys> As SYS$COMMON:[SYSLIB] 877$! Define <sys> As SYS$COMMON:[SYSLIB]
@@ -923,7 +902,8 @@ $!
923$! Use GNU C... 902$! Use GNU C...
924$! 903$!
925$ IF F$TYPE(GCC) .EQS. "" THEN GCC := GCC 904$ IF F$TYPE(GCC) .EQS. "" THEN GCC := GCC
926$ CC = GCC+"/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 905$ CC = GCC+"/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
906 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
927$! 907$!
928$! Define The Linker Options File Name. 908$! Define The Linker Options File Name.
929$! 909$!
@@ -1133,6 +1113,7 @@ $!
1133$! Save directory information 1113$! Save directory information
1134$! 1114$!
1135$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;" 1115$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1116$ __HERE = F$EDIT(__HERE,"UPCASE")
1136$ __TOP = __HERE - "APPS]" 1117$ __TOP = __HERE - "APPS]"
1137$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]" 1118$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1138$! 1119$!
diff --git a/src/lib/libssl/src/apps/nseq.c b/src/lib/libssl/src/apps/nseq.c
index 1d73d1ad52..93adcdfef8 100644
--- a/src/lib/libssl/src/apps/nseq.c
+++ b/src/lib/libssl/src/apps/nseq.c
@@ -121,7 +121,7 @@ int MAIN(int argc, char **argv)
121 } 121 }
122 } else { 122 } else {
123 out = BIO_new_fp(stdout, BIO_NOCLOSE); 123 out = BIO_new_fp(stdout, BIO_NOCLOSE);
124#ifdef VMS 124#ifdef OPENSSL_SYS_VMS
125 { 125 {
126 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 126 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
127 out = BIO_push(tmpbio, out); 127 out = BIO_push(tmpbio, out);
diff --git a/src/lib/libssl/src/apps/ocsp.c b/src/lib/libssl/src/apps/ocsp.c
new file mode 100644
index 0000000000..c87edbc44b
--- /dev/null
+++ b/src/lib/libssl/src/apps/ocsp.c
@@ -0,0 +1,1211 @@
1/* ocsp.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 2000.
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 <string.h>
61#include <openssl/pem.h>
62#include <openssl/ocsp.h>
63#include <openssl/err.h>
64#include <openssl/ssl.h>
65#include "apps.h"
66
67/* Maximum leeway in validity period: default 5 minutes */
68#define MAX_VALIDITY_PERIOD (5 * 60)
69
70/* CA index.txt definitions */
71#define DB_type 0
72#define DB_exp_date 1
73#define DB_rev_date 2
74#define DB_serial 3 /* index - unique */
75#define DB_file 4
76#define DB_name 5 /* index - unique for active */
77#define DB_NUMBER 6
78
79#define DB_TYPE_REV 'R'
80#define DB_TYPE_EXP 'E'
81#define DB_TYPE_VAL 'V'
82
83static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer,
84 STACK_OF(OCSP_CERTID) *ids);
85static int add_ocsp_serial(OCSP_REQUEST **req, char *serial, X509 *issuer,
86 STACK_OF(OCSP_CERTID) *ids);
87static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
88 STACK *names, STACK_OF(OCSP_CERTID) *ids,
89 long nsec, long maxage);
90
91static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, TXT_DB *db,
92 X509 *ca, X509 *rcert, EVP_PKEY *rkey,
93 STACK_OF(X509) *rother, unsigned long flags,
94 int nmin, int ndays);
95
96static char **lookup_serial(TXT_DB *db, ASN1_INTEGER *ser);
97static BIO *init_responder(char *port);
98static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port);
99static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp);
100
101#undef PROG
102#define PROG ocsp_main
103
104int MAIN(int, char **);
105
106int MAIN(int argc, char **argv)
107 {
108 ENGINE *e = NULL;
109 char **args;
110 char *host = NULL, *port = NULL, *path = "/";
111 char *reqin = NULL, *respin = NULL;
112 char *reqout = NULL, *respout = NULL;
113 char *signfile = NULL, *keyfile = NULL;
114 char *rsignfile = NULL, *rkeyfile = NULL;
115 char *outfile = NULL;
116 int add_nonce = 1, noverify = 0, use_ssl = -1;
117 OCSP_REQUEST *req = NULL;
118 OCSP_RESPONSE *resp = NULL;
119 OCSP_BASICRESP *bs = NULL;
120 X509 *issuer = NULL, *cert = NULL;
121 X509 *signer = NULL, *rsigner = NULL;
122 EVP_PKEY *key = NULL, *rkey = NULL;
123 BIO *acbio = NULL, *cbio = NULL;
124 BIO *derbio = NULL;
125 BIO *out = NULL;
126 int req_text = 0, resp_text = 0;
127 long nsec = MAX_VALIDITY_PERIOD, maxage = -1;
128 char *CAfile = NULL, *CApath = NULL;
129 X509_STORE *store = NULL;
130 SSL_CTX *ctx = NULL;
131 STACK_OF(X509) *sign_other = NULL, *verify_other = NULL, *rother = NULL;
132 char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL;
133 unsigned long sign_flags = 0, verify_flags = 0, rflags = 0;
134 int ret = 1;
135 int accept_count = -1;
136 int badarg = 0;
137 int i;
138 STACK *reqnames = NULL;
139 STACK_OF(OCSP_CERTID) *ids = NULL;
140
141 X509 *rca_cert = NULL;
142 char *ridx_filename = NULL;
143 char *rca_filename = NULL;
144 TXT_DB *rdb = NULL;
145 int nmin = 0, ndays = -1;
146
147 if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
148
149 if (!load_config(bio_err, NULL))
150 goto end;
151 SSL_load_error_strings();
152 args = argv + 1;
153 reqnames = sk_new_null();
154 ids = sk_OCSP_CERTID_new_null();
155 while (!badarg && *args && *args[0] == '-')
156 {
157 if (!strcmp(*args, "-out"))
158 {
159 if (args[1])
160 {
161 args++;
162 outfile = *args;
163 }
164 else badarg = 1;
165 }
166 else if (!strcmp(*args, "-url"))
167 {
168 if (args[1])
169 {
170 args++;
171 if (!OCSP_parse_url(*args, &host, &port, &path, &use_ssl))
172 {
173 BIO_printf(bio_err, "Error parsing URL\n");
174 badarg = 1;
175 }
176 }
177 else badarg = 1;
178 }
179 else if (!strcmp(*args, "-host"))
180 {
181 if (args[1])
182 {
183 args++;
184 host = *args;
185 }
186 else badarg = 1;
187 }
188 else if (!strcmp(*args, "-port"))
189 {
190 if (args[1])
191 {
192 args++;
193 port = *args;
194 }
195 else badarg = 1;
196 }
197 else if (!strcmp(*args, "-noverify"))
198 noverify = 1;
199 else if (!strcmp(*args, "-nonce"))
200 add_nonce = 2;
201 else if (!strcmp(*args, "-no_nonce"))
202 add_nonce = 0;
203 else if (!strcmp(*args, "-resp_no_certs"))
204 rflags |= OCSP_NOCERTS;
205 else if (!strcmp(*args, "-resp_key_id"))
206 rflags |= OCSP_RESPID_KEY;
207 else if (!strcmp(*args, "-no_certs"))
208 sign_flags |= OCSP_NOCERTS;
209 else if (!strcmp(*args, "-no_signature_verify"))
210 verify_flags |= OCSP_NOSIGS;
211 else if (!strcmp(*args, "-no_cert_verify"))
212 verify_flags |= OCSP_NOVERIFY;
213 else if (!strcmp(*args, "-no_chain"))
214 verify_flags |= OCSP_NOCHAIN;
215 else if (!strcmp(*args, "-no_cert_checks"))
216 verify_flags |= OCSP_NOCHECKS;
217 else if (!strcmp(*args, "-no_explicit"))
218 verify_flags |= OCSP_NOEXPLICIT;
219 else if (!strcmp(*args, "-trust_other"))
220 verify_flags |= OCSP_TRUSTOTHER;
221 else if (!strcmp(*args, "-no_intern"))
222 verify_flags |= OCSP_NOINTERN;
223 else if (!strcmp(*args, "-text"))
224 {
225 req_text = 1;
226 resp_text = 1;
227 }
228 else if (!strcmp(*args, "-req_text"))
229 req_text = 1;
230 else if (!strcmp(*args, "-resp_text"))
231 resp_text = 1;
232 else if (!strcmp(*args, "-reqin"))
233 {
234 if (args[1])
235 {
236 args++;
237 reqin = *args;
238 }
239 else badarg = 1;
240 }
241 else if (!strcmp(*args, "-respin"))
242 {
243 if (args[1])
244 {
245 args++;
246 respin = *args;
247 }
248 else badarg = 1;
249 }
250 else if (!strcmp(*args, "-signer"))
251 {
252 if (args[1])
253 {
254 args++;
255 signfile = *args;
256 }
257 else badarg = 1;
258 }
259 else if (!strcmp (*args, "-VAfile"))
260 {
261 if (args[1])
262 {
263 args++;
264 verify_certfile = *args;
265 verify_flags |= OCSP_TRUSTOTHER;
266 }
267 else badarg = 1;
268 }
269 else if (!strcmp(*args, "-sign_other"))
270 {
271 if (args[1])
272 {
273 args++;
274 sign_certfile = *args;
275 }
276 else badarg = 1;
277 }
278 else if (!strcmp(*args, "-verify_other"))
279 {
280 if (args[1])
281 {
282 args++;
283 verify_certfile = *args;
284 }
285 else badarg = 1;
286 }
287 else if (!strcmp (*args, "-CAfile"))
288 {
289 if (args[1])
290 {
291 args++;
292 CAfile = *args;
293 }
294 else badarg = 1;
295 }
296 else if (!strcmp (*args, "-CApath"))
297 {
298 if (args[1])
299 {
300 args++;
301 CApath = *args;
302 }
303 else badarg = 1;
304 }
305 else if (!strcmp (*args, "-validity_period"))
306 {
307 if (args[1])
308 {
309 args++;
310 nsec = atol(*args);
311 if (nsec < 0)
312 {
313 BIO_printf(bio_err,
314 "Illegal validity period %s\n",
315 *args);
316 badarg = 1;
317 }
318 }
319 else badarg = 1;
320 }
321 else if (!strcmp (*args, "-status_age"))
322 {
323 if (args[1])
324 {
325 args++;
326 maxage = atol(*args);
327 if (maxage < 0)
328 {
329 BIO_printf(bio_err,
330 "Illegal validity age %s\n",
331 *args);
332 badarg = 1;
333 }
334 }
335 else badarg = 1;
336 }
337 else if (!strcmp(*args, "-signkey"))
338 {
339 if (args[1])
340 {
341 args++;
342 keyfile = *args;
343 }
344 else badarg = 1;
345 }
346 else if (!strcmp(*args, "-reqout"))
347 {
348 if (args[1])
349 {
350 args++;
351 reqout = *args;
352 }
353 else badarg = 1;
354 }
355 else if (!strcmp(*args, "-respout"))
356 {
357 if (args[1])
358 {
359 args++;
360 respout = *args;
361 }
362 else badarg = 1;
363 }
364 else if (!strcmp(*args, "-path"))
365 {
366 if (args[1])
367 {
368 args++;
369 path = *args;
370 }
371 else badarg = 1;
372 }
373 else if (!strcmp(*args, "-issuer"))
374 {
375 if (args[1])
376 {
377 args++;
378 X509_free(issuer);
379 issuer = load_cert(bio_err, *args, FORMAT_PEM,
380 NULL, e, "issuer certificate");
381 if(!issuer) goto end;
382 }
383 else badarg = 1;
384 }
385 else if (!strcmp (*args, "-cert"))
386 {
387 if (args[1])
388 {
389 args++;
390 X509_free(cert);
391 cert = load_cert(bio_err, *args, FORMAT_PEM,
392 NULL, e, "certificate");
393 if(!cert) goto end;
394 if(!add_ocsp_cert(&req, cert, issuer, ids))
395 goto end;
396 if(!sk_push(reqnames, *args))
397 goto end;
398 }
399 else badarg = 1;
400 }
401 else if (!strcmp(*args, "-serial"))
402 {
403 if (args[1])
404 {
405 args++;
406 if(!add_ocsp_serial(&req, *args, issuer, ids))
407 goto end;
408 if(!sk_push(reqnames, *args))
409 goto end;
410 }
411 else badarg = 1;
412 }
413 else if (!strcmp(*args, "-index"))
414 {
415 if (args[1])
416 {
417 args++;
418 ridx_filename = *args;
419 }
420 else badarg = 1;
421 }
422 else if (!strcmp(*args, "-CA"))
423 {
424 if (args[1])
425 {
426 args++;
427 rca_filename = *args;
428 }
429 else badarg = 1;
430 }
431 else if (!strcmp (*args, "-nmin"))
432 {
433 if (args[1])
434 {
435 args++;
436 nmin = atol(*args);
437 if (nmin < 0)
438 {
439 BIO_printf(bio_err,
440 "Illegal update period %s\n",
441 *args);
442 badarg = 1;
443 }
444 }
445 if (ndays == -1)
446 ndays = 0;
447 else badarg = 1;
448 }
449 else if (!strcmp (*args, "-nrequest"))
450 {
451 if (args[1])
452 {
453 args++;
454 accept_count = atol(*args);
455 if (accept_count < 0)
456 {
457 BIO_printf(bio_err,
458 "Illegal accept count %s\n",
459 *args);
460 badarg = 1;
461 }
462 }
463 else badarg = 1;
464 }
465 else if (!strcmp (*args, "-ndays"))
466 {
467 if (args[1])
468 {
469 args++;
470 ndays = atol(*args);
471 if (ndays < 0)
472 {
473 BIO_printf(bio_err,
474 "Illegal update period %s\n",
475 *args);
476 badarg = 1;
477 }
478 }
479 else badarg = 1;
480 }
481 else if (!strcmp(*args, "-rsigner"))
482 {
483 if (args[1])
484 {
485 args++;
486 rsignfile = *args;
487 }
488 else badarg = 1;
489 }
490 else if (!strcmp(*args, "-rkey"))
491 {
492 if (args[1])
493 {
494 args++;
495 rkeyfile = *args;
496 }
497 else badarg = 1;
498 }
499 else if (!strcmp(*args, "-rother"))
500 {
501 if (args[1])
502 {
503 args++;
504 rcertfile = *args;
505 }
506 else badarg = 1;
507 }
508 else badarg = 1;
509 args++;
510 }
511
512 /* Have we anything to do? */
513 if (!req && !reqin && !respin && !(port && ridx_filename)) badarg = 1;
514
515 if (badarg)
516 {
517 BIO_printf (bio_err, "OCSP utility\n");
518 BIO_printf (bio_err, "Usage ocsp [options]\n");
519 BIO_printf (bio_err, "where options are\n");
520 BIO_printf (bio_err, "-out file output filename\n");
521 BIO_printf (bio_err, "-issuer file issuer certificate\n");
522 BIO_printf (bio_err, "-cert file certificate to check\n");
523 BIO_printf (bio_err, "-serial n serial number to check\n");
524 BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
525 BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
526 BIO_printf (bio_err, "-sign_certs file additional certificates to include in signed request\n");
527 BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
528 BIO_printf (bio_err, "-req_text print text form of request\n");
529 BIO_printf (bio_err, "-resp_text print text form of response\n");
530 BIO_printf (bio_err, "-text print text form of request and response\n");
531 BIO_printf (bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n");
532 BIO_printf (bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n");
533 BIO_printf (bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n");
534 BIO_printf (bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n");
535 BIO_printf (bio_err, "-nonce add OCSP nonce to request\n");
536 BIO_printf (bio_err, "-no_nonce don't add OCSP nonce to request\n");
537 BIO_printf (bio_err, "-url URL OCSP responder URL\n");
538 BIO_printf (bio_err, "-host host:n send OCSP request to host on port n\n");
539 BIO_printf (bio_err, "-path path to use in OCSP request\n");
540 BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
541 BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
542 BIO_printf (bio_err, "-VAfile file validator certificates file\n");
543 BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
544 BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
545 BIO_printf (bio_err, "-noverify don't verify response at all\n");
546 BIO_printf (bio_err, "-verify_certs file additional certificates to search for signer\n");
547 BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
548 BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
549 BIO_printf (bio_err, "-no_sig_verify don't check signature on response\n");
550 BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
551 BIO_printf (bio_err, "-no_chain don't chain verify response\n");
552 BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
553 BIO_printf (bio_err, "-port num port to run responder on\n");
554 BIO_printf (bio_err, "-index file certificate status index file\n");
555 BIO_printf (bio_err, "-CA file CA certificate\n");
556 BIO_printf (bio_err, "-rsigner file responder certificate to sign requests with\n");
557 BIO_printf (bio_err, "-rkey file responder key to sign requests with\n");
558 BIO_printf (bio_err, "-rother file other certificates to include in response\n");
559 BIO_printf (bio_err, "-resp_no_certs don't include any certificates in response\n");
560 BIO_printf (bio_err, "-nmin n number of minutes before next update\n");
561 BIO_printf (bio_err, "-ndays n number of days before next update\n");
562 BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
563 BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
564 goto end;
565 }
566
567 if(outfile) out = BIO_new_file(outfile, "w");
568 else out = BIO_new_fp(stdout, BIO_NOCLOSE);
569
570 if(!out)
571 {
572 BIO_printf(bio_err, "Error opening output file\n");
573 goto end;
574 }
575
576 if (!req && (add_nonce != 2)) add_nonce = 0;
577
578 if (!req && reqin)
579 {
580 derbio = BIO_new_file(reqin, "rb");
581 if (!derbio)
582 {
583 BIO_printf(bio_err, "Error Opening OCSP request file\n");
584 goto end;
585 }
586 req = d2i_OCSP_REQUEST_bio(derbio, NULL);
587 BIO_free(derbio);
588 if(!req)
589 {
590 BIO_printf(bio_err, "Error reading OCSP request\n");
591 goto end;
592 }
593 }
594
595 if (!req && port)
596 {
597 acbio = init_responder(port);
598 if (!acbio)
599 goto end;
600 }
601
602 if (rsignfile && !rdb)
603 {
604 if (!rkeyfile) rkeyfile = rsignfile;
605 rsigner = load_cert(bio_err, rsignfile, FORMAT_PEM,
606 NULL, e, "responder certificate");
607 if (!rsigner)
608 {
609 BIO_printf(bio_err, "Error loading responder certificate\n");
610 goto end;
611 }
612 rca_cert = load_cert(bio_err, rca_filename, FORMAT_PEM,
613 NULL, e, "CA certificate");
614 if (rcertfile)
615 {
616 rother = load_certs(bio_err, sign_certfile, FORMAT_PEM,
617 NULL, e, "responder other certificates");
618 if (!sign_other) goto end;
619 }
620 rkey = load_key(bio_err, rkeyfile, FORMAT_PEM, NULL, NULL,
621 "responder private key");
622 if (!rkey)
623 goto end;
624 }
625 if(acbio)
626 BIO_printf(bio_err, "Waiting for OCSP client connections...\n");
627
628 redo_accept:
629
630 if (acbio)
631 {
632 if (!do_responder(&req, &cbio, acbio, port))
633 goto end;
634 if (!req)
635 {
636 resp = OCSP_response_create(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, NULL);
637 send_ocsp_response(cbio, resp);
638 goto done_resp;
639 }
640 }
641
642 if (!req && (signfile || reqout || host || add_nonce || ridx_filename))
643 {
644 BIO_printf(bio_err, "Need an OCSP request for this operation!\n");
645 goto end;
646 }
647
648 if (req && add_nonce) OCSP_request_add1_nonce(req, NULL, -1);
649
650 if (signfile)
651 {
652 if (!keyfile) keyfile = signfile;
653 signer = load_cert(bio_err, signfile, FORMAT_PEM,
654 NULL, e, "signer certificate");
655 if (!signer)
656 {
657 BIO_printf(bio_err, "Error loading signer certificate\n");
658 goto end;
659 }
660 if (sign_certfile)
661 {
662 sign_other = load_certs(bio_err, sign_certfile, FORMAT_PEM,
663 NULL, e, "signer certificates");
664 if (!sign_other) goto end;
665 }
666 key = load_key(bio_err, keyfile, FORMAT_PEM, NULL, NULL,
667 "signer private key");
668 if (!key)
669 goto end;
670 if (!OCSP_request_sign(req, signer, key, EVP_sha1(), sign_other, sign_flags))
671 {
672 BIO_printf(bio_err, "Error signing OCSP request\n");
673 goto end;
674 }
675 }
676
677 if (req_text && req) OCSP_REQUEST_print(out, req, 0);
678
679 if (ridx_filename && (!rkey || !rsigner || !rca_cert))
680 {
681 BIO_printf(bio_err, "Need a responder certificate, key and CA for this operation!\n");
682 goto end;
683 }
684
685 if (ridx_filename && !rdb)
686 {
687 BIO *db_bio = NULL;
688 db_bio = BIO_new_file(ridx_filename, "r");
689 if (!db_bio)
690 {
691 BIO_printf(bio_err, "Error opening index file %s\n", ridx_filename);
692 goto end;
693 }
694 rdb = TXT_DB_read(db_bio, DB_NUMBER);
695 BIO_free(db_bio);
696 if (!rdb)
697 {
698 BIO_printf(bio_err, "Error reading index file %s\n", ridx_filename);
699 goto end;
700 }
701 if (!make_serial_index(rdb))
702 goto end;
703 }
704
705 if (rdb)
706 {
707 i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey, rother, rflags, nmin, ndays);
708 if (cbio)
709 send_ocsp_response(cbio, resp);
710 }
711 else if (host)
712 {
713 cbio = BIO_new_connect(host);
714 if (!cbio)
715 {
716 BIO_printf(bio_err, "Error creating connect BIO\n");
717 goto end;
718 }
719 if (port) BIO_set_conn_port(cbio, port);
720 if (use_ssl == 1)
721 {
722 BIO *sbio;
723 ctx = SSL_CTX_new(SSLv23_client_method());
724 SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
725 sbio = BIO_new_ssl(ctx, 1);
726 cbio = BIO_push(sbio, cbio);
727 }
728 if (BIO_do_connect(cbio) <= 0)
729 {
730 BIO_printf(bio_err, "Error connecting BIO\n");
731 goto end;
732 }
733 resp = OCSP_sendreq_bio(cbio, path, req);
734 BIO_free_all(cbio);
735 cbio = NULL;
736 if (!resp)
737 {
738 BIO_printf(bio_err, "Error querying OCSP responsder\n");
739 goto end;
740 }
741 }
742 else if (respin)
743 {
744 derbio = BIO_new_file(respin, "rb");
745 if (!derbio)
746 {
747 BIO_printf(bio_err, "Error Opening OCSP response file\n");
748 goto end;
749 }
750 resp = d2i_OCSP_RESPONSE_bio(derbio, NULL);
751 BIO_free(derbio);
752 if(!resp)
753 {
754 BIO_printf(bio_err, "Error reading OCSP response\n");
755 goto end;
756 }
757
758 }
759 else
760 {
761 ret = 0;
762 goto end;
763 }
764
765 done_resp:
766
767 if (respout)
768 {
769 derbio = BIO_new_file(respout, "wb");
770 if(!derbio)
771 {
772 BIO_printf(bio_err, "Error opening file %s\n", respout);
773 goto end;
774 }
775 i2d_OCSP_RESPONSE_bio(derbio, resp);
776 BIO_free(derbio);
777 }
778
779 i = OCSP_response_status(resp);
780
781 if (i != OCSP_RESPONSE_STATUS_SUCCESSFUL)
782 {
783 BIO_printf(out, "Responder Error: %s (%ld)\n",
784 OCSP_response_status_str(i), i);
785 ret = 0;
786 goto end;
787 }
788
789 if (resp_text) OCSP_RESPONSE_print(out, resp, 0);
790
791 /* If running as responder don't verify our own response */
792 if (cbio)
793 {
794 if (accept_count > 0)
795 accept_count--;
796 /* Redo if more connections needed */
797 if (accept_count)
798 {
799 BIO_free_all(cbio);
800 cbio = NULL;
801 OCSP_REQUEST_free(req);
802 req = NULL;
803 OCSP_RESPONSE_free(resp);
804 resp = NULL;
805 goto redo_accept;
806 }
807 goto end;
808 }
809
810 if (!store)
811 store = setup_verify(bio_err, CAfile, CApath);
812 if (verify_certfile)
813 {
814 verify_other = load_certs(bio_err, verify_certfile, FORMAT_PEM,
815 NULL, e, "validator certificate");
816 if (!verify_other) goto end;
817 }
818
819 bs = OCSP_response_get1_basic(resp);
820
821 if (!bs)
822 {
823 BIO_printf(bio_err, "Error parsing response\n");
824 goto end;
825 }
826
827 if (!noverify)
828 {
829 if (req && ((i = OCSP_check_nonce(req, bs)) <= 0))
830 {
831 if (i == -1)
832 BIO_printf(bio_err, "WARNING: no nonce in response\n");
833 else
834 {
835 BIO_printf(bio_err, "Nonce Verify error\n");
836 goto end;
837 }
838 }
839
840 i = OCSP_basic_verify(bs, verify_other, store, verify_flags);
841 if (i < 0) i = OCSP_basic_verify(bs, NULL, store, 0);
842
843 if(i <= 0)
844 {
845 BIO_printf(bio_err, "Response Verify Failure\n", i);
846 ERR_print_errors(bio_err);
847 }
848 else
849 BIO_printf(bio_err, "Response verify OK\n");
850
851 }
852
853 if (!print_ocsp_summary(out, bs, req, reqnames, ids, nsec, maxage))
854 goto end;
855
856 ret = 0;
857
858end:
859 ERR_print_errors(bio_err);
860 X509_free(signer);
861 X509_STORE_free(store);
862 EVP_PKEY_free(key);
863 EVP_PKEY_free(rkey);
864 X509_free(issuer);
865 X509_free(cert);
866 X509_free(rsigner);
867 X509_free(rca_cert);
868 TXT_DB_free(rdb);
869 BIO_free_all(cbio);
870 BIO_free_all(acbio);
871 BIO_free(out);
872 OCSP_REQUEST_free(req);
873 OCSP_RESPONSE_free(resp);
874 OCSP_BASICRESP_free(bs);
875 sk_free(reqnames);
876 sk_OCSP_CERTID_free(ids);
877 sk_X509_pop_free(sign_other, X509_free);
878 sk_X509_pop_free(verify_other, X509_free);
879
880 if (use_ssl != -1)
881 {
882 OPENSSL_free(host);
883 OPENSSL_free(port);
884 OPENSSL_free(path);
885 SSL_CTX_free(ctx);
886 }
887
888 EXIT(ret);
889}
890
891static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer,
892 STACK_OF(OCSP_CERTID) *ids)
893 {
894 OCSP_CERTID *id;
895 if(!issuer)
896 {
897 BIO_printf(bio_err, "No issuer certificate specified\n");
898 return 0;
899 }
900 if(!*req) *req = OCSP_REQUEST_new();
901 if(!*req) goto err;
902 id = OCSP_cert_to_id(NULL, cert, issuer);
903 if(!id || !sk_OCSP_CERTID_push(ids, id)) goto err;
904 if(!OCSP_request_add0_id(*req, id)) goto err;
905 return 1;
906
907 err:
908 BIO_printf(bio_err, "Error Creating OCSP request\n");
909 return 0;
910 }
911
912static int add_ocsp_serial(OCSP_REQUEST **req, char *serial, X509 *issuer,
913 STACK_OF(OCSP_CERTID) *ids)
914 {
915 OCSP_CERTID *id;
916 X509_NAME *iname;
917 ASN1_BIT_STRING *ikey;
918 ASN1_INTEGER *sno;
919 if(!issuer)
920 {
921 BIO_printf(bio_err, "No issuer certificate specified\n");
922 return 0;
923 }
924 if(!*req) *req = OCSP_REQUEST_new();
925 if(!*req) goto err;
926 iname = X509_get_subject_name(issuer);
927 ikey = X509_get0_pubkey_bitstr(issuer);
928 sno = s2i_ASN1_INTEGER(NULL, serial);
929 if(!sno)
930 {
931 BIO_printf(bio_err, "Error converting serial number %s\n", serial);
932 return 0;
933 }
934 id = OCSP_cert_id_new(EVP_sha1(), iname, ikey, sno);
935 ASN1_INTEGER_free(sno);
936 if(!id || !sk_OCSP_CERTID_push(ids, id)) goto err;
937 if(!OCSP_request_add0_id(*req, id)) goto err;
938 return 1;
939
940 err:
941 BIO_printf(bio_err, "Error Creating OCSP request\n");
942 return 0;
943 }
944
945static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,
946 STACK *names, STACK_OF(OCSP_CERTID) *ids,
947 long nsec, long maxage)
948 {
949 OCSP_CERTID *id;
950 char *name;
951 int i;
952
953 int status, reason;
954
955 ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd;
956
957 if (!bs || !req || !sk_num(names) || !sk_OCSP_CERTID_num(ids))
958 return 1;
959
960 for (i = 0; i < sk_OCSP_CERTID_num(ids); i++)
961 {
962 id = sk_OCSP_CERTID_value(ids, i);
963 name = sk_value(names, i);
964 BIO_printf(out, "%s: ", name);
965
966 if(!OCSP_resp_find_status(bs, id, &status, &reason,
967 &rev, &thisupd, &nextupd))
968 {
969 BIO_puts(out, "ERROR: No Status found.\n");
970 continue;
971 }
972
973 /* Check validity: if invalid write to output BIO so we
974 * know which response this refers to.
975 */
976 if (!OCSP_check_validity(thisupd, nextupd, nsec, maxage))
977 {
978 BIO_puts(out, "WARNING: Status times invalid.\n");
979 ERR_print_errors(out);
980 }
981 BIO_printf(out, "%s\n", OCSP_cert_status_str(status));
982
983 BIO_puts(out, "\tThis Update: ");
984 ASN1_GENERALIZEDTIME_print(out, thisupd);
985 BIO_puts(out, "\n");
986
987 if(nextupd)
988 {
989 BIO_puts(out, "\tNext Update: ");
990 ASN1_GENERALIZEDTIME_print(out, nextupd);
991 BIO_puts(out, "\n");
992 }
993
994 if (status != V_OCSP_CERTSTATUS_REVOKED)
995 continue;
996
997 if (reason != -1)
998 BIO_printf(out, "\tReason: %s\n",
999 OCSP_crl_reason_str(reason));
1000
1001 BIO_puts(out, "\tRevocation Time: ");
1002 ASN1_GENERALIZEDTIME_print(out, rev);
1003 BIO_puts(out, "\n");
1004 }
1005
1006 return 1;
1007 }
1008
1009
1010static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req, TXT_DB *db,
1011 X509 *ca, X509 *rcert, EVP_PKEY *rkey,
1012 STACK_OF(X509) *rother, unsigned long flags,
1013 int nmin, int ndays)
1014 {
1015 ASN1_TIME *thisupd = NULL, *nextupd = NULL;
1016 OCSP_CERTID *cid, *ca_id = NULL;
1017 OCSP_BASICRESP *bs = NULL;
1018 int i, id_count, ret = 1;
1019
1020
1021 id_count = OCSP_request_onereq_count(req);
1022
1023 if (id_count <= 0)
1024 {
1025 *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, NULL);
1026 goto end;
1027 }
1028
1029 ca_id = OCSP_cert_to_id(EVP_sha1(), NULL, ca);
1030
1031 bs = OCSP_BASICRESP_new();
1032 thisupd = X509_gmtime_adj(NULL, 0);
1033 if (ndays != -1)
1034 nextupd = X509_gmtime_adj(NULL, nmin * 60 + ndays * 3600 * 24 );
1035
1036 /* Examine each certificate id in the request */
1037 for (i = 0; i < id_count; i++)
1038 {
1039 OCSP_ONEREQ *one;
1040 ASN1_INTEGER *serial;
1041 char **inf;
1042 one = OCSP_request_onereq_get0(req, i);
1043 cid = OCSP_onereq_get0_id(one);
1044 /* Is this request about our CA? */
1045 if (OCSP_id_issuer_cmp(ca_id, cid))
1046 {
1047 OCSP_basic_add1_status(bs, cid,
1048 V_OCSP_CERTSTATUS_UNKNOWN,
1049 0, NULL,
1050 thisupd, nextupd);
1051 continue;
1052 }
1053 OCSP_id_get0_info(NULL, NULL, NULL, &serial, cid);
1054 inf = lookup_serial(db, serial);
1055 if (!inf)
1056 OCSP_basic_add1_status(bs, cid,
1057 V_OCSP_CERTSTATUS_UNKNOWN,
1058 0, NULL,
1059 thisupd, nextupd);
1060 else if (inf[DB_type][0] == DB_TYPE_VAL)
1061 OCSP_basic_add1_status(bs, cid,
1062 V_OCSP_CERTSTATUS_GOOD,
1063 0, NULL,
1064 thisupd, nextupd);
1065 else if (inf[DB_type][0] == DB_TYPE_REV)
1066 {
1067 ASN1_OBJECT *inst = NULL;
1068 ASN1_TIME *revtm = NULL;
1069 ASN1_GENERALIZEDTIME *invtm = NULL;
1070 OCSP_SINGLERESP *single;
1071 int reason = -1;
1072 unpack_revinfo(&revtm, &reason, &inst, &invtm, inf[DB_rev_date]);
1073 single = OCSP_basic_add1_status(bs, cid,
1074 V_OCSP_CERTSTATUS_REVOKED,
1075 reason, revtm,
1076 thisupd, nextupd);
1077 if (invtm)
1078 OCSP_SINGLERESP_add1_ext_i2d(single, NID_invalidity_date, invtm, 0, 0);
1079 else if (inst)
1080 OCSP_SINGLERESP_add1_ext_i2d(single, NID_hold_instruction_code, inst, 0, 0);
1081 ASN1_OBJECT_free(inst);
1082 ASN1_TIME_free(revtm);
1083 ASN1_GENERALIZEDTIME_free(invtm);
1084 }
1085 }
1086
1087 OCSP_copy_nonce(bs, req);
1088
1089 OCSP_basic_sign(bs, rcert, rkey, EVP_sha1(), rother, flags);
1090
1091 *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_SUCCESSFUL, bs);
1092
1093 end:
1094 ASN1_TIME_free(thisupd);
1095 ASN1_TIME_free(nextupd);
1096 OCSP_CERTID_free(ca_id);
1097 OCSP_BASICRESP_free(bs);
1098 return ret;
1099
1100 }
1101
1102static char **lookup_serial(TXT_DB *db, ASN1_INTEGER *ser)
1103 {
1104 int i;
1105 BIGNUM *bn = NULL;
1106 char *itmp, *row[DB_NUMBER],**rrow;
1107 for (i = 0; i < DB_NUMBER; i++) row[i] = NULL;
1108 bn = ASN1_INTEGER_to_BN(ser,NULL);
1109 itmp = BN_bn2hex(bn);
1110 row[DB_serial] = itmp;
1111 BN_free(bn);
1112 rrow=TXT_DB_get_by_index(db,DB_serial,row);
1113 OPENSSL_free(itmp);
1114 return rrow;
1115 }
1116
1117/* Quick and dirty OCSP server: read in and parse input request */
1118
1119static BIO *init_responder(char *port)
1120 {
1121 BIO *acbio = NULL, *bufbio = NULL;
1122 bufbio = BIO_new(BIO_f_buffer());
1123 if (!bufbio)
1124 goto err;
1125 acbio = BIO_new_accept(port);
1126 if (!acbio)
1127 goto err;
1128 BIO_set_accept_bios(acbio, bufbio);
1129 bufbio = NULL;
1130
1131 if (BIO_do_accept(acbio) <= 0)
1132 {
1133 BIO_printf(bio_err, "Error setting up accept BIO\n");
1134 ERR_print_errors(bio_err);
1135 goto err;
1136 }
1137
1138 return acbio;
1139
1140 err:
1141 BIO_free_all(acbio);
1142 BIO_free(bufbio);
1143 return NULL;
1144 }
1145
1146static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, char *port)
1147 {
1148 int have_post = 0, len;
1149 OCSP_REQUEST *req = NULL;
1150 char inbuf[1024];
1151 BIO *cbio = NULL;
1152
1153 if (BIO_do_accept(acbio) <= 0)
1154 {
1155 BIO_printf(bio_err, "Error accepting connection\n");
1156 ERR_print_errors(bio_err);
1157 return 0;
1158 }
1159
1160 cbio = BIO_pop(acbio);
1161 *pcbio = cbio;
1162
1163 for(;;)
1164 {
1165 len = BIO_gets(cbio, inbuf, 1024);
1166 if (len <= 0)
1167 return 1;
1168 /* Look for "POST" signalling start of query */
1169 if (!have_post)
1170 {
1171 if(strncmp(inbuf, "POST", 4))
1172 {
1173 BIO_printf(bio_err, "Invalid request\n");
1174 return 1;
1175 }
1176 have_post = 1;
1177 }
1178 /* Look for end of headers */
1179 if ((inbuf[0] == '\r') || (inbuf[0] == '\n'))
1180 break;
1181 }
1182
1183 /* Try to read OCSP request */
1184
1185 req = d2i_OCSP_REQUEST_bio(cbio, NULL);
1186
1187 if (!req)
1188 {
1189 BIO_printf(bio_err, "Error parsing OCSP request\n");
1190 ERR_print_errors(bio_err);
1191 }
1192
1193 *preq = req;
1194
1195 return 1;
1196
1197 }
1198
1199static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
1200 {
1201 char http_resp[] =
1202 "HTTP/1.0 200 OK\r\nContent-type: application/ocsp-response\r\n"
1203 "Content-Length: %d\r\n\r\n";
1204 if (!cbio)
1205 return 0;
1206 BIO_printf(cbio, http_resp, i2d_OCSP_RESPONSE(resp, NULL));
1207 i2d_OCSP_RESPONSE_bio(cbio, resp);
1208 BIO_flush(cbio);
1209 return 1;
1210 }
1211
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 4f61006b73..c17458ef7c 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -55,6 +55,60 @@
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 */
111
58 112
59#include <stdio.h> 113#include <stdio.h>
60#include <string.h> 114#include <string.h>
@@ -67,17 +121,25 @@
67#include <openssl/x509.h> 121#include <openssl/x509.h>
68#include <openssl/pem.h> 122#include <openssl/pem.h>
69#include <openssl/ssl.h> 123#include <openssl/ssl.h>
124#include <openssl/engine.h>
70#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ 125#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
71#include "apps.h" 126#include "apps.h"
72#include "progs.h" 127#include "progs.h"
73#include "s_apps.h" 128#include "s_apps.h"
74#include <openssl/err.h> 129#include <openssl/err.h>
75 130
76static unsigned long MS_CALLBACK hash(FUNCTION *a); 131/* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the
77static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); 132 * base prototypes (we cast each variable inside the function to the required
133 * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
134 * functions. */
135
136/* static unsigned long MS_CALLBACK hash(FUNCTION *a); */
137static unsigned long MS_CALLBACK hash(const void *a_void);
138/* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */
139static int MS_CALLBACK cmp(const void *a_void,const void *b_void);
78static LHASH *prog_init(void ); 140static LHASH *prog_init(void );
79static int do_cmd(LHASH *prog,int argc,char *argv[]); 141static int do_cmd(LHASH *prog,int argc,char *argv[]);
80LHASH *config=NULL; 142CONF *config=NULL;
81char *default_config_file=NULL; 143char *default_config_file=NULL;
82 144
83/* Make sure there is only one when MONOLITH is defined */ 145/* Make sure there is only one when MONOLITH is defined */
@@ -85,11 +147,76 @@ char *default_config_file=NULL;
85BIO *bio_err=NULL; 147BIO *bio_err=NULL;
86#endif 148#endif
87 149
150
151static void lock_dbg_cb(int mode, int type, const char *file, int line)
152 {
153 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
154 const char *errstr = NULL;
155 int rw;
156
157 rw = mode & (CRYPTO_READ|CRYPTO_WRITE);
158 if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE)))
159 {
160 errstr = "invalid mode";
161 goto err;
162 }
163
164 if (type < 0 || type > CRYPTO_NUM_LOCKS)
165 {
166 errstr = "type out of bounds";
167 goto err;
168 }
169
170 if (mode & CRYPTO_LOCK)
171 {
172 if (modes[type])
173 {
174 errstr = "already locked";
175 /* must not happen in a single-threaded program
176 * (would deadlock) */
177 goto err;
178 }
179
180 modes[type] = rw;
181 }
182 else if (mode & CRYPTO_UNLOCK)
183 {
184 if (!modes[type])
185 {
186 errstr = "not locked";
187 goto err;
188 }
189
190 if (modes[type] != rw)
191 {
192 errstr = (rw == CRYPTO_READ) ?
193 "CRYPTO_r_unlock on write lock" :
194 "CRYPTO_w_unlock on read lock";
195 }
196
197 modes[type] = 0;
198 }
199 else
200 {
201 errstr = "invalid mode";
202 goto err;
203 }
204
205 err:
206 if (errstr)
207 {
208 /* we cannot use bio_err here */
209 fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
210 errstr, mode, type, file, line);
211 }
212 }
213
214
88int main(int Argc, char *Argv[]) 215int main(int Argc, char *Argv[])
89 { 216 {
90 ARGS arg; 217 ARGS arg;
91#define PROG_NAME_SIZE 16 218#define PROG_NAME_SIZE 39
92 char pname[PROG_NAME_SIZE]; 219 char pname[PROG_NAME_SIZE+1];
93 FUNCTION f,*fp; 220 FUNCTION f,*fp;
94 MS_STATIC char *prompt,buf[1024],config_name[256]; 221 MS_STATIC char *prompt,buf[1024],config_name[256];
95 int n,i,ret=0; 222 int n,i,ret=0;
@@ -101,18 +228,34 @@ int main(int Argc, char *Argv[])
101 arg.data=NULL; 228 arg.data=NULL;
102 arg.count=0; 229 arg.count=0;
103 230
104 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) 231 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */
105 CRYPTO_malloc_debug_init(); 232 {
233 if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))
234 {
235 CRYPTO_malloc_debug_init();
236 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
237 }
238 else
239 {
240 /* OPENSSL_DEBUG_MEMORY=off */
241 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
242 }
243 }
106 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 244 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
107 245
246#if 0
247 if (getenv("OPENSSL_DEBUG_LOCKING") != NULL)
248#endif
249 {
250 CRYPTO_set_locking_callback(lock_dbg_cb);
251 }
252
108 apps_startup(); 253 apps_startup();
109 254
110 if (bio_err == NULL) 255 if (bio_err == NULL)
111 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 256 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
112 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 257 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
113 258
114 ERR_load_crypto_strings();
115
116 /* Lets load up our environment a little */ 259 /* Lets load up our environment a little */
117 p=getenv("OPENSSL_CONF"); 260 p=getenv("OPENSSL_CONF");
118 if (p == NULL) 261 if (p == NULL)
@@ -120,7 +263,7 @@ int main(int Argc, char *Argv[])
120 if (p == NULL) 263 if (p == NULL)
121 { 264 {
122 strcpy(config_name,X509_get_default_cert_area()); 265 strcpy(config_name,X509_get_default_cert_area());
123#ifndef VMS 266#ifndef OPENSSL_SYS_VMS
124 strcat(config_name,"/"); 267 strcat(config_name,"/");
125#endif 268#endif
126 strcat(config_name,OPENSSL_CONF); 269 strcat(config_name,OPENSSL_CONF);
@@ -129,8 +272,14 @@ int main(int Argc, char *Argv[])
129 272
130 default_config_file=p; 273 default_config_file=p;
131 274
132 config=CONF_load(config,p,&errline); 275 config=NCONF_new(NULL);
133 if (config == NULL) ERR_clear_error(); 276 i=NCONF_load(config,p,&errline);
277 if (i == 0)
278 {
279 NCONF_free(config);
280 config = NULL;
281 ERR_clear_error();
282 }
134 283
135 prog=prog_init(); 284 prog=prog_init();
136 285
@@ -199,16 +348,14 @@ int main(int Argc, char *Argv[])
199end: 348end:
200 if (config != NULL) 349 if (config != NULL)
201 { 350 {
202 CONF_free(config); 351 NCONF_free(config);
203 config=NULL; 352 config=NULL;
204 } 353 }
205 if (prog != NULL) lh_free(prog); 354 if (prog != NULL) lh_free(prog);
206 if (arg.data != NULL) OPENSSL_free(arg.data); 355 if (arg.data != NULL) OPENSSL_free(arg.data);
207 ERR_remove_state(0);
208 356
209 EVP_cleanup(); 357 apps_shutdown();
210 ERR_free_strings(); 358
211
212 CRYPTO_mem_leaks(bio_err); 359 CRYPTO_mem_leaks(bio_err);
213 if (bio_err != NULL) 360 if (bio_err != NULL)
214 { 361 {
@@ -238,7 +385,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
238 else if ((strncmp(argv[0],"no-",3)) == 0) 385 else if ((strncmp(argv[0],"no-",3)) == 0)
239 { 386 {
240 BIO *bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE); 387 BIO *bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
241#ifdef VMS 388#ifdef OPENSSL_SYS_VMS
242 { 389 {
243 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 390 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
244 bio_stdout = BIO_push(tmpbio, bio_stdout); 391 bio_stdout = BIO_push(tmpbio, bio_stdout);
@@ -275,7 +422,7 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
275 else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */ 422 else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */
276 list_type = FUNC_TYPE_CIPHER; 423 list_type = FUNC_TYPE_CIPHER;
277 bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE); 424 bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
278#ifdef VMS 425#ifdef OPENSSL_SYS_VMS
279 { 426 {
280 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 427 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
281 bio_stdout = BIO_push(tmpbio, bio_stdout); 428 bio_stdout = BIO_push(tmpbio, bio_stdout);
@@ -350,19 +497,23 @@ static LHASH *prog_init(void)
350 ; 497 ;
351 qsort(functions,i,sizeof *functions,SortFnByName); 498 qsort(functions,i,sizeof *functions,SortFnByName);
352 499
353 if ((ret=lh_new(hash,cmp)) == NULL) return(NULL); 500 if ((ret=lh_new(hash, cmp)) == NULL)
501 return(NULL);
354 502
355 for (f=functions; f->name != NULL; f++) 503 for (f=functions; f->name != NULL; f++)
356 lh_insert(ret,f); 504 lh_insert(ret,f);
357 return(ret); 505 return(ret);
358 } 506 }
359 507
360static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) 508/* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */
509static int MS_CALLBACK cmp(const void *a_void, const void *b_void)
361 { 510 {
362 return(strncmp(a->name,b->name,8)); 511 return(strncmp(((FUNCTION *)a_void)->name,
512 ((FUNCTION *)b_void)->name,8));
363 } 513 }
364 514
365static unsigned long MS_CALLBACK hash(FUNCTION *a) 515/* static unsigned long MS_CALLBACK hash(FUNCTION *a) */
516static unsigned long MS_CALLBACK hash(const void *a_void)
366 { 517 {
367 return(lh_strhash(a->name)); 518 return(lh_strhash(((FUNCTION *)a_void)->name));
368 } 519 }
diff --git a/src/lib/libssl/src/apps/openssl.cnf b/src/lib/libssl/src/apps/openssl.cnf
index dbe8cbefe0..eca51c3322 100644
--- a/src/lib/libssl/src/apps/openssl.cnf
+++ b/src/lib/libssl/src/apps/openssl.cnf
@@ -48,6 +48,14 @@ RANDFILE = $dir/private/.rand # private random number file
48 48
49x509_extensions = usr_cert # The extentions to add to the cert 49x509_extensions = usr_cert # The extentions to add to the cert
50 50
51# Comment out the following two lines for the "traditional"
52# (and highly broken) format.
53name_opt = ca_default # Subject Name options
54cert_opt = ca_default # Certificate field options
55
56# Extension copying option: use with caution.
57# copy_extensions = copy
58
51# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs 59# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
52# so this is commented out by default to leave a V1 CRL. 60# so this is commented out by default to leave a V1 CRL.
53# crl_extensions = crl_ext 61# crl_extensions = crl_ext
@@ -132,7 +140,7 @@ commonName = Common Name (eg, YOUR name)
132commonName_max = 64 140commonName_max = 64
133 141
134emailAddress = Email Address 142emailAddress = Email Address
135emailAddress_max = 40 143emailAddress_max = 64
136 144
137# SET-ex3 = SET extension number 3 145# SET-ex3 = SET extension number 3
138 146
@@ -180,6 +188,9 @@ authorityKeyIdentifier=keyid,issuer:always
180# This stuff is for subjectAltName and issuerAltname. 188# This stuff is for subjectAltName and issuerAltname.
181# Import the email address. 189# Import the email address.
182# subjectAltName=email:copy 190# subjectAltName=email:copy
191# An alternative to produce certificates that aren't
192# deprecated according to PKIX.
193# subjectAltName=email:move
183 194
184# Copy subject details 195# Copy subject details
185# issuerAltName=issuer:copy 196# issuerAltName=issuer:copy
diff --git a/src/lib/libssl/src/apps/passwd.c b/src/lib/libssl/src/apps/passwd.c
index ea2b089e24..ad8e7b0349 100644
--- a/src/lib/libssl/src/apps/passwd.c
+++ b/src/lib/libssl/src/apps/passwd.c
@@ -1,10 +1,10 @@
1/* apps/passwd.c */ 1/* apps/passwd.c */
2 2
3#if defined NO_MD5 || defined CHARSET_EBCDIC 3#if defined OPENSSL_NO_MD5 || defined CHARSET_EBCDIC
4# define NO_MD5CRYPT_1 4# define NO_MD5CRYPT_1
5#endif 5#endif
6 6
7#if !defined(NO_DES) || !defined(NO_MD5CRYPT_1) 7#if !defined(OPENSSL_NO_DES) || !defined(NO_MD5CRYPT_1)
8 8
9#include <assert.h> 9#include <assert.h>
10#include <string.h> 10#include <string.h>
@@ -15,11 +15,11 @@
15#include <openssl/err.h> 15#include <openssl/err.h>
16#include <openssl/evp.h> 16#include <openssl/evp.h>
17#include <openssl/rand.h> 17#include <openssl/rand.h>
18 18#ifndef OPENSSL_NO_DES
19#ifndef NO_DES
20# include <openssl/des.h> 19# include <openssl/des.h>
21#endif 20#endif
22#ifndef NO_MD5CRYPT_1 21#ifndef NO_MD5CRYPT_1
22# include <openssl/evp.h>
23# include <openssl/md5.h> 23# include <openssl/md5.h>
24#endif 24#endif
25 25
@@ -50,6 +50,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
50 * -salt string - salt 50 * -salt string - salt
51 * -in file - read passwords from file 51 * -in file - read passwords from file
52 * -stdin - read passwords from stdin 52 * -stdin - read passwords from stdin
53 * -noverify - never verify when reading password from terminal
53 * -quiet - no warnings 54 * -quiet - no warnings
54 * -table - format output as table 55 * -table - format output as table
55 * -reverse - switch table columns 56 * -reverse - switch table columns
@@ -62,6 +63,7 @@ int MAIN(int argc, char **argv)
62 int ret = 1; 63 int ret = 1;
63 char *infile = NULL; 64 char *infile = NULL;
64 int in_stdin = 0; 65 int in_stdin = 0;
66 int in_noverify = 0;
65 char *salt = NULL, *passwd = NULL, **passwds = NULL; 67 char *salt = NULL, *passwd = NULL, **passwds = NULL;
66 char *salt_malloc = NULL, *passwd_malloc = NULL; 68 char *salt_malloc = NULL, *passwd_malloc = NULL;
67 size_t passwd_malloc_size = 0; 69 size_t passwd_malloc_size = 0;
@@ -77,11 +79,14 @@ int MAIN(int argc, char **argv)
77 if (bio_err == NULL) 79 if (bio_err == NULL)
78 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 80 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
79 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 81 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
82
83 if (!load_config(bio_err, NULL))
84 goto err;
80 out = BIO_new(BIO_s_file()); 85 out = BIO_new(BIO_s_file());
81 if (out == NULL) 86 if (out == NULL)
82 goto err; 87 goto err;
83 BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); 88 BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
84#ifdef VMS 89#ifdef OPENSSL_SYS_VMS
85 { 90 {
86 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 91 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
87 out = BIO_push(tmpbio, out); 92 out = BIO_push(tmpbio, out);
@@ -128,6 +133,8 @@ int MAIN(int argc, char **argv)
128 else 133 else
129 badopt = 1; 134 badopt = 1;
130 } 135 }
136 else if (strcmp(argv[i], "-noverify") == 0)
137 in_noverify = 1;
131 else if (strcmp(argv[i], "-quiet") == 0) 138 else if (strcmp(argv[i], "-quiet") == 0)
132 quiet = 1; 139 quiet = 1;
133 else if (strcmp(argv[i], "-table") == 0) 140 else if (strcmp(argv[i], "-table") == 0)
@@ -153,7 +160,7 @@ int MAIN(int argc, char **argv)
153 badopt = 1; 160 badopt = 1;
154 161
155 /* reject unsupported algorithms */ 162 /* reject unsupported algorithms */
156#ifdef NO_DES 163#ifdef OPENSSL_NO_DES
157 if (usecrypt) badopt = 1; 164 if (usecrypt) badopt = 1;
158#endif 165#endif
159#ifdef NO_MD5CRYPT_1 166#ifdef NO_MD5CRYPT_1
@@ -164,7 +171,7 @@ int MAIN(int argc, char **argv)
164 { 171 {
165 BIO_printf(bio_err, "Usage: passwd [options] [passwords]\n"); 172 BIO_printf(bio_err, "Usage: passwd [options] [passwords]\n");
166 BIO_printf(bio_err, "where options are\n"); 173 BIO_printf(bio_err, "where options are\n");
167#ifndef NO_DES 174#ifndef OPENSSL_NO_DES
168 BIO_printf(bio_err, "-crypt standard Unix password algorithm (default)\n"); 175 BIO_printf(bio_err, "-crypt standard Unix password algorithm (default)\n");
169#endif 176#endif
170#ifndef NO_MD5CRYPT_1 177#ifndef NO_MD5CRYPT_1
@@ -174,6 +181,7 @@ int MAIN(int argc, char **argv)
174 BIO_printf(bio_err, "-salt string use provided salt\n"); 181 BIO_printf(bio_err, "-salt string use provided salt\n");
175 BIO_printf(bio_err, "-in file read passwords from file\n"); 182 BIO_printf(bio_err, "-in file read passwords from file\n");
176 BIO_printf(bio_err, "-stdin read passwords from stdin\n"); 183 BIO_printf(bio_err, "-stdin read passwords from stdin\n");
184 BIO_printf(bio_err, "-noverify never verify when reading password from terminal\n");
177 BIO_printf(bio_err, "-quiet no warnings\n"); 185 BIO_printf(bio_err, "-quiet no warnings\n");
178 BIO_printf(bio_err, "-table format output as table\n"); 186 BIO_printf(bio_err, "-table format output as table\n");
179 BIO_printf(bio_err, "-reverse switch table columns\n"); 187 BIO_printf(bio_err, "-reverse switch table columns\n");
@@ -222,7 +230,7 @@ int MAIN(int argc, char **argv)
222 230
223 passwds = passwds_static; 231 passwds = passwds_static;
224 if (in == NULL) 232 if (in == NULL)
225 if (EVP_read_pw_string(passwd_malloc, passwd_malloc_size, "Password: ", 0) != 0) 233 if (EVP_read_pw_string(passwd_malloc, passwd_malloc_size, "Password: ", !(passed_salt || in_noverify)) != 0)
226 goto err; 234 goto err;
227 passwds[0] = passwd_malloc; 235 passwds[0] = passwd_malloc;
228 } 236 }
@@ -284,6 +292,7 @@ err:
284 BIO_free(in); 292 BIO_free(in);
285 if (out) 293 if (out)
286 BIO_free_all(out); 294 BIO_free_all(out);
295 apps_shutdown();
287 EXIT(ret); 296 EXIT(ret);
288 } 297 }
289 298
@@ -305,7 +314,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
305 unsigned char buf[MD5_DIGEST_LENGTH]; 314 unsigned char buf[MD5_DIGEST_LENGTH];
306 char *salt_out; 315 char *salt_out;
307 int n, i; 316 int n, i;
308 MD5_CTX md; 317 EVP_MD_CTX md,md2;
309 size_t passwd_len, salt_len; 318 size_t passwd_len, salt_len;
310 319
311 passwd_len = strlen(passwd); 320 passwd_len = strlen(passwd);
@@ -320,49 +329,47 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
320 salt_len = strlen(salt_out); 329 salt_len = strlen(salt_out);
321 assert(salt_len <= 8); 330 assert(salt_len <= 8);
322 331
323 MD5_Init(&md); 332 EVP_MD_CTX_init(&md);
324 MD5_Update(&md, passwd, passwd_len); 333 EVP_DigestInit_ex(&md,EVP_md5(), NULL);
325 MD5_Update(&md, "$", 1); 334 EVP_DigestUpdate(&md, passwd, passwd_len);
326 MD5_Update(&md, magic, strlen(magic)); 335 EVP_DigestUpdate(&md, "$", 1);
327 MD5_Update(&md, "$", 1); 336 EVP_DigestUpdate(&md, magic, strlen(magic));
328 MD5_Update(&md, salt_out, salt_len); 337 EVP_DigestUpdate(&md, "$", 1);
338 EVP_DigestUpdate(&md, salt_out, salt_len);
329 339
330 { 340 EVP_MD_CTX_init(&md2);
331 MD5_CTX md2; 341 EVP_DigestInit_ex(&md2,EVP_md5(), NULL);
342 EVP_DigestUpdate(&md2, passwd, passwd_len);
343 EVP_DigestUpdate(&md2, salt_out, salt_len);
344 EVP_DigestUpdate(&md2, passwd, passwd_len);
345 EVP_DigestFinal_ex(&md2, buf, NULL);
332 346
333 MD5_Init(&md2);
334 MD5_Update(&md2, passwd, passwd_len);
335 MD5_Update(&md2, salt_out, salt_len);
336 MD5_Update(&md2, passwd, passwd_len);
337 MD5_Final(buf, &md2);
338 }
339 for (i = passwd_len; i > sizeof buf; i -= sizeof buf) 347 for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
340 MD5_Update(&md, buf, sizeof buf); 348 EVP_DigestUpdate(&md, buf, sizeof buf);
341 MD5_Update(&md, buf, i); 349 EVP_DigestUpdate(&md, buf, i);
342 350
343 n = passwd_len; 351 n = passwd_len;
344 while (n) 352 while (n)
345 { 353 {
346 MD5_Update(&md, (n & 1) ? "\0" : passwd, 1); 354 EVP_DigestUpdate(&md, (n & 1) ? "\0" : passwd, 1);
347 n >>= 1; 355 n >>= 1;
348 } 356 }
349 MD5_Final(buf, &md); 357 EVP_DigestFinal_ex(&md, buf, NULL);
350 358
351 for (i = 0; i < 1000; i++) 359 for (i = 0; i < 1000; i++)
352 { 360 {
353 MD5_CTX md2; 361 EVP_DigestInit_ex(&md2,EVP_md5(), NULL);
354 362 EVP_DigestUpdate(&md2, (i & 1) ? (unsigned char *) passwd : buf,
355 MD5_Init(&md2); 363 (i & 1) ? passwd_len : sizeof buf);
356 MD5_Update(&md2, (i & 1) ? (unsigned char *) passwd : buf,
357 (i & 1) ? passwd_len : sizeof buf);
358 if (i % 3) 364 if (i % 3)
359 MD5_Update(&md2, salt_out, salt_len); 365 EVP_DigestUpdate(&md2, salt_out, salt_len);
360 if (i % 7) 366 if (i % 7)
361 MD5_Update(&md2, passwd, passwd_len); 367 EVP_DigestUpdate(&md2, passwd, passwd_len);
362 MD5_Update(&md2, (i & 1) ? buf : (unsigned char *) passwd, 368 EVP_DigestUpdate(&md2, (i & 1) ? buf : (unsigned char *) passwd,
363 (i & 1) ? sizeof buf : passwd_len); 369 (i & 1) ? sizeof buf : passwd_len);
364 MD5_Final(buf, &md2); 370 EVP_DigestFinal_ex(&md2, buf, NULL);
365 } 371 }
372 EVP_MD_CTX_cleanup(&md2);
366 373
367 { 374 {
368 /* transform buf into output string */ 375 /* transform buf into output string */
@@ -400,6 +407,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
400 *output = 0; 407 *output = 0;
401 assert(strlen(out_buf) < sizeof(out_buf)); 408 assert(strlen(out_buf) < sizeof(out_buf));
402 } 409 }
410 EVP_MD_CTX_cleanup(&md);
403 411
404 return out_buf; 412 return out_buf;
405 } 413 }
@@ -418,7 +426,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
418 /* first make sure we have a salt */ 426 /* first make sure we have a salt */
419 if (!passed_salt) 427 if (!passed_salt)
420 { 428 {
421#ifndef NO_DES 429#ifndef OPENSSL_NO_DES
422 if (usecrypt) 430 if (usecrypt)
423 { 431 {
424 if (*salt_malloc_p == NULL) 432 if (*salt_malloc_p == NULL)
@@ -437,7 +445,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
437 * back to ASCII */ 445 * back to ASCII */
438#endif 446#endif
439 } 447 }
440#endif /* !NO_DES */ 448#endif /* !OPENSSL_NO_DES */
441 449
442#ifndef NO_MD5CRYPT_1 450#ifndef NO_MD5CRYPT_1
443 if (use1 || useapr1) 451 if (use1 || useapr1)
@@ -472,9 +480,9 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
472 assert(strlen(passwd) <= pw_maxlen); 480 assert(strlen(passwd) <= pw_maxlen);
473 481
474 /* now compute password hash */ 482 /* now compute password hash */
475#ifndef NO_DES 483#ifndef OPENSSL_NO_DES
476 if (usecrypt) 484 if (usecrypt)
477 hash = des_crypt(passwd, *salt_p); 485 hash = DES_crypt(passwd, *salt_p);
478#endif 486#endif
479#ifndef NO_MD5CRYPT_1 487#ifndef NO_MD5CRYPT_1
480 if (use1 || useapr1) 488 if (use1 || useapr1)
diff --git a/src/lib/libssl/src/apps/pkcs12.c b/src/lib/libssl/src/apps/pkcs12.c
index 365a8ada93..e345cf1489 100644
--- a/src/lib/libssl/src/apps/pkcs12.c
+++ b/src/lib/libssl/src/apps/pkcs12.c
@@ -1,5 +1,5 @@
1/* pkcs12.c */ 1/* pkcs12.c */
2#if !defined(NO_DES) && !defined(NO_SHA1) 2#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)
3 3
4/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 4/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
5 * project 1999. 5 * project 1999.
@@ -66,11 +66,10 @@
66#include <openssl/err.h> 66#include <openssl/err.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68#include <openssl/pkcs12.h> 68#include <openssl/pkcs12.h>
69#include <openssl/engine.h>
70 69
71#define PROG pkcs12_main 70#define PROG pkcs12_main
72 71
73EVP_CIPHER *enc; 72const EVP_CIPHER *enc;
74 73
75 74
76#define NOKEYS 0x1 75#define NOKEYS 0x1
@@ -96,9 +95,10 @@ int MAIN(int argc, char **argv)
96 ENGINE *e = NULL; 95 ENGINE *e = NULL;
97 char *infile=NULL, *outfile=NULL, *keyname = NULL; 96 char *infile=NULL, *outfile=NULL, *keyname = NULL;
98 char *certfile=NULL; 97 char *certfile=NULL;
99 BIO *in=NULL, *out = NULL, *inkey = NULL, *certsin = NULL; 98 BIO *in=NULL, *out = NULL;
100 char **args; 99 char **args;
101 char *name = NULL; 100 char *name = NULL;
101 char *csp_name = NULL;
102 PKCS12 *p12 = NULL; 102 PKCS12 *p12 = NULL;
103 char pass[50], macpass[50]; 103 char pass[50], macpass[50];
104 int export_cert = 0; 104 int export_cert = 0;
@@ -127,6 +127,9 @@ int MAIN(int argc, char **argv)
127 enc = EVP_des_ede3_cbc(); 127 enc = EVP_des_ede3_cbc();
128 if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE); 128 if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
129 129
130 if (!load_config(bio_err, NULL))
131 goto end;
132
130 args = argv + 1; 133 args = argv + 1;
131 134
132 135
@@ -147,10 +150,15 @@ int MAIN(int argc, char **argv)
147 cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; 150 cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
148 else if (!strcmp (*args, "-export")) export_cert = 1; 151 else if (!strcmp (*args, "-export")) export_cert = 1;
149 else if (!strcmp (*args, "-des")) enc=EVP_des_cbc(); 152 else if (!strcmp (*args, "-des")) enc=EVP_des_cbc();
150#ifndef NO_IDEA 153#ifndef OPENSSL_NO_IDEA
151 else if (!strcmp (*args, "-idea")) enc=EVP_idea_cbc(); 154 else if (!strcmp (*args, "-idea")) enc=EVP_idea_cbc();
152#endif 155#endif
153 else if (!strcmp (*args, "-des3")) enc = EVP_des_ede3_cbc(); 156 else if (!strcmp (*args, "-des3")) enc = EVP_des_ede3_cbc();
157#ifndef OPENSSL_NO_AES
158 else if (!strcmp(*args,"-aes128")) enc=EVP_aes_128_cbc();
159 else if (!strcmp(*args,"-aes192")) enc=EVP_aes_192_cbc();
160 else if (!strcmp(*args,"-aes256")) enc=EVP_aes_256_cbc();
161#endif
154 else if (!strcmp (*args, "-noiter")) iter = 1; 162 else if (!strcmp (*args, "-noiter")) iter = 1;
155 else if (!strcmp (*args, "-maciter")) 163 else if (!strcmp (*args, "-maciter"))
156 maciter = PKCS12_DEFAULT_ITER; 164 maciter = PKCS12_DEFAULT_ITER;
@@ -197,6 +205,11 @@ int MAIN(int argc, char **argv)
197 args++; 205 args++;
198 name = *args; 206 name = *args;
199 } else badarg = 1; 207 } else badarg = 1;
208 } else if (!strcmp (*args, "-CSP")) {
209 if (args[1]) {
210 args++;
211 csp_name = *args;
212 } else badarg = 1;
200 } else if (!strcmp (*args, "-caname")) { 213 } else if (!strcmp (*args, "-caname")) {
201 if (args[1]) { 214 if (args[1]) {
202 args++; 215 args++;
@@ -272,9 +285,13 @@ int MAIN(int argc, char **argv)
272 BIO_printf (bio_err, "-info give info about PKCS#12 structure.\n"); 285 BIO_printf (bio_err, "-info give info about PKCS#12 structure.\n");
273 BIO_printf (bio_err, "-des encrypt private keys with DES\n"); 286 BIO_printf (bio_err, "-des encrypt private keys with DES\n");
274 BIO_printf (bio_err, "-des3 encrypt private keys with triple DES (default)\n"); 287 BIO_printf (bio_err, "-des3 encrypt private keys with triple DES (default)\n");
275#ifndef NO_IDEA 288#ifndef OPENSSL_NO_IDEA
276 BIO_printf (bio_err, "-idea encrypt private keys with idea\n"); 289 BIO_printf (bio_err, "-idea encrypt private keys with idea\n");
277#endif 290#endif
291#ifndef OPENSSL_NO_AES
292 BIO_printf (bio_err, "-aes128, -aes192, -aes256\n");
293 BIO_printf (bio_err, " encrypt PEM output with cbc aes\n");
294#endif
278 BIO_printf (bio_err, "-nodes don't encrypt private keys\n"); 295 BIO_printf (bio_err, "-nodes don't encrypt private keys\n");
279 BIO_printf (bio_err, "-noiter don't use encryption iteration\n"); 296 BIO_printf (bio_err, "-noiter don't use encryption iteration\n");
280 BIO_printf (bio_err, "-maciter use MAC iteration\n"); 297 BIO_printf (bio_err, "-maciter use MAC iteration\n");
@@ -294,19 +311,7 @@ int MAIN(int argc, char **argv)
294 goto end; 311 goto end;
295 } 312 }
296 313
297 if (engine != NULL) { 314 e = setup_engine(bio_err, engine, 0);
298 if((e = ENGINE_by_id(engine)) == NULL) {
299 BIO_printf(bio_err,"invalid engine \"%s\"\n", engine);
300 goto end;
301 }
302 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
303 BIO_printf(bio_err,"can't use that engine\n");
304 goto end;
305 }
306 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
307 /* Free our "structural" reference. */
308 ENGINE_free(e);
309 }
310 315
311 if(passarg) { 316 if(passarg) {
312 if(export_cert) passargout = passarg; 317 if(export_cert) passargout = passarg;
@@ -352,6 +357,7 @@ int MAIN(int argc, char **argv)
352 goto end; 357 goto end;
353 } 358 }
354 359
360#if 0
355 if (certfile) { 361 if (certfile) {
356 if(!(certsin = BIO_new_file(certfile, "r"))) { 362 if(!(certsin = BIO_new_file(certfile, "r"))) {
357 BIO_printf(bio_err, "Can't open certificate file %s\n", certfile); 363 BIO_printf(bio_err, "Can't open certificate file %s\n", certfile);
@@ -367,6 +373,7 @@ int MAIN(int argc, char **argv)
367 goto end; 373 goto end;
368 } 374 }
369 } 375 }
376#endif
370 377
371#ifdef CRYPTO_MDEBUG 378#ifdef CRYPTO_MDEBUG
372 CRYPTO_pop_info(); 379 CRYPTO_pop_info();
@@ -375,7 +382,7 @@ int MAIN(int argc, char **argv)
375 382
376 if (!outfile) { 383 if (!outfile) {
377 out = BIO_new_fp(stdout, BIO_NOCLOSE); 384 out = BIO_new_fp(stdout, BIO_NOCLOSE);
378#ifdef VMS 385#ifdef OPENSSL_SYS_VMS
379 { 386 {
380 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 387 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
381 out = BIO_push(tmpbio, out); 388 out = BIO_push(tmpbio, out);
@@ -420,12 +427,9 @@ int MAIN(int argc, char **argv)
420 CRYPTO_push_info("process -export_cert"); 427 CRYPTO_push_info("process -export_cert");
421 CRYPTO_push_info("reading private key"); 428 CRYPTO_push_info("reading private key");
422#endif 429#endif
423 key = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL, passin); 430 key = load_key(bio_err, keyname ? keyname : infile, FORMAT_PEM,
424 if (!inkey) (void) BIO_reset(in); 431 passin, e, "private key");
425 else BIO_free(inkey);
426 if (!key) { 432 if (!key) {
427 BIO_printf (bio_err, "Error loading private key\n");
428 ERR_print_errors(bio_err);
429 goto export_end; 433 goto export_end;
430 } 434 }
431 435
@@ -434,12 +438,9 @@ int MAIN(int argc, char **argv)
434 CRYPTO_push_info("reading certs from input"); 438 CRYPTO_push_info("reading certs from input");
435#endif 439#endif
436 440
437 certs = sk_X509_new_null();
438
439 /* Load in all certs in input file */ 441 /* Load in all certs in input file */
440 if(!cert_load(in, certs)) { 442 if(!(certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, e,
441 BIO_printf(bio_err, "Error loading certificates from input\n"); 443 "certificates"))) {
442 ERR_print_errors(bio_err);
443 goto export_end; 444 goto export_end;
444 } 445 }
445 446
@@ -469,13 +470,17 @@ int MAIN(int argc, char **argv)
469 bags = sk_PKCS12_SAFEBAG_new_null (); 470 bags = sk_PKCS12_SAFEBAG_new_null ();
470 471
471 /* Add any more certificates asked for */ 472 /* Add any more certificates asked for */
472 if (certsin) { 473 if (certfile) {
473 if(!cert_load(certsin, certs)) { 474 STACK_OF(X509) *morecerts=NULL;
474 BIO_printf(bio_err, "Error loading certificates from certfile\n"); 475 if(!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM,
475 ERR_print_errors(bio_err); 476 NULL, e,
477 "certificates from certfile"))) {
476 goto export_end; 478 goto export_end;
477 } 479 }
478 BIO_free(certsin); 480 while(sk_X509_num(morecerts) > 0) {
481 sk_X509_push(certs, sk_X509_shift(morecerts));
482 }
483 sk_X509_free(morecerts);
479 } 484 }
480 485
481#ifdef CRYPTO_MDEBUG 486#ifdef CRYPTO_MDEBUG
@@ -521,7 +526,7 @@ int MAIN(int argc, char **argv)
521 for(i = 0; i < sk_X509_num(certs); i++) { 526 for(i = 0; i < sk_X509_num(certs); i++) {
522 X509 *cert = NULL; 527 X509 *cert = NULL;
523 cert = sk_X509_value(certs, i); 528 cert = sk_X509_value(certs, i);
524 bag = M_PKCS12_x5092certbag(cert); 529 bag = PKCS12_x5092certbag(cert);
525 /* If it matches private key set id */ 530 /* If it matches private key set id */
526 if(cert == ucert) { 531 if(cert == ucert) {
527 if(name) PKCS12_add_friendlyname(bag, name, -1); 532 if(name) PKCS12_add_friendlyname(bag, name, -1);
@@ -572,6 +577,7 @@ int MAIN(int argc, char **argv)
572 PKCS8_PRIV_KEY_INFO_free(p8); 577 PKCS8_PRIV_KEY_INFO_free(p8);
573 p8 = NULL; 578 p8 = NULL;
574 if (name) PKCS12_add_friendlyname (bag, name, -1); 579 if (name) PKCS12_add_friendlyname (bag, name, -1);
580 if(csp_name) PKCS12_add_CSPName_asc(bag, csp_name, -1);
575 PKCS12_add_localkeyid (bag, keyid, keyidlen); 581 PKCS12_add_localkeyid (bag, keyid, keyidlen);
576 bags = sk_PKCS12_SAFEBAG_new_null(); 582 bags = sk_PKCS12_SAFEBAG_new_null();
577 sk_PKCS12_SAFEBAG_push (bags, bag); 583 sk_PKCS12_SAFEBAG_push (bags, bag);
@@ -592,9 +598,9 @@ int MAIN(int argc, char **argv)
592 CRYPTO_push_info("building pkcs12"); 598 CRYPTO_push_info("building pkcs12");
593#endif 599#endif
594 600
595 p12 = PKCS12_init (NID_pkcs7_data); 601 p12 = PKCS12_init(NID_pkcs7_data);
596 602
597 M_PKCS12_pack_authsafes (p12, safes); 603 PKCS12_pack_authsafes(p12, safes);
598 604
599 sk_PKCS7_pop_free(safes, PKCS7_free); 605 sk_PKCS7_pop_free(safes, PKCS7_free);
600 safes = NULL; 606 safes = NULL;
@@ -691,6 +697,7 @@ int MAIN(int argc, char **argv)
691 if (canames) sk_free(canames); 697 if (canames) sk_free(canames);
692 if(passin) OPENSSL_free(passin); 698 if(passin) OPENSSL_free(passin);
693 if(passout) OPENSSL_free(passout); 699 if(passout) OPENSSL_free(passout);
700 apps_shutdown();
694 EXIT(ret); 701 EXIT(ret);
695} 702}
696 703
@@ -702,20 +709,20 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
702 int i, bagnid; 709 int i, bagnid;
703 PKCS7 *p7; 710 PKCS7 *p7;
704 711
705 if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; 712 if (!( asafes = PKCS12_unpack_authsafes(p12))) return 0;
706 for (i = 0; i < sk_PKCS7_num (asafes); i++) { 713 for (i = 0; i < sk_PKCS7_num (asafes); i++) {
707 p7 = sk_PKCS7_value (asafes, i); 714 p7 = sk_PKCS7_value (asafes, i);
708 bagnid = OBJ_obj2nid (p7->type); 715 bagnid = OBJ_obj2nid (p7->type);
709 if (bagnid == NID_pkcs7_data) { 716 if (bagnid == NID_pkcs7_data) {
710 bags = M_PKCS12_unpack_p7data (p7); 717 bags = PKCS12_unpack_p7data(p7);
711 if (options & INFO) BIO_printf (bio_err, "PKCS7 Data\n"); 718 if (options & INFO) BIO_printf (bio_err, "PKCS7 Data\n");
712 } else if (bagnid == NID_pkcs7_encrypted) { 719 } else if (bagnid == NID_pkcs7_encrypted) {
713 if (options & INFO) { 720 if (options & INFO) {
714 BIO_printf (bio_err, "PKCS7 Encrypted data: "); 721 BIO_printf(bio_err, "PKCS7 Encrypted data: ");
715 alg_print (bio_err, 722 alg_print(bio_err,
716 p7->d.encrypted->enc_data->algorithm); 723 p7->d.encrypted->enc_data->algorithm);
717 } 724 }
718 bags = M_PKCS12_unpack_p7encdata (p7, pass, passlen); 725 bags = PKCS12_unpack_p7encdata(p7, pass, passlen);
719 } else continue; 726 } else continue;
720 if (!bags) return 0; 727 if (!bags) return 0;
721 if (!dump_certs_pkeys_bags (out, bags, pass, passlen, 728 if (!dump_certs_pkeys_bags (out, bags, pass, passlen,
@@ -770,9 +777,12 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
770 } 777 }
771 if (options & NOKEYS) return 1; 778 if (options & NOKEYS) return 1;
772 print_attribs (out, bag->attrib, "Bag Attributes"); 779 print_attribs (out, bag->attrib, "Bag Attributes");
773 if (!(p8 = M_PKCS12_decrypt_skey (bag, pass, passlen))) 780 if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
774 return 0; 781 return 0;
775 if (!(pkey = EVP_PKCS82PKEY (p8))) return 0; 782 if (!(pkey = EVP_PKCS82PKEY (p8))) {
783 PKCS8_PRIV_KEY_INFO_free(p8);
784 return 0;
785 }
776 print_attribs (out, p8->attributes, "Key Attributes"); 786 print_attribs (out, p8->attributes, "Key Attributes");
777 PKCS8_PRIV_KEY_INFO_free(p8); 787 PKCS8_PRIV_KEY_INFO_free(p8);
778 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass); 788 PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass);
@@ -788,7 +798,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
788 print_attribs (out, bag->attrib, "Bag Attributes"); 798 print_attribs (out, bag->attrib, "Bag Attributes");
789 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate ) 799 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate )
790 return 1; 800 return 1;
791 if (!(x509 = M_PKCS12_certbag2x509(bag))) return 0; 801 if (!(x509 = PKCS12_certbag2x509(bag))) return 0;
792 dump_cert_text (out, x509); 802 dump_cert_text (out, x509);
793 PEM_write_bio_X509 (out, x509); 803 PEM_write_bio_X509 (out, x509);
794 X509_free(x509); 804 X509_free(x509);
@@ -820,6 +830,9 @@ int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
820 STACK_OF(X509) *chn; 830 STACK_OF(X509) *chn;
821 int i; 831 int i;
822 832
833 /* FIXME: Should really check the return status of X509_STORE_CTX_init
834 * for an error, but how that fits into the return value of this
835 * function is less obvious. */
823 X509_STORE_CTX_init(&store_ctx, store, cert, NULL); 836 X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
824 if (X509_verify_cert(&store_ctx) <= 0) { 837 if (X509_verify_cert(&store_ctx) <= 0) {
825 i = X509_STORE_CTX_get_error (&store_ctx); 838 i = X509_STORE_CTX_get_error (&store_ctx);
diff --git a/src/lib/libssl/src/apps/pkcs7.c b/src/lib/libssl/src/apps/pkcs7.c
index b348da2203..1cc91509a2 100644
--- a/src/lib/libssl/src/apps/pkcs7.c
+++ b/src/lib/libssl/src/apps/pkcs7.c
@@ -67,7 +67,6 @@
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68#include <openssl/pkcs7.h> 68#include <openssl/pkcs7.h>
69#include <openssl/pem.h> 69#include <openssl/pem.h>
70#include <openssl/engine.h>
71 70
72#undef PROG 71#undef PROG
73#define PROG pkcs7_main 72#define PROG pkcs7_main
@@ -163,28 +162,13 @@ bad:
163 BIO_printf(bio_err," -text print full details of certificates\n"); 162 BIO_printf(bio_err," -text print full details of certificates\n");
164 BIO_printf(bio_err," -noout don't output encoded data\n"); 163 BIO_printf(bio_err," -noout don't output encoded data\n");
165 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 164 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
166 EXIT(1); 165 ret = 1;
166 goto end;
167 } 167 }
168 168
169 ERR_load_crypto_strings(); 169 ERR_load_crypto_strings();
170 170
171 if (engine != NULL) 171 e = setup_engine(bio_err, engine, 0);
172 {
173 if((e = ENGINE_by_id(engine)) == NULL)
174 {
175 BIO_printf(bio_err,"invalid engine \"%s\"\n",
176 engine);
177 goto end;
178 }
179 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
180 {
181 BIO_printf(bio_err,"can't use that engine\n");
182 goto end;
183 }
184 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
185 /* Free our "structural" reference. */
186 ENGINE_free(e);
187 }
188 172
189 in=BIO_new(BIO_s_file()); 173 in=BIO_new(BIO_s_file());
190 out=BIO_new(BIO_s_file()); 174 out=BIO_new(BIO_s_file());
@@ -225,7 +209,7 @@ bad:
225 if (outfile == NULL) 209 if (outfile == NULL)
226 { 210 {
227 BIO_set_fp(out,stdout,BIO_NOCLOSE); 211 BIO_set_fp(out,stdout,BIO_NOCLOSE);
228#ifdef VMS 212#ifdef OPENSSL_SYS_VMS
229 { 213 {
230 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 214 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
231 out = BIO_push(tmpbio, out); 215 out = BIO_push(tmpbio, out);
@@ -316,5 +300,6 @@ end:
316 if (p7 != NULL) PKCS7_free(p7); 300 if (p7 != NULL) PKCS7_free(p7);
317 if (in != NULL) BIO_free(in); 301 if (in != NULL) BIO_free(in);
318 if (out != NULL) BIO_free_all(out); 302 if (out != NULL) BIO_free_all(out);
303 apps_shutdown();
319 EXIT(ret); 304 EXIT(ret);
320 } 305 }
diff --git a/src/lib/libssl/src/apps/pkcs8.c b/src/lib/libssl/src/apps/pkcs8.c
index bd1697a325..ba91caee6b 100644
--- a/src/lib/libssl/src/apps/pkcs8.c
+++ b/src/lib/libssl/src/apps/pkcs8.c
@@ -62,7 +62,6 @@
62#include <openssl/err.h> 62#include <openssl/err.h>
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/pkcs12.h> 64#include <openssl/pkcs12.h>
65#include <openssl/engine.h>
66 65
67#include "apps.h" 66#include "apps.h"
68#define PROG pkcs8_main 67#define PROG pkcs8_main
@@ -84,13 +83,16 @@ int MAIN(int argc, char **argv)
84 int nocrypt = 0; 83 int nocrypt = 0;
85 X509_SIG *p8; 84 X509_SIG *p8;
86 PKCS8_PRIV_KEY_INFO *p8inf; 85 PKCS8_PRIV_KEY_INFO *p8inf;
87 EVP_PKEY *pkey; 86 EVP_PKEY *pkey=NULL;
88 char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL; 87 char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
89 int badarg = 0; 88 int badarg = 0;
90 char *engine=NULL; 89 char *engine=NULL;
91 90
92 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE); 91 if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
93 92
93 if (!load_config(bio_err, NULL))
94 goto end;
95
94 informat=FORMAT_PEM; 96 informat=FORMAT_PEM;
95 outformat=FORMAT_PEM; 97 outformat=FORMAT_PEM;
96 98
@@ -185,23 +187,7 @@ int MAIN(int argc, char **argv)
185 return (1); 187 return (1);
186 } 188 }
187 189
188 if (engine != NULL) 190 e = setup_engine(bio_err, engine, 0);
189 {
190 if((e = ENGINE_by_id(engine)) == NULL)
191 {
192 BIO_printf(bio_err,"invalid engine \"%s\"\n",
193 engine);
194 return (1);
195 }
196 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
197 {
198 BIO_printf(bio_err,"can't use that engine\n");
199 return (1);
200 }
201 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
202 /* Free our "structural" reference. */
203 ENGINE_free(e);
204 }
205 191
206 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 192 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
207 BIO_printf(bio_err, "Error getting passwords\n"); 193 BIO_printf(bio_err, "Error getting passwords\n");
@@ -226,28 +212,20 @@ int MAIN(int argc, char **argv)
226 } 212 }
227 } else { 213 } else {
228 out = BIO_new_fp (stdout, BIO_NOCLOSE); 214 out = BIO_new_fp (stdout, BIO_NOCLOSE);
229#ifdef VMS 215#ifdef OPENSSL_SYS_VMS
230 { 216 {
231 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 217 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
232 out = BIO_push(tmpbio, out); 218 out = BIO_push(tmpbio, out);
233 } 219 }
234#endif 220#endif
235 } 221 }
236 if (topk8) { 222 if (topk8)
237 if(informat == FORMAT_PEM) 223 {
238 pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, passin); 224 BIO_free(in); /* Not needed in this section */
239 else if(informat == FORMAT_ASN1) 225 pkey = load_key(bio_err, infile, informat, passin, e, "key");
240 pkey = d2i_PrivateKey_bio(in, NULL);
241 else {
242 BIO_printf(bio_err, "Bad format specified for key\n");
243 return (1);
244 }
245 if (!pkey) { 226 if (!pkey) {
246 BIO_printf(bio_err, "Error reading key\n", outfile);
247 ERR_print_errors(bio_err);
248 return (1); 227 return (1);
249 } 228 }
250 BIO_free(in);
251 if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) { 229 if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
252 BIO_printf(bio_err, "Error converting key\n", outfile); 230 BIO_printf(bio_err, "Error converting key\n", outfile);
253 ERR_print_errors(bio_err); 231 ERR_print_errors(bio_err);
@@ -325,7 +303,7 @@ int MAIN(int argc, char **argv)
325 p8pass = pass; 303 p8pass = pass;
326 EVP_read_pw_string(pass, 50, "Enter Password:", 0); 304 EVP_read_pw_string(pass, 50, "Enter Password:", 0);
327 } 305 }
328 p8inf = M_PKCS8_decrypt(p8, p8pass, strlen(p8pass)); 306 p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
329 X509_SIG_free(p8); 307 X509_SIG_free(p8);
330 } 308 }
331 309
@@ -372,6 +350,7 @@ int MAIN(int argc, char **argv)
372 return (1); 350 return (1);
373 } 351 }
374 352
353 end:
375 EVP_PKEY_free(pkey); 354 EVP_PKEY_free(pkey);
376 BIO_free_all(out); 355 BIO_free_all(out);
377 BIO_free(in); 356 BIO_free(in);
diff --git a/src/lib/libssl/src/apps/progs.h b/src/lib/libssl/src/apps/progs.h
index fbc65de632..752385d3a7 100644
--- a/src/lib/libssl/src/apps/progs.h
+++ b/src/lib/libssl/src/apps/progs.h
@@ -35,6 +35,8 @@ extern int pkcs8_main(int argc,char *argv[]);
35extern int spkac_main(int argc,char *argv[]); 35extern int spkac_main(int argc,char *argv[]);
36extern int smime_main(int argc,char *argv[]); 36extern int smime_main(int argc,char *argv[]);
37extern int rand_main(int argc,char *argv[]); 37extern int rand_main(int argc,char *argv[]);
38extern int engine_main(int argc,char *argv[]);
39extern int ocsp_main(int argc,char *argv[]);
38 40
39#define FUNC_TYPE_GENERAL 1 41#define FUNC_TYPE_GENERAL 1
40#define FUNC_TYPE_MD 2 42#define FUNC_TYPE_MD 2
@@ -51,205 +53,239 @@ FUNCTION functions[] = {
51 {FUNC_TYPE_GENERAL,"asn1parse",asn1parse_main}, 53 {FUNC_TYPE_GENERAL,"asn1parse",asn1parse_main},
52 {FUNC_TYPE_GENERAL,"req",req_main}, 54 {FUNC_TYPE_GENERAL,"req",req_main},
53 {FUNC_TYPE_GENERAL,"dgst",dgst_main}, 55 {FUNC_TYPE_GENERAL,"dgst",dgst_main},
54#ifndef NO_DH 56#ifndef OPENSSL_NO_DH
55 {FUNC_TYPE_GENERAL,"dh",dh_main}, 57 {FUNC_TYPE_GENERAL,"dh",dh_main},
56#endif 58#endif
57#ifndef NO_DH 59#ifndef OPENSSL_NO_DH
58 {FUNC_TYPE_GENERAL,"dhparam",dhparam_main}, 60 {FUNC_TYPE_GENERAL,"dhparam",dhparam_main},
59#endif 61#endif
60 {FUNC_TYPE_GENERAL,"enc",enc_main}, 62 {FUNC_TYPE_GENERAL,"enc",enc_main},
61 {FUNC_TYPE_GENERAL,"passwd",passwd_main}, 63 {FUNC_TYPE_GENERAL,"passwd",passwd_main},
62#ifndef NO_DH 64#ifndef OPENSSL_NO_DH
63 {FUNC_TYPE_GENERAL,"gendh",gendh_main}, 65 {FUNC_TYPE_GENERAL,"gendh",gendh_main},
64#endif 66#endif
65 {FUNC_TYPE_GENERAL,"errstr",errstr_main}, 67 {FUNC_TYPE_GENERAL,"errstr",errstr_main},
66 {FUNC_TYPE_GENERAL,"ca",ca_main}, 68 {FUNC_TYPE_GENERAL,"ca",ca_main},
67 {FUNC_TYPE_GENERAL,"crl",crl_main}, 69 {FUNC_TYPE_GENERAL,"crl",crl_main},
68#ifndef NO_RSA 70#ifndef OPENSSL_NO_RSA
69 {FUNC_TYPE_GENERAL,"rsa",rsa_main}, 71 {FUNC_TYPE_GENERAL,"rsa",rsa_main},
70#endif 72#endif
71#ifndef NO_RSA 73#ifndef OPENSSL_NO_RSA
72 {FUNC_TYPE_GENERAL,"rsautl",rsautl_main}, 74 {FUNC_TYPE_GENERAL,"rsautl",rsautl_main},
73#endif 75#endif
74#ifndef NO_DSA 76#ifndef OPENSSL_NO_DSA
75 {FUNC_TYPE_GENERAL,"dsa",dsa_main}, 77 {FUNC_TYPE_GENERAL,"dsa",dsa_main},
76#endif 78#endif
77#ifndef NO_DSA 79#ifndef OPENSSL_NO_DSA
78 {FUNC_TYPE_GENERAL,"dsaparam",dsaparam_main}, 80 {FUNC_TYPE_GENERAL,"dsaparam",dsaparam_main},
79#endif 81#endif
80 {FUNC_TYPE_GENERAL,"x509",x509_main}, 82 {FUNC_TYPE_GENERAL,"x509",x509_main},
81#ifndef NO_RSA 83#ifndef OPENSSL_NO_RSA
82 {FUNC_TYPE_GENERAL,"genrsa",genrsa_main}, 84 {FUNC_TYPE_GENERAL,"genrsa",genrsa_main},
83#endif 85#endif
84#ifndef NO_DSA 86#ifndef OPENSSL_NO_DSA
85 {FUNC_TYPE_GENERAL,"gendsa",gendsa_main}, 87 {FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
86#endif 88#endif
87#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3)) 89#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
88 {FUNC_TYPE_GENERAL,"s_server",s_server_main}, 90 {FUNC_TYPE_GENERAL,"s_server",s_server_main},
89#endif 91#endif
90#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3)) 92#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
91 {FUNC_TYPE_GENERAL,"s_client",s_client_main}, 93 {FUNC_TYPE_GENERAL,"s_client",s_client_main},
92#endif 94#endif
93 {FUNC_TYPE_GENERAL,"speed",speed_main}, 95 {FUNC_TYPE_GENERAL,"speed",speed_main},
94#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3)) 96#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
95 {FUNC_TYPE_GENERAL,"s_time",s_time_main}, 97 {FUNC_TYPE_GENERAL,"s_time",s_time_main},
96#endif 98#endif
97 {FUNC_TYPE_GENERAL,"version",version_main}, 99 {FUNC_TYPE_GENERAL,"version",version_main},
98 {FUNC_TYPE_GENERAL,"pkcs7",pkcs7_main}, 100 {FUNC_TYPE_GENERAL,"pkcs7",pkcs7_main},
99 {FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main}, 101 {FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main},
100 {FUNC_TYPE_GENERAL,"sess_id",sess_id_main}, 102 {FUNC_TYPE_GENERAL,"sess_id",sess_id_main},
101#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3)) 103#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))
102 {FUNC_TYPE_GENERAL,"ciphers",ciphers_main}, 104 {FUNC_TYPE_GENERAL,"ciphers",ciphers_main},
103#endif 105#endif
104 {FUNC_TYPE_GENERAL,"nseq",nseq_main}, 106 {FUNC_TYPE_GENERAL,"nseq",nseq_main},
105#if !defined(NO_DES) && !defined(NO_SHA1) 107#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)
106 {FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main}, 108 {FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main},
107#endif 109#endif
108 {FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main}, 110 {FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main},
109 {FUNC_TYPE_GENERAL,"spkac",spkac_main}, 111 {FUNC_TYPE_GENERAL,"spkac",spkac_main},
110 {FUNC_TYPE_GENERAL,"smime",smime_main}, 112 {FUNC_TYPE_GENERAL,"smime",smime_main},
111 {FUNC_TYPE_GENERAL,"rand",rand_main}, 113 {FUNC_TYPE_GENERAL,"rand",rand_main},
114 {FUNC_TYPE_GENERAL,"engine",engine_main},
115 {FUNC_TYPE_GENERAL,"ocsp",ocsp_main},
116#ifndef OPENSSL_NO_MD2
112 {FUNC_TYPE_MD,"md2",dgst_main}, 117 {FUNC_TYPE_MD,"md2",dgst_main},
118#endif
119#ifndef OPENSSL_NO_MD4
113 {FUNC_TYPE_MD,"md4",dgst_main}, 120 {FUNC_TYPE_MD,"md4",dgst_main},
121#endif
122#ifndef OPENSSL_NO_MD5
114 {FUNC_TYPE_MD,"md5",dgst_main}, 123 {FUNC_TYPE_MD,"md5",dgst_main},
124#endif
125#ifndef OPENSSL_NO_SHA
115 {FUNC_TYPE_MD,"sha",dgst_main}, 126 {FUNC_TYPE_MD,"sha",dgst_main},
127#endif
128#ifndef OPENSSL_NO_SHA1
116 {FUNC_TYPE_MD,"sha1",dgst_main}, 129 {FUNC_TYPE_MD,"sha1",dgst_main},
130#endif
131#ifndef OPENSSL_NO_MDC2
117 {FUNC_TYPE_MD,"mdc2",dgst_main}, 132 {FUNC_TYPE_MD,"mdc2",dgst_main},
133#endif
134#ifndef OPENSSL_NO_RMD160
118 {FUNC_TYPE_MD,"rmd160",dgst_main}, 135 {FUNC_TYPE_MD,"rmd160",dgst_main},
136#endif
137#ifndef OPENSSL_NO_AES
138 {FUNC_TYPE_CIPHER,"aes-128-cbc",enc_main},
139#endif
140#ifndef OPENSSL_NO_AES
141 {FUNC_TYPE_CIPHER,"aes-128-ecb",enc_main},
142#endif
143#ifndef OPENSSL_NO_AES
144 {FUNC_TYPE_CIPHER,"aes-192-cbc",enc_main},
145#endif
146#ifndef OPENSSL_NO_AES
147 {FUNC_TYPE_CIPHER,"aes-192-ecb",enc_main},
148#endif
149#ifndef OPENSSL_NO_AES
150 {FUNC_TYPE_CIPHER,"aes-256-cbc",enc_main},
151#endif
152#ifndef OPENSSL_NO_AES
153 {FUNC_TYPE_CIPHER,"aes-256-ecb",enc_main},
154#endif
119 {FUNC_TYPE_CIPHER,"base64",enc_main}, 155 {FUNC_TYPE_CIPHER,"base64",enc_main},
120#ifndef NO_DES 156#ifndef OPENSSL_NO_DES
121 {FUNC_TYPE_CIPHER,"des",enc_main}, 157 {FUNC_TYPE_CIPHER,"des",enc_main},
122#endif 158#endif
123#ifndef NO_DES 159#ifndef OPENSSL_NO_DES
124 {FUNC_TYPE_CIPHER,"des3",enc_main}, 160 {FUNC_TYPE_CIPHER,"des3",enc_main},
125#endif 161#endif
126#ifndef NO_DES 162#ifndef OPENSSL_NO_DES
127 {FUNC_TYPE_CIPHER,"desx",enc_main}, 163 {FUNC_TYPE_CIPHER,"desx",enc_main},
128#endif 164#endif
129#ifndef NO_IDEA 165#ifndef OPENSSL_NO_IDEA
130 {FUNC_TYPE_CIPHER,"idea",enc_main}, 166 {FUNC_TYPE_CIPHER,"idea",enc_main},
131#endif 167#endif
132#ifndef NO_RC4 168#ifndef OPENSSL_NO_RC4
133 {FUNC_TYPE_CIPHER,"rc4",enc_main}, 169 {FUNC_TYPE_CIPHER,"rc4",enc_main},
134#endif 170#endif
135#ifndef NO_RC4 171#ifndef OPENSSL_NO_RC4
136 {FUNC_TYPE_CIPHER,"rc4-40",enc_main}, 172 {FUNC_TYPE_CIPHER,"rc4-40",enc_main},
137#endif 173#endif
138#ifndef NO_RC2 174#ifndef OPENSSL_NO_RC2
139 {FUNC_TYPE_CIPHER,"rc2",enc_main}, 175 {FUNC_TYPE_CIPHER,"rc2",enc_main},
140#endif 176#endif
141#ifndef NO_BF 177#ifndef OPENSSL_NO_BF
142 {FUNC_TYPE_CIPHER,"bf",enc_main}, 178 {FUNC_TYPE_CIPHER,"bf",enc_main},
143#endif 179#endif
144#ifndef NO_CAST 180#ifndef OPENSSL_NO_CAST
145 {FUNC_TYPE_CIPHER,"cast",enc_main}, 181 {FUNC_TYPE_CIPHER,"cast",enc_main},
146#endif 182#endif
147#ifndef NO_RC5 183#ifndef OPENSSL_NO_RC5
148 {FUNC_TYPE_CIPHER,"rc5",enc_main}, 184 {FUNC_TYPE_CIPHER,"rc5",enc_main},
149#endif 185#endif
150#ifndef NO_DES 186#ifndef OPENSSL_NO_DES
151 {FUNC_TYPE_CIPHER,"des-ecb",enc_main}, 187 {FUNC_TYPE_CIPHER,"des-ecb",enc_main},
152#endif 188#endif
153#ifndef NO_DES 189#ifndef OPENSSL_NO_DES
154 {FUNC_TYPE_CIPHER,"des-ede",enc_main}, 190 {FUNC_TYPE_CIPHER,"des-ede",enc_main},
155#endif 191#endif
156#ifndef NO_DES 192#ifndef OPENSSL_NO_DES
157 {FUNC_TYPE_CIPHER,"des-ede3",enc_main}, 193 {FUNC_TYPE_CIPHER,"des-ede3",enc_main},
158#endif 194#endif
159#ifndef NO_DES 195#ifndef OPENSSL_NO_DES
160 {FUNC_TYPE_CIPHER,"des-cbc",enc_main}, 196 {FUNC_TYPE_CIPHER,"des-cbc",enc_main},
161#endif 197#endif
162#ifndef NO_DES 198#ifndef OPENSSL_NO_DES
163 {FUNC_TYPE_CIPHER,"des-ede-cbc",enc_main}, 199 {FUNC_TYPE_CIPHER,"des-ede-cbc",enc_main},
164#endif 200#endif
165#ifndef NO_DES 201#ifndef OPENSSL_NO_DES
166 {FUNC_TYPE_CIPHER,"des-ede3-cbc",enc_main}, 202 {FUNC_TYPE_CIPHER,"des-ede3-cbc",enc_main},
167#endif 203#endif
168#ifndef NO_DES 204#ifndef OPENSSL_NO_DES
169 {FUNC_TYPE_CIPHER,"des-cfb",enc_main}, 205 {FUNC_TYPE_CIPHER,"des-cfb",enc_main},
170#endif 206#endif
171#ifndef NO_DES 207#ifndef OPENSSL_NO_DES
172 {FUNC_TYPE_CIPHER,"des-ede-cfb",enc_main}, 208 {FUNC_TYPE_CIPHER,"des-ede-cfb",enc_main},
173#endif 209#endif
174#ifndef NO_DES 210#ifndef OPENSSL_NO_DES
175 {FUNC_TYPE_CIPHER,"des-ede3-cfb",enc_main}, 211 {FUNC_TYPE_CIPHER,"des-ede3-cfb",enc_main},
176#endif 212#endif
177#ifndef NO_DES 213#ifndef OPENSSL_NO_DES
178 {FUNC_TYPE_CIPHER,"des-ofb",enc_main}, 214 {FUNC_TYPE_CIPHER,"des-ofb",enc_main},
179#endif 215#endif
180#ifndef NO_DES 216#ifndef OPENSSL_NO_DES
181 {FUNC_TYPE_CIPHER,"des-ede-ofb",enc_main}, 217 {FUNC_TYPE_CIPHER,"des-ede-ofb",enc_main},
182#endif 218#endif
183#ifndef NO_DES 219#ifndef OPENSSL_NO_DES
184 {FUNC_TYPE_CIPHER,"des-ede3-ofb",enc_main}, 220 {FUNC_TYPE_CIPHER,"des-ede3-ofb",enc_main},
185#endif 221#endif
186#ifndef NO_IDEA 222#ifndef OPENSSL_NO_IDEA
187 {FUNC_TYPE_CIPHER,"idea-cbc",enc_main}, 223 {FUNC_TYPE_CIPHER,"idea-cbc",enc_main},
188#endif 224#endif
189#ifndef NO_IDEA 225#ifndef OPENSSL_NO_IDEA
190 {FUNC_TYPE_CIPHER,"idea-ecb",enc_main}, 226 {FUNC_TYPE_CIPHER,"idea-ecb",enc_main},
191#endif 227#endif
192#ifndef NO_IDEA 228#ifndef OPENSSL_NO_IDEA
193 {FUNC_TYPE_CIPHER,"idea-cfb",enc_main}, 229 {FUNC_TYPE_CIPHER,"idea-cfb",enc_main},
194#endif 230#endif
195#ifndef NO_IDEA 231#ifndef OPENSSL_NO_IDEA
196 {FUNC_TYPE_CIPHER,"idea-ofb",enc_main}, 232 {FUNC_TYPE_CIPHER,"idea-ofb",enc_main},
197#endif 233#endif
198#ifndef NO_RC2 234#ifndef OPENSSL_NO_RC2
199 {FUNC_TYPE_CIPHER,"rc2-cbc",enc_main}, 235 {FUNC_TYPE_CIPHER,"rc2-cbc",enc_main},
200#endif 236#endif
201#ifndef NO_RC2 237#ifndef OPENSSL_NO_RC2
202 {FUNC_TYPE_CIPHER,"rc2-ecb",enc_main}, 238 {FUNC_TYPE_CIPHER,"rc2-ecb",enc_main},
203#endif 239#endif
204#ifndef NO_RC2 240#ifndef OPENSSL_NO_RC2
205 {FUNC_TYPE_CIPHER,"rc2-cfb",enc_main}, 241 {FUNC_TYPE_CIPHER,"rc2-cfb",enc_main},
206#endif 242#endif
207#ifndef NO_RC2 243#ifndef OPENSSL_NO_RC2
208 {FUNC_TYPE_CIPHER,"rc2-ofb",enc_main}, 244 {FUNC_TYPE_CIPHER,"rc2-ofb",enc_main},
209#endif 245#endif
210#ifndef NO_RC2 246#ifndef OPENSSL_NO_RC2
211 {FUNC_TYPE_CIPHER,"rc2-64-cbc",enc_main}, 247 {FUNC_TYPE_CIPHER,"rc2-64-cbc",enc_main},
212#endif 248#endif
213#ifndef NO_RC2 249#ifndef OPENSSL_NO_RC2
214 {FUNC_TYPE_CIPHER,"rc2-40-cbc",enc_main}, 250 {FUNC_TYPE_CIPHER,"rc2-40-cbc",enc_main},
215#endif 251#endif
216#ifndef NO_BF 252#ifndef OPENSSL_NO_BF
217 {FUNC_TYPE_CIPHER,"bf-cbc",enc_main}, 253 {FUNC_TYPE_CIPHER,"bf-cbc",enc_main},
218#endif 254#endif
219#ifndef NO_BF 255#ifndef OPENSSL_NO_BF
220 {FUNC_TYPE_CIPHER,"bf-ecb",enc_main}, 256 {FUNC_TYPE_CIPHER,"bf-ecb",enc_main},
221#endif 257#endif
222#ifndef NO_BF 258#ifndef OPENSSL_NO_BF
223 {FUNC_TYPE_CIPHER,"bf-cfb",enc_main}, 259 {FUNC_TYPE_CIPHER,"bf-cfb",enc_main},
224#endif 260#endif
225#ifndef NO_BF 261#ifndef OPENSSL_NO_BF
226 {FUNC_TYPE_CIPHER,"bf-ofb",enc_main}, 262 {FUNC_TYPE_CIPHER,"bf-ofb",enc_main},
227#endif 263#endif
228#ifndef NO_CAST 264#ifndef OPENSSL_NO_CAST
229 {FUNC_TYPE_CIPHER,"cast5-cbc",enc_main}, 265 {FUNC_TYPE_CIPHER,"cast5-cbc",enc_main},
230#endif 266#endif
231#ifndef NO_CAST 267#ifndef OPENSSL_NO_CAST
232 {FUNC_TYPE_CIPHER,"cast5-ecb",enc_main}, 268 {FUNC_TYPE_CIPHER,"cast5-ecb",enc_main},
233#endif 269#endif
234#ifndef NO_CAST 270#ifndef OPENSSL_NO_CAST
235 {FUNC_TYPE_CIPHER,"cast5-cfb",enc_main}, 271 {FUNC_TYPE_CIPHER,"cast5-cfb",enc_main},
236#endif 272#endif
237#ifndef NO_CAST 273#ifndef OPENSSL_NO_CAST
238 {FUNC_TYPE_CIPHER,"cast5-ofb",enc_main}, 274 {FUNC_TYPE_CIPHER,"cast5-ofb",enc_main},
239#endif 275#endif
240#ifndef NO_CAST 276#ifndef OPENSSL_NO_CAST
241 {FUNC_TYPE_CIPHER,"cast-cbc",enc_main}, 277 {FUNC_TYPE_CIPHER,"cast-cbc",enc_main},
242#endif 278#endif
243#ifndef NO_RC5 279#ifndef OPENSSL_NO_RC5
244 {FUNC_TYPE_CIPHER,"rc5-cbc",enc_main}, 280 {FUNC_TYPE_CIPHER,"rc5-cbc",enc_main},
245#endif 281#endif
246#ifndef NO_RC5 282#ifndef OPENSSL_NO_RC5
247 {FUNC_TYPE_CIPHER,"rc5-ecb",enc_main}, 283 {FUNC_TYPE_CIPHER,"rc5-ecb",enc_main},
248#endif 284#endif
249#ifndef NO_RC5 285#ifndef OPENSSL_NO_RC5
250 {FUNC_TYPE_CIPHER,"rc5-cfb",enc_main}, 286 {FUNC_TYPE_CIPHER,"rc5-cfb",enc_main},
251#endif 287#endif
252#ifndef NO_RC5 288#ifndef OPENSSL_NO_RC5
253 {FUNC_TYPE_CIPHER,"rc5-ofb",enc_main}, 289 {FUNC_TYPE_CIPHER,"rc5-ofb",enc_main},
254#endif 290#endif
255 {0,NULL,NULL} 291 {0,NULL,NULL}
diff --git a/src/lib/libssl/src/apps/progs.pl b/src/lib/libssl/src/apps/progs.pl
index 214025cd2d..d6a40edb91 100644
--- a/src/lib/libssl/src/apps/progs.pl
+++ b/src/lib/libssl/src/apps/progs.pl
@@ -28,15 +28,15 @@ foreach (@ARGV)
28 push(@files,$_); 28 push(@files,$_);
29 $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n"; 29 $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
30 if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/)) 30 if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
31 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))\n${str}#endif\n"; } 31 { print "#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))\n${str}#endif\n"; }
32 elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || ($_ =~ /^rsautl$/)) 32 elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || ($_ =~ /^rsautl$/))
33 { print "#ifndef NO_RSA\n${str}#endif\n"; } 33 { print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n"; }
34 elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/)) 34 elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
35 { print "#ifndef NO_DSA\n${str}#endif\n"; } 35 { print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n"; }
36 elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/)) 36 elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
37 { print "#ifndef NO_DH\n${str}#endif\n"; } 37 { print "#ifndef OPENSSL_NO_DH\n${str}#endif\n"; }
38 elsif ( ($_ =~ /^pkcs12$/)) 38 elsif ( ($_ =~ /^pkcs12$/))
39 { print "#if !defined(NO_DES) && !defined(NO_SHA1)\n${str}#endif\n"; } 39 { print "#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)\n${str}#endif\n"; }
40 else 40 else
41 { print $str; } 41 { print $str; }
42 } 42 }
@@ -44,10 +44,13 @@ foreach (@ARGV)
44foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160") 44foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
45 { 45 {
46 push(@files,$_); 46 push(@files,$_);
47 printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_; 47 printf "#ifndef OPENSSL_NO_".uc($_)."\n\t{FUNC_TYPE_MD,\"".$_."\",dgst_main},\n#endif\n";
48 } 48 }
49 49
50foreach ( 50foreach (
51 "aes-128-cbc", "aes-128-ecb",
52 "aes-192-cbc", "aes-192-ecb",
53 "aes-256-cbc", "aes-256-ecb",
51 "base64", 54 "base64",
52 "des", "des3", "desx", "idea", "rc4", "rc4-40", 55 "des", "des3", "desx", "idea", "rc4", "rc4-40",
53 "rc2", "bf", "cast", "rc5", 56 "rc2", "bf", "cast", "rc5",
@@ -64,13 +67,14 @@ foreach (
64 push(@files,$_); 67 push(@files,$_);
65 68
66 $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_); 69 $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
67 if ($_ =~ /des/) { $t="#ifndef NO_DES\n${t}#endif\n"; } 70 if ($_ =~ /des/) { $t="#ifndef OPENSSL_NO_DES\n${t}#endif\n"; }
68 elsif ($_ =~ /idea/) { $t="#ifndef NO_IDEA\n${t}#endif\n"; } 71 elsif ($_ =~ /aes/) { $t="#ifndef OPENSSL_NO_AES\n${t}#endif\n"; }
69 elsif ($_ =~ /rc4/) { $t="#ifndef NO_RC4\n${t}#endif\n"; } 72 elsif ($_ =~ /idea/) { $t="#ifndef OPENSSL_NO_IDEA\n${t}#endif\n"; }
70 elsif ($_ =~ /rc2/) { $t="#ifndef NO_RC2\n${t}#endif\n"; } 73 elsif ($_ =~ /rc4/) { $t="#ifndef OPENSSL_NO_RC4\n${t}#endif\n"; }
71 elsif ($_ =~ /bf/) { $t="#ifndef NO_BF\n${t}#endif\n"; } 74 elsif ($_ =~ /rc2/) { $t="#ifndef OPENSSL_NO_RC2\n${t}#endif\n"; }
72 elsif ($_ =~ /cast/) { $t="#ifndef NO_CAST\n${t}#endif\n"; } 75 elsif ($_ =~ /bf/) { $t="#ifndef OPENSSL_NO_BF\n${t}#endif\n"; }
73 elsif ($_ =~ /rc5/) { $t="#ifndef NO_RC5\n${t}#endif\n"; } 76 elsif ($_ =~ /cast/) { $t="#ifndef OPENSSL_NO_CAST\n${t}#endif\n"; }
77 elsif ($_ =~ /rc5/) { $t="#ifndef OPENSSL_NO_RC5\n${t}#endif\n"; }
74 print $t; 78 print $t;
75 } 79 }
76 80
diff --git a/src/lib/libssl/src/apps/rand.c b/src/lib/libssl/src/apps/rand.c
index 6add7bbd6c..f51f5bec35 100644
--- a/src/lib/libssl/src/apps/rand.c
+++ b/src/lib/libssl/src/apps/rand.c
@@ -1,4 +1,57 @@
1/* apps/rand.c */ 1/* apps/rand.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 */
2 55
3#include "apps.h" 56#include "apps.h"
4 57
@@ -9,7 +62,6 @@
9#include <openssl/bio.h> 62#include <openssl/bio.h>
10#include <openssl/err.h> 63#include <openssl/err.h>
11#include <openssl/rand.h> 64#include <openssl/rand.h>
12#include <openssl/engine.h>
13 65
14#undef PROG 66#undef PROG
15#define PROG rand_main 67#define PROG rand_main
@@ -40,6 +92,9 @@ int MAIN(int argc, char **argv)
40 if ((bio_err = BIO_new(BIO_s_file())) != NULL) 92 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
41 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT); 93 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
42 94
95 if (!load_config(bio_err, NULL))
96 goto err;
97
43 badopt = 0; 98 badopt = 0;
44 i = 0; 99 i = 0;
45 while (!badopt && argv[++i] != NULL) 100 while (!badopt && argv[++i] != NULL)
@@ -51,7 +106,7 @@ int MAIN(int argc, char **argv)
51 else 106 else
52 badopt = 1; 107 badopt = 1;
53 } 108 }
54 if (strcmp(argv[i], "-engine") == 0) 109 else if (strcmp(argv[i], "-engine") == 0)
55 { 110 {
56 if ((argv[i+1] != NULL) && (engine == NULL)) 111 if ((argv[i+1] != NULL) && (engine == NULL))
57 engine = argv[++i]; 112 engine = argv[++i];
@@ -95,29 +150,13 @@ int MAIN(int argc, char **argv)
95 BIO_printf(bio_err, "Usage: rand [options] num\n"); 150 BIO_printf(bio_err, "Usage: rand [options] num\n");
96 BIO_printf(bio_err, "where options are\n"); 151 BIO_printf(bio_err, "where options are\n");
97 BIO_printf(bio_err, "-out file - write to file\n"); 152 BIO_printf(bio_err, "-out file - write to file\n");
98 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); 153 BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n");
99 BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 154 BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
100 BIO_printf(bio_err, "-base64 - encode output\n"); 155 BIO_printf(bio_err, "-base64 - encode output\n");
101 goto err; 156 goto err;
102 } 157 }
103 158
104 if (engine != NULL) 159 e = setup_engine(bio_err, engine, 0);
105 {
106 if((e = ENGINE_by_id(engine)) == NULL)
107 {
108 BIO_printf(bio_err,"invalid engine \"%s\"\n",
109 engine);
110 goto err;
111 }
112 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
113 {
114 BIO_printf(bio_err,"can't use that engine\n");
115 goto err;
116 }
117 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
118 /* Free our "structural" reference. */
119 ENGINE_free(e);
120 }
121 160
122 app_RAND_load_file(NULL, bio_err, (inrand != NULL)); 161 app_RAND_load_file(NULL, bio_err, (inrand != NULL));
123 if (inrand != NULL) 162 if (inrand != NULL)
@@ -132,7 +171,7 @@ int MAIN(int argc, char **argv)
132 else 171 else
133 { 172 {
134 r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); 173 r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
135#ifdef VMS 174#ifdef OPENSSL_SYS_VMS
136 { 175 {
137 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 176 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
138 out = BIO_push(tmpbio, out); 177 out = BIO_push(tmpbio, out);
@@ -173,5 +212,6 @@ err:
173 ERR_print_errors(bio_err); 212 ERR_print_errors(bio_err);
174 if (out) 213 if (out)
175 BIO_free_all(out); 214 BIO_free_all(out);
215 apps_shutdown();
176 EXIT(ret); 216 EXIT(ret);
177 } 217 }
diff --git a/src/lib/libssl/src/apps/req.c b/src/lib/libssl/src/apps/req.c
index ca8dc87957..790aa90eb6 100644
--- a/src/lib/libssl/src/apps/req.c
+++ b/src/lib/libssl/src/apps/req.c
@@ -60,7 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <time.h> 61#include <time.h>
62#include <string.h> 62#include <string.h>
63#ifdef NO_STDIO 63#ifdef OPENSSL_NO_STDIO
64#define APPS_WIN16 64#define APPS_WIN16
65#endif 65#endif
66#include "apps.h" 66#include "apps.h"
@@ -73,7 +73,6 @@
73#include <openssl/x509v3.h> 73#include <openssl/x509v3.h>
74#include <openssl/objects.h> 74#include <openssl/objects.h>
75#include <openssl/pem.h> 75#include <openssl/pem.h>
76#include <openssl/engine.h>
77 76
78#define SECTION "req" 77#define SECTION "req"
79 78
@@ -85,6 +84,7 @@
85#define V3_EXTENSIONS "x509_extensions" 84#define V3_EXTENSIONS "x509_extensions"
86#define REQ_EXTENSIONS "req_extensions" 85#define REQ_EXTENSIONS "req_extensions"
87#define STRING_MASK "string_mask" 86#define STRING_MASK "string_mask"
87#define UTF8_IN "utf8"
88 88
89#define DEFAULT_KEY_LENGTH 512 89#define DEFAULT_KEY_LENGTH 512
90#define MIN_KEY_LENGTH 384 90#define MIN_KEY_LENGTH 384
@@ -102,36 +102,42 @@
102 * -nodes - no des encryption 102 * -nodes - no des encryption
103 * -config file - Load configuration file. 103 * -config file - Load configuration file.
104 * -key file - make a request using key in file (or use it for verification). 104 * -key file - make a request using key in file (or use it for verification).
105 * -keyform - key file format. 105 * -keyform arg - key file format.
106 * -rand file(s) - load the file(s) into the PRNG. 106 * -rand file(s) - load the file(s) into the PRNG.
107 * -newkey - make a key and a request. 107 * -newkey - make a key and a request.
108 * -modulus - print RSA modulus. 108 * -modulus - print RSA modulus.
109 * -pubkey - output Public Key.
109 * -x509 - output a self signed X509 structure instead. 110 * -x509 - output a self signed X509 structure instead.
110 * -asn1-kludge - output new certificate request in a format that some CA's 111 * -asn1-kludge - output new certificate request in a format that some CA's
111 * require. This format is wrong 112 * require. This format is wrong
112 */ 113 */
113 114
114static int make_REQ(X509_REQ *req,EVP_PKEY *pkey,int attribs); 115static int make_REQ(X509_REQ *req,EVP_PKEY *pkey,char *dn,int attribs,
116 unsigned long chtype);
117static int build_subject(X509_REQ *req, char *subj, unsigned long chtype);
115static int prompt_info(X509_REQ *req, 118static int prompt_info(X509_REQ *req,
116 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect, 119 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect,
117 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs); 120 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs,
121 unsigned long chtype);
118static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *sk, 122static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *sk,
119 STACK_OF(CONF_VALUE) *attr, int attribs); 123 STACK_OF(CONF_VALUE) *attr, int attribs,
124 unsigned long chtype);
120static int add_attribute_object(X509_REQ *req, char *text, 125static int add_attribute_object(X509_REQ *req, char *text,
121 char *def, char *value, int nid, int min, 126 char *def, char *value, int nid, int n_min,
122 int max); 127 int n_max, unsigned long chtype);
123static int add_DN_object(X509_NAME *n, char *text, char *def, char *value, 128static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
124 int nid,int min,int max); 129 int nid,int n_min,int n_max, unsigned long chtype);
125#ifndef NO_RSA 130#ifndef OPENSSL_NO_RSA
126static void MS_CALLBACK req_cb(int p,int n,void *arg); 131static void MS_CALLBACK req_cb(int p,int n,void *arg);
127#endif 132#endif
128static int req_check_len(int len,int min,int max); 133static int req_check_len(int len,int n_min,int n_max);
129static int check_end(char *str, char *end); 134static int check_end(char *str, char *end);
130#ifndef MONOLITH 135#ifndef MONOLITH
131static char *default_config_file=NULL; 136static char *default_config_file=NULL;
132static LHASH *config=NULL; 137static CONF *config=NULL;
133#endif 138#endif
134static LHASH *req_conf=NULL; 139static CONF *req_conf=NULL;
140static int batch=0;
135 141
136#define TYPE_RSA 1 142#define TYPE_RSA 1
137#define TYPE_DSA 2 143#define TYPE_DSA 2
@@ -142,34 +148,40 @@ int MAIN(int, char **);
142int MAIN(int argc, char **argv) 148int MAIN(int argc, char **argv)
143 { 149 {
144 ENGINE *e = NULL; 150 ENGINE *e = NULL;
145#ifndef NO_DSA 151#ifndef OPENSSL_NO_DSA
146 DSA *dsa_params=NULL; 152 DSA *dsa_params=NULL;
147#endif 153#endif
154 unsigned long nmflag = 0;
148 int ex=1,x509=0,days=30; 155 int ex=1,x509=0,days=30;
149 X509 *x509ss=NULL; 156 X509 *x509ss=NULL;
150 X509_REQ *req=NULL; 157 X509_REQ *req=NULL;
151 EVP_PKEY *pkey=NULL; 158 EVP_PKEY *pkey=NULL;
152 int i,badops=0,newreq=0,newkey= -1,pkey_type=0; 159 int i=0,badops=0,newreq=0,verbose=0,pkey_type=TYPE_RSA;
160 long newkey = -1;
153 BIO *in=NULL,*out=NULL; 161 BIO *in=NULL,*out=NULL;
154 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM; 162 int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM;
155 int nodes=0,kludge=0,newhdr=0; 163 int nodes=0,kludge=0,newhdr=0,subject=0,pubkey=0;
156 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL; 164 char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL;
157 char *engine=NULL; 165 char *engine=NULL;
158 char *extensions = NULL; 166 char *extensions = NULL;
159 char *req_exts = NULL; 167 char *req_exts = NULL;
160 EVP_CIPHER *cipher=NULL; 168 const EVP_CIPHER *cipher=NULL;
169 ASN1_INTEGER *serial = NULL;
161 int modulus=0; 170 int modulus=0;
162 char *inrand=NULL; 171 char *inrand=NULL;
163 char *passargin = NULL, *passargout = NULL; 172 char *passargin = NULL, *passargout = NULL;
164 char *passin = NULL, *passout = NULL; 173 char *passin = NULL, *passout = NULL;
165 char *p; 174 char *p;
175 char *subj = NULL;
166 const EVP_MD *md_alg=NULL,*digest=EVP_md5(); 176 const EVP_MD *md_alg=NULL,*digest=EVP_md5();
177 unsigned long chtype = MBSTRING_ASC;
167#ifndef MONOLITH 178#ifndef MONOLITH
168 MS_STATIC char config_name[256]; 179 MS_STATIC char config_name[256];
180 long errline;
169#endif 181#endif
170 182
171 req_conf = NULL; 183 req_conf = NULL;
172#ifndef NO_DES 184#ifndef OPENSSL_NO_DES
173 cipher=EVP_des_ede3_cbc(); 185 cipher=EVP_des_ede3_cbc();
174#endif 186#endif
175 apps_startup(); 187 apps_startup();
@@ -208,9 +220,12 @@ int MAIN(int argc, char **argv)
208 if (--argc < 1) goto bad; 220 if (--argc < 1) goto bad;
209 keyfile= *(++argv); 221 keyfile= *(++argv);
210 } 222 }
223 else if (strcmp(*argv,"-pubkey") == 0)
224 {
225 pubkey=1;
226 }
211 else if (strcmp(*argv,"-new") == 0) 227 else if (strcmp(*argv,"-new") == 0)
212 { 228 {
213 pkey_type=TYPE_RSA;
214 newreq=1; 229 newreq=1;
215 } 230 }
216 else if (strcmp(*argv,"-config") == 0) 231 else if (strcmp(*argv,"-config") == 0)
@@ -268,7 +283,7 @@ int MAIN(int argc, char **argv)
268 newkey= atoi(p); 283 newkey= atoi(p);
269 } 284 }
270 else 285 else
271#ifndef NO_DSA 286#ifndef OPENSSL_NO_DSA
272 if (strncmp("dsa:",p,4) == 0) 287 if (strncmp("dsa:",p,4) == 0)
273 { 288 {
274 X509 *xtmp=NULL; 289 X509 *xtmp=NULL;
@@ -291,7 +306,7 @@ int MAIN(int argc, char **argv)
291 goto end; 306 goto end;
292 } 307 }
293 308
294 dtmp=X509_get_pubkey(xtmp); 309 if ((dtmp=X509_get_pubkey(xtmp)) == NULL) goto end;
295 if (dtmp->type == EVP_PKEY_DSA) 310 if (dtmp->type == EVP_PKEY_DSA)
296 dsa_params=DSAparams_dup(dtmp->pkey.dsa); 311 dsa_params=DSAparams_dup(dtmp->pkey.dsa);
297 EVP_PKEY_free(dtmp); 312 EVP_PKEY_free(dtmp);
@@ -308,7 +323,7 @@ int MAIN(int argc, char **argv)
308 } 323 }
309 else 324 else
310#endif 325#endif
311#ifndef NO_DH 326#ifndef OPENSSL_NO_DH
312 if (strncmp("dh:",p,4) == 0) 327 if (strncmp("dh:",p,4) == 0)
313 { 328 {
314 pkey_type=TYPE_DH; 329 pkey_type=TYPE_DH;
@@ -320,6 +335,8 @@ int MAIN(int argc, char **argv)
320 335
321 newreq=1; 336 newreq=1;
322 } 337 }
338 else if (strcmp(*argv,"-batch") == 0)
339 batch=1;
323 else if (strcmp(*argv,"-newhdr") == 0) 340 else if (strcmp(*argv,"-newhdr") == 0)
324 newhdr=1; 341 newhdr=1;
325 else if (strcmp(*argv,"-modulus") == 0) 342 else if (strcmp(*argv,"-modulus") == 0)
@@ -330,6 +347,17 @@ int MAIN(int argc, char **argv)
330 nodes=1; 347 nodes=1;
331 else if (strcmp(*argv,"-noout") == 0) 348 else if (strcmp(*argv,"-noout") == 0)
332 noout=1; 349 noout=1;
350 else if (strcmp(*argv,"-verbose") == 0)
351 verbose=1;
352 else if (strcmp(*argv,"-utf8") == 0)
353 chtype = MBSTRING_UTF8;
354 else if (strcmp(*argv,"-nameopt") == 0)
355 {
356 if (--argc < 1) goto bad;
357 if (!set_name_ex(&nmflag, *(++argv))) goto bad;
358 }
359 else if (strcmp(*argv,"-subject") == 0)
360 subject=1;
333 else if (strcmp(*argv,"-text") == 0) 361 else if (strcmp(*argv,"-text") == 0)
334 text=1; 362 text=1;
335 else if (strcmp(*argv,"-x509") == 0) 363 else if (strcmp(*argv,"-x509") == 0)
@@ -338,12 +366,23 @@ int MAIN(int argc, char **argv)
338 kludge=1; 366 kludge=1;
339 else if (strcmp(*argv,"-no-asn1-kludge") == 0) 367 else if (strcmp(*argv,"-no-asn1-kludge") == 0)
340 kludge=0; 368 kludge=0;
369 else if (strcmp(*argv,"-subj") == 0)
370 {
371 if (--argc < 1) goto bad;
372 subj= *(++argv);
373 }
341 else if (strcmp(*argv,"-days") == 0) 374 else if (strcmp(*argv,"-days") == 0)
342 { 375 {
343 if (--argc < 1) goto bad; 376 if (--argc < 1) goto bad;
344 days= atoi(*(++argv)); 377 days= atoi(*(++argv));
345 if (days == 0) days=30; 378 if (days == 0) days=30;
346 } 379 }
380 else if (strcmp(*argv,"-set_serial") == 0)
381 {
382 if (--argc < 1) goto bad;
383 serial = s2i_ASN1_INTEGER(NULL, *(++argv));
384 if (!serial) goto bad;
385 }
347 else if ((md_alg=EVP_get_digestbyname(&((*argv)[1]))) != NULL) 386 else if ((md_alg=EVP_get_digestbyname(&((*argv)[1]))) != NULL)
348 { 387 {
349 /* ok */ 388 /* ok */
@@ -379,12 +418,15 @@ bad:
379 BIO_printf(bio_err," -in arg input file\n"); 418 BIO_printf(bio_err," -in arg input file\n");
380 BIO_printf(bio_err," -out arg output file\n"); 419 BIO_printf(bio_err," -out arg output file\n");
381 BIO_printf(bio_err," -text text form of request\n"); 420 BIO_printf(bio_err," -text text form of request\n");
421 BIO_printf(bio_err," -pubkey output public key\n");
382 BIO_printf(bio_err," -noout do not output REQ\n"); 422 BIO_printf(bio_err," -noout do not output REQ\n");
383 BIO_printf(bio_err," -verify verify signature on REQ\n"); 423 BIO_printf(bio_err," -verify verify signature on REQ\n");
384 BIO_printf(bio_err," -modulus RSA modulus\n"); 424 BIO_printf(bio_err," -modulus RSA modulus\n");
385 BIO_printf(bio_err," -nodes don't encrypt the output key\n"); 425 BIO_printf(bio_err," -nodes don't encrypt the output key\n");
386 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); 426 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device\n");
387 BIO_printf(bio_err," -key file use the private key contained in file\n"); 427 BIO_printf(bio_err," -subject output the request's subject\n");
428 BIO_printf(bio_err," -passin private key password source\n");
429 BIO_printf(bio_err," -key file use the private key contained in file\n");
388 BIO_printf(bio_err," -keyform arg key file format\n"); 430 BIO_printf(bio_err," -keyform arg key file format\n");
389 BIO_printf(bio_err," -keyout arg file to send the key to\n"); 431 BIO_printf(bio_err," -keyout arg file to send the key to\n");
390 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 432 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
@@ -392,17 +434,21 @@ bad:
392 BIO_printf(bio_err," the random number generator\n"); 434 BIO_printf(bio_err," the random number generator\n");
393 BIO_printf(bio_err," -newkey rsa:bits generate a new RSA key of 'bits' in size\n"); 435 BIO_printf(bio_err," -newkey rsa:bits generate a new RSA key of 'bits' in size\n");
394 BIO_printf(bio_err," -newkey dsa:file generate a new DSA key, parameters taken from CA in 'file'\n"); 436 BIO_printf(bio_err," -newkey dsa:file generate a new DSA key, parameters taken from CA in 'file'\n");
395 437 BIO_printf(bio_err," -[digest] Digest to sign with (md5, sha1, md2, mdc2, md4)\n");
396 BIO_printf(bio_err," -[digest] Digest to sign with (md5, sha1, md2, mdc2)\n");
397 BIO_printf(bio_err," -config file request template file.\n"); 438 BIO_printf(bio_err," -config file request template file.\n");
439 BIO_printf(bio_err," -subj arg set or modify request subject\n");
398 BIO_printf(bio_err," -new new request.\n"); 440 BIO_printf(bio_err," -new new request.\n");
441 BIO_printf(bio_err," -batch do not ask anything during request generation\n");
399 BIO_printf(bio_err," -x509 output a x509 structure instead of a cert. req.\n"); 442 BIO_printf(bio_err," -x509 output a x509 structure instead of a cert. req.\n");
400 BIO_printf(bio_err," -days number of days a x509 generated by -x509 is valid for.\n"); 443 BIO_printf(bio_err," -days number of days a certificate generated by -x509 is valid for.\n");
444 BIO_printf(bio_err," -set_serial serial number to use for a certificate generated by -x509.\n");
401 BIO_printf(bio_err," -newhdr output \"NEW\" in the header lines\n"); 445 BIO_printf(bio_err," -newhdr output \"NEW\" in the header lines\n");
402 BIO_printf(bio_err," -asn1-kludge Output the 'request' in a format that is wrong but some CA's\n"); 446 BIO_printf(bio_err," -asn1-kludge Output the 'request' in a format that is wrong but some CA's\n");
403 BIO_printf(bio_err," have been reported as requiring\n"); 447 BIO_printf(bio_err," have been reported as requiring\n");
404 BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n"); 448 BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n");
405 BIO_printf(bio_err," -reqexts .. specify request extension section (override value in config file)\n"); 449 BIO_printf(bio_err," -reqexts .. specify request extension section (override value in config file)\n");
450 BIO_printf(bio_err," -utf8 input characters are UTF8 (default ASCII)\n");
451 BIO_printf(bio_err," -nameopt arg - various certificate name options\n");
406 goto end; 452 goto end;
407 } 453 }
408 454
@@ -420,23 +466,26 @@ bad:
420 if (p == NULL) 466 if (p == NULL)
421 { 467 {
422 strcpy(config_name,X509_get_default_cert_area()); 468 strcpy(config_name,X509_get_default_cert_area());
423#ifndef VMS 469#ifndef OPENSSL_SYS_VMS
424 strcat(config_name,"/"); 470 strcat(config_name,"/");
425#endif 471#endif
426 strcat(config_name,OPENSSL_CONF); 472 strcat(config_name,OPENSSL_CONF);
427 p=config_name; 473 p=config_name;
428 } 474 }
429 default_config_file=p; 475 default_config_file=p;
430 config=CONF_load(config,p,NULL); 476 config=NCONF_new(NULL);
477 i=NCONF_load(config, p, &errline);
431#endif 478#endif
432 479
433 if (template != NULL) 480 if (template != NULL)
434 { 481 {
435 long errline; 482 long errline;
436 483
437 BIO_printf(bio_err,"Using configuration from %s\n",template); 484 if( verbose )
438 req_conf=CONF_load(NULL,template,&errline); 485 BIO_printf(bio_err,"Using configuration from %s\n",template);
439 if (req_conf == NULL) 486 req_conf=NCONF_new(NULL);
487 i=NCONF_load(req_conf,template,&errline);
488 if (i == 0)
440 { 489 {
441 BIO_printf(bio_err,"error on line %ld of %s\n",errline,template); 490 BIO_printf(bio_err,"error on line %ld of %s\n",errline,template);
442 goto end; 491 goto end;
@@ -445,7 +494,8 @@ bad:
445 else 494 else
446 { 495 {
447 req_conf=config; 496 req_conf=config;
448 BIO_printf(bio_err,"Using configuration from %s\n", 497 if( verbose )
498 BIO_printf(bio_err,"Using configuration from %s\n",
449 default_config_file); 499 default_config_file);
450 if (req_conf == NULL) 500 if (req_conf == NULL)
451 { 501 {
@@ -455,7 +505,11 @@ bad:
455 505
456 if (req_conf != NULL) 506 if (req_conf != NULL)
457 { 507 {
458 p=CONF_get_string(req_conf,NULL,"oid_file"); 508 if (!load_config(bio_err, req_conf))
509 goto end;
510 p=NCONF_get_string(req_conf,NULL,"oid_file");
511 if (p == NULL)
512 ERR_clear_error();
459 if (p != NULL) 513 if (p != NULL)
460 { 514 {
461 BIO *oid_bio; 515 BIO *oid_bio;
@@ -475,23 +529,32 @@ bad:
475 } 529 }
476 } 530 }
477 } 531 }
478 if(!add_oid_section(bio_err, req_conf)) goto end; 532 if(!add_oid_section(bio_err, req_conf)) goto end;
479 533
480 if ((md_alg == NULL) && 534 if (md_alg == NULL)
481 ((p=CONF_get_string(req_conf,SECTION,"default_md")) != NULL))
482 { 535 {
483 if ((md_alg=EVP_get_digestbyname(p)) != NULL) 536 p=NCONF_get_string(req_conf,SECTION,"default_md");
484 digest=md_alg; 537 if (p == NULL)
538 ERR_clear_error();
539 if (p != NULL)
540 {
541 if ((md_alg=EVP_get_digestbyname(p)) != NULL)
542 digest=md_alg;
543 }
485 } 544 }
486 545
487 if(!extensions) 546 if (!extensions)
488 extensions = CONF_get_string(req_conf, SECTION, V3_EXTENSIONS); 547 {
489 if(extensions) { 548 extensions = NCONF_get_string(req_conf, SECTION, V3_EXTENSIONS);
549 if (!extensions)
550 ERR_clear_error();
551 }
552 if (extensions) {
490 /* Check syntax of file */ 553 /* Check syntax of file */
491 X509V3_CTX ctx; 554 X509V3_CTX ctx;
492 X509V3_set_ctx_test(&ctx); 555 X509V3_set_ctx_test(&ctx);
493 X509V3_set_conf_lhash(&ctx, req_conf); 556 X509V3_set_nconf(&ctx, req_conf);
494 if(!X509V3_EXT_add_conf(req_conf, &ctx, extensions, NULL)) { 557 if(!X509V3_EXT_add_nconf(req_conf, &ctx, extensions, NULL)) {
495 BIO_printf(bio_err, 558 BIO_printf(bio_err,
496 "Error Loading extension section %s\n", extensions); 559 "Error Loading extension section %s\n", extensions);
497 goto end; 560 goto end;
@@ -499,26 +562,50 @@ bad:
499 } 562 }
500 563
501 if(!passin) 564 if(!passin)
502 passin = CONF_get_string(req_conf, SECTION, "input_password"); 565 {
503 566 passin = NCONF_get_string(req_conf, SECTION, "input_password");
567 if (!passin)
568 ERR_clear_error();
569 }
570
504 if(!passout) 571 if(!passout)
505 passout = CONF_get_string(req_conf, SECTION, "output_password"); 572 {
573 passout = NCONF_get_string(req_conf, SECTION, "output_password");
574 if (!passout)
575 ERR_clear_error();
576 }
506 577
507 p = CONF_get_string(req_conf, SECTION, STRING_MASK); 578 p = NCONF_get_string(req_conf, SECTION, STRING_MASK);
579 if (!p)
580 ERR_clear_error();
508 581
509 if(p && !ASN1_STRING_set_default_mask_asc(p)) { 582 if(p && !ASN1_STRING_set_default_mask_asc(p)) {
510 BIO_printf(bio_err, "Invalid global string mask setting %s\n", p); 583 BIO_printf(bio_err, "Invalid global string mask setting %s\n", p);
511 goto end; 584 goto end;
512 } 585 }
513 586
587 if (chtype != MBSTRING_UTF8)
588 {
589 p = NCONF_get_string(req_conf, SECTION, UTF8_IN);
590 if (!p)
591 ERR_clear_error();
592 else if (!strcmp(p, "yes"))
593 chtype = MBSTRING_UTF8;
594 }
595
596
514 if(!req_exts) 597 if(!req_exts)
515 req_exts = CONF_get_string(req_conf, SECTION, REQ_EXTENSIONS); 598 {
599 req_exts = NCONF_get_string(req_conf, SECTION, REQ_EXTENSIONS);
600 if (!req_exts)
601 ERR_clear_error();
602 }
516 if(req_exts) { 603 if(req_exts) {
517 /* Check syntax of file */ 604 /* Check syntax of file */
518 X509V3_CTX ctx; 605 X509V3_CTX ctx;
519 X509V3_set_ctx_test(&ctx); 606 X509V3_set_ctx_test(&ctx);
520 X509V3_set_conf_lhash(&ctx, req_conf); 607 X509V3_set_nconf(&ctx, req_conf);
521 if(!X509V3_EXT_add_conf(req_conf, &ctx, req_exts, NULL)) { 608 if(!X509V3_EXT_add_nconf(req_conf, &ctx, req_exts, NULL)) {
522 BIO_printf(bio_err, 609 BIO_printf(bio_err,
523 "Error Loading request extension section %s\n", 610 "Error Loading request extension section %s\n",
524 req_exts); 611 req_exts);
@@ -531,80 +618,39 @@ bad:
531 if ((in == NULL) || (out == NULL)) 618 if ((in == NULL) || (out == NULL))
532 goto end; 619 goto end;
533 620
534 if (engine != NULL) 621 e = setup_engine(bio_err, engine, 0);
535 {
536 if((e = ENGINE_by_id(engine)) == NULL)
537 {
538 BIO_printf(bio_err,"invalid engine \"%s\"\n",
539 engine);
540 goto end;
541 }
542 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
543 {
544 BIO_printf(bio_err,"can't use that engine\n");
545 goto end;
546 }
547 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
548 /* Free our "structural" reference. */
549 ENGINE_free(e);
550 }
551 622
552 if (keyfile != NULL) 623 if (keyfile != NULL)
553 { 624 {
554 if (keyform == FORMAT_ENGINE) 625 pkey = load_key(bio_err, keyfile, keyform, passin, e,
555 { 626 "Private Key");
556 if (!e) 627 if (!pkey)
557 {
558 BIO_printf(bio_err,"no engine specified\n");
559 goto end;
560 }
561 pkey = ENGINE_load_private_key(e, keyfile, NULL);
562 }
563 else
564 {
565 if (BIO_read_filename(in,keyfile) <= 0)
566 {
567 perror(keyfile);
568 goto end;
569 }
570
571 if (keyform == FORMAT_ASN1)
572 pkey=d2i_PrivateKey_bio(in,NULL);
573 else if (keyform == FORMAT_PEM)
574 {
575 pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,
576 passin);
577 }
578 else
579 {
580 BIO_printf(bio_err,"bad input format specified for X509 request\n");
581 goto end;
582 }
583 }
584
585 if (pkey == NULL)
586 { 628 {
587 BIO_printf(bio_err,"unable to load Private key\n"); 629 /* load_key() has already printed an appropriate
630 message */
588 goto end; 631 goto end;
589 } 632 }
590 if (EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA) 633 if (EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA)
591 { 634 {
592 char *randfile = CONF_get_string(req_conf,SECTION,"RANDFILE"); 635 char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
636 if (randfile == NULL)
637 ERR_clear_error();
593 app_RAND_load_file(randfile, bio_err, 0); 638 app_RAND_load_file(randfile, bio_err, 0);
594 } 639 }
595 } 640 }
596 641
597 if (newreq && (pkey == NULL)) 642 if (newreq && (pkey == NULL))
598 { 643 {
599 char *randfile = CONF_get_string(req_conf,SECTION,"RANDFILE"); 644 char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
645 if (randfile == NULL)
646 ERR_clear_error();
600 app_RAND_load_file(randfile, bio_err, 0); 647 app_RAND_load_file(randfile, bio_err, 0);
601 if (inrand) 648 if (inrand)
602 app_RAND_load_files(inrand); 649 app_RAND_load_files(inrand);
603 650
604 if (newkey <= 0) 651 if (newkey <= 0)
605 { 652 {
606 newkey=(int)CONF_get_number(req_conf,SECTION,BITS); 653 if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
607 if (newkey <= 0)
608 newkey=DEFAULT_KEY_LENGTH; 654 newkey=DEFAULT_KEY_LENGTH;
609 } 655 }
610 656
@@ -619,7 +665,7 @@ bad:
619 665
620 if ((pkey=EVP_PKEY_new()) == NULL) goto end; 666 if ((pkey=EVP_PKEY_new()) == NULL) goto end;
621 667
622#ifndef NO_RSA 668#ifndef OPENSSL_NO_RSA
623 if (pkey_type == TYPE_RSA) 669 if (pkey_type == TYPE_RSA)
624 { 670 {
625 if (!EVP_PKEY_assign_RSA(pkey, 671 if (!EVP_PKEY_assign_RSA(pkey,
@@ -629,7 +675,7 @@ bad:
629 } 675 }
630 else 676 else
631#endif 677#endif
632#ifndef NO_DSA 678#ifndef OPENSSL_NO_DSA
633 if (pkey_type == TYPE_DSA) 679 if (pkey_type == TYPE_DSA)
634 { 680 {
635 if (!DSA_generate_key(dsa_params)) goto end; 681 if (!DSA_generate_key(dsa_params)) goto end;
@@ -643,13 +689,17 @@ bad:
643 if (pkey == NULL) goto end; 689 if (pkey == NULL) goto end;
644 690
645 if (keyout == NULL) 691 if (keyout == NULL)
646 keyout=CONF_get_string(req_conf,SECTION,KEYFILE); 692 {
647 693 keyout=NCONF_get_string(req_conf,SECTION,KEYFILE);
694 if (keyout == NULL)
695 ERR_clear_error();
696 }
697
648 if (keyout == NULL) 698 if (keyout == NULL)
649 { 699 {
650 BIO_printf(bio_err,"writing new private key to stdout\n"); 700 BIO_printf(bio_err,"writing new private key to stdout\n");
651 BIO_set_fp(out,stdout,BIO_NOCLOSE); 701 BIO_set_fp(out,stdout,BIO_NOCLOSE);
652#ifdef VMS 702#ifdef OPENSSL_SYS_VMS
653 { 703 {
654 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 704 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
655 out = BIO_push(tmpbio, out); 705 out = BIO_push(tmpbio, out);
@@ -666,9 +716,14 @@ bad:
666 } 716 }
667 } 717 }
668 718
669 p=CONF_get_string(req_conf,SECTION,"encrypt_rsa_key"); 719 p=NCONF_get_string(req_conf,SECTION,"encrypt_rsa_key");
670 if (p == NULL) 720 if (p == NULL)
671 p=CONF_get_string(req_conf,SECTION,"encrypt_key"); 721 {
722 ERR_clear_error();
723 p=NCONF_get_string(req_conf,SECTION,"encrypt_key");
724 if (p == NULL)
725 ERR_clear_error();
726 }
672 if ((p != NULL) && (strcmp(p,"no") == 0)) 727 if ((p != NULL) && (strcmp(p,"no") == 0))
673 cipher=NULL; 728 cipher=NULL;
674 if (nodes) cipher=NULL; 729 if (nodes) cipher=NULL;
@@ -730,7 +785,7 @@ loop:
730 BIO_printf(bio_err,"you need to specify a private key\n"); 785 BIO_printf(bio_err,"you need to specify a private key\n");
731 goto end; 786 goto end;
732 } 787 }
733#ifndef NO_DSA 788#ifndef OPENSSL_NO_DSA
734 if (pkey->type == EVP_PKEY_DSA) 789 if (pkey->type == EVP_PKEY_DSA)
735 digest=EVP_dss1(); 790 digest=EVP_dss1();
736#endif 791#endif
@@ -742,9 +797,13 @@ loop:
742 goto end; 797 goto end;
743 } 798 }
744 799
745 i=make_REQ(req,pkey,!x509); 800 i=make_REQ(req,pkey,subj,!x509, chtype);
746 if (kludge >= 0) 801 subj=NULL; /* done processing '-subj' option */
747 req->req_info->req_kludge=kludge; 802 if ((kludge > 0) && !sk_X509_ATTRIBUTE_num(req->req_info->attributes))
803 {
804 sk_X509_ATTRIBUTE_free(req->req_info->attributes);
805 req->req_info->attributes = NULL;
806 }
748 if (!i) 807 if (!i)
749 { 808 {
750 BIO_printf(bio_err,"problems making Certificate Request\n"); 809 BIO_printf(bio_err,"problems making Certificate Request\n");
@@ -759,34 +818,38 @@ loop:
759 818
760 /* Set version to V3 */ 819 /* Set version to V3 */
761 if(!X509_set_version(x509ss, 2)) goto end; 820 if(!X509_set_version(x509ss, 2)) goto end;
762 ASN1_INTEGER_set(X509_get_serialNumber(x509ss),0L); 821 if (serial)
763 822 {
764 X509_set_issuer_name(x509ss, 823 if (!X509_set_serialNumber(x509ss, serial)) goto end;
765 X509_REQ_get_subject_name(req)); 824 }
766 X509_gmtime_adj(X509_get_notBefore(x509ss),0); 825 else
767 X509_gmtime_adj(X509_get_notAfter(x509ss), 826 {
768 (long)60*60*24*days); 827 if (!ASN1_INTEGER_set(X509_get_serialNumber(x509ss),0L)) goto end;
769 X509_set_subject_name(x509ss, 828 }
770 X509_REQ_get_subject_name(req)); 829
830 if (!X509_set_issuer_name(x509ss, X509_REQ_get_subject_name(req))) goto end;
831 if (!X509_gmtime_adj(X509_get_notBefore(x509ss),0)) goto end;
832 if (!X509_gmtime_adj(X509_get_notAfter(x509ss), (long)60*60*24*days)) goto end;
833 if (!X509_set_subject_name(x509ss, X509_REQ_get_subject_name(req))) goto end;
771 tmppkey = X509_REQ_get_pubkey(req); 834 tmppkey = X509_REQ_get_pubkey(req);
772 X509_set_pubkey(x509ss,tmppkey); 835 if (!tmppkey || !X509_set_pubkey(x509ss,tmppkey)) goto end;
773 EVP_PKEY_free(tmppkey); 836 EVP_PKEY_free(tmppkey);
774 837
775 /* Set up V3 context struct */ 838 /* Set up V3 context struct */
776 839
777 X509V3_set_ctx(&ext_ctx, x509ss, x509ss, NULL, NULL, 0); 840 X509V3_set_ctx(&ext_ctx, x509ss, x509ss, NULL, NULL, 0);
778 X509V3_set_conf_lhash(&ext_ctx, req_conf); 841 X509V3_set_nconf(&ext_ctx, req_conf);
779 842
780 /* Add extensions */ 843 /* Add extensions */
781 if(extensions && !X509V3_EXT_add_conf(req_conf, 844 if(extensions && !X509V3_EXT_add_nconf(req_conf,
782 &ext_ctx, extensions, x509ss)) 845 &ext_ctx, extensions, x509ss))
783 { 846 {
784 BIO_printf(bio_err, 847 BIO_printf(bio_err,
785 "Error Loading extension section %s\n", 848 "Error Loading extension section %s\n",
786 extensions); 849 extensions);
787 goto end; 850 goto end;
788 } 851 }
789 852
790 if (!(i=X509_sign(x509ss,pkey,digest))) 853 if (!(i=X509_sign(x509ss,pkey,digest)))
791 goto end; 854 goto end;
792 } 855 }
@@ -797,22 +860,51 @@ loop:
797 /* Set up V3 context struct */ 860 /* Set up V3 context struct */
798 861
799 X509V3_set_ctx(&ext_ctx, NULL, NULL, req, NULL, 0); 862 X509V3_set_ctx(&ext_ctx, NULL, NULL, req, NULL, 0);
800 X509V3_set_conf_lhash(&ext_ctx, req_conf); 863 X509V3_set_nconf(&ext_ctx, req_conf);
801 864
802 /* Add extensions */ 865 /* Add extensions */
803 if(req_exts && !X509V3_EXT_REQ_add_conf(req_conf, 866 if(req_exts && !X509V3_EXT_REQ_add_nconf(req_conf,
804 &ext_ctx, req_exts, req)) 867 &ext_ctx, req_exts, req))
805 { 868 {
806 BIO_printf(bio_err, 869 BIO_printf(bio_err,
807 "Error Loading extension section %s\n", 870 "Error Loading extension section %s\n",
808 req_exts); 871 req_exts);
809 goto end; 872 goto end;
810 } 873 }
811 if (!(i=X509_REQ_sign(req,pkey,digest))) 874 if (!(i=X509_REQ_sign(req,pkey,digest)))
812 goto end; 875 goto end;
813 } 876 }
814 } 877 }
815 878
879 if (subj && x509)
880 {
881 BIO_printf(bio_err, "Cannot modifiy certificate subject\n");
882 goto end;
883 }
884
885 if (subj && !x509)
886 {
887 if (verbose)
888 {
889 BIO_printf(bio_err, "Modifying Request's Subject\n");
890 print_name(bio_err, "old subject=", X509_REQ_get_subject_name(req), nmflag);
891 }
892
893 if (build_subject(req, subj, chtype) == 0)
894 {
895 BIO_printf(bio_err, "ERROR: cannot modify subject\n");
896 ex=1;
897 goto end;
898 }
899
900 req->req_info->enc.modified = 1;
901
902 if (verbose)
903 {
904 print_name(bio_err, "new subject=", X509_REQ_get_subject_name(req), nmflag);
905 }
906 }
907
816 if (verify && !x509) 908 if (verify && !x509)
817 { 909 {
818 int tmp=0; 910 int tmp=0;
@@ -837,12 +929,13 @@ loop:
837 else if (i == 0) 929 else if (i == 0)
838 { 930 {
839 BIO_printf(bio_err,"verify failure\n"); 931 BIO_printf(bio_err,"verify failure\n");
932 ERR_print_errors(bio_err);
840 } 933 }
841 else /* if (i > 0) */ 934 else /* if (i > 0) */
842 BIO_printf(bio_err,"verify OK\n"); 935 BIO_printf(bio_err,"verify OK\n");
843 } 936 }
844 937
845 if (noout && !text && !modulus) 938 if (noout && !text && !modulus && !subject && !pubkey)
846 { 939 {
847 ex=0; 940 ex=0;
848 goto end; 941 goto end;
@@ -851,7 +944,7 @@ loop:
851 if (outfile == NULL) 944 if (outfile == NULL)
852 { 945 {
853 BIO_set_fp(out,stdout,BIO_NOCLOSE); 946 BIO_set_fp(out,stdout,BIO_NOCLOSE);
854#ifdef VMS 947#ifdef OPENSSL_SYS_VMS
855 { 948 {
856 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 949 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
857 out = BIO_push(tmpbio, out); 950 out = BIO_push(tmpbio, out);
@@ -871,6 +964,20 @@ loop:
871 } 964 }
872 } 965 }
873 966
967 if (pubkey)
968 {
969 EVP_PKEY *tpubkey;
970 tpubkey=X509_REQ_get_pubkey(req);
971 if (tpubkey == NULL)
972 {
973 BIO_printf(bio_err,"Error getting public key\n");
974 ERR_print_errors(bio_err);
975 goto end;
976 }
977 PEM_write_bio_PUBKEY(out, tpubkey);
978 EVP_PKEY_free(tpubkey);
979 }
980
874 if (text) 981 if (text)
875 { 982 {
876 if (x509) 983 if (x509)
@@ -879,26 +986,35 @@ loop:
879 X509_REQ_print(out,req); 986 X509_REQ_print(out,req);
880 } 987 }
881 988
989 if(subject)
990 {
991 if(x509)
992 print_name(out, "subject=", X509_get_subject_name(x509ss), nmflag);
993 else
994 print_name(out, "subject=", X509_REQ_get_subject_name(req), nmflag);
995 }
996
882 if (modulus) 997 if (modulus)
883 { 998 {
884 EVP_PKEY *pubkey; 999 EVP_PKEY *tpubkey;
885 1000
886 if (x509) 1001 if (x509)
887 pubkey=X509_get_pubkey(x509ss); 1002 tpubkey=X509_get_pubkey(x509ss);
888 else 1003 else
889 pubkey=X509_REQ_get_pubkey(req); 1004 tpubkey=X509_REQ_get_pubkey(req);
890 if (pubkey == NULL) 1005 if (tpubkey == NULL)
891 { 1006 {
892 fprintf(stdout,"Modulus=unavailable\n"); 1007 fprintf(stdout,"Modulus=unavailable\n");
893 goto end; 1008 goto end;
894 } 1009 }
895 fprintf(stdout,"Modulus="); 1010 fprintf(stdout,"Modulus=");
896#ifndef NO_RSA 1011#ifndef OPENSSL_NO_RSA
897 if (pubkey->type == EVP_PKEY_RSA) 1012 if (tpubkey->type == EVP_PKEY_RSA)
898 BN_print(out,pubkey->pkey.rsa->n); 1013 BN_print(out,tpubkey->pkey.rsa->n);
899 else 1014 else
900#endif 1015#endif
901 fprintf(stdout,"Wrong Algorithm type"); 1016 fprintf(stdout,"Wrong Algorithm type");
1017 EVP_PKEY_free(tpubkey);
902 fprintf(stdout,"\n"); 1018 fprintf(stdout,"\n");
903 } 1019 }
904 1020
@@ -941,51 +1057,59 @@ end:
941 { 1057 {
942 ERR_print_errors(bio_err); 1058 ERR_print_errors(bio_err);
943 } 1059 }
944 if ((req_conf != NULL) && (req_conf != config)) CONF_free(req_conf); 1060 if ((req_conf != NULL) && (req_conf != config)) NCONF_free(req_conf);
945 BIO_free(in); 1061 BIO_free(in);
946 BIO_free_all(out); 1062 BIO_free_all(out);
947 EVP_PKEY_free(pkey); 1063 EVP_PKEY_free(pkey);
948 X509_REQ_free(req); 1064 X509_REQ_free(req);
949 X509_free(x509ss); 1065 X509_free(x509ss);
1066 ASN1_INTEGER_free(serial);
950 if(passargin && passin) OPENSSL_free(passin); 1067 if(passargin && passin) OPENSSL_free(passin);
951 if(passargout && passout) OPENSSL_free(passout); 1068 if(passargout && passout) OPENSSL_free(passout);
952 OBJ_cleanup(); 1069 OBJ_cleanup();
953#ifndef NO_DSA 1070#ifndef OPENSSL_NO_DSA
954 if (dsa_params != NULL) DSA_free(dsa_params); 1071 if (dsa_params != NULL) DSA_free(dsa_params);
955#endif 1072#endif
1073 apps_shutdown();
956 EXIT(ex); 1074 EXIT(ex);
957 } 1075 }
958 1076
959static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs) 1077static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs,
1078 unsigned long chtype)
960 { 1079 {
961 int ret=0,i; 1080 int ret=0,i;
962 char no_prompt = 0; 1081 char no_prompt = 0;
963 STACK_OF(CONF_VALUE) *dn_sk, *attr_sk = NULL; 1082 STACK_OF(CONF_VALUE) *dn_sk, *attr_sk = NULL;
964 char *tmp, *dn_sect,*attr_sect; 1083 char *tmp, *dn_sect,*attr_sect;
965 1084
966 tmp=CONF_get_string(req_conf,SECTION,PROMPT); 1085 tmp=NCONF_get_string(req_conf,SECTION,PROMPT);
1086 if (tmp == NULL)
1087 ERR_clear_error();
967 if((tmp != NULL) && !strcmp(tmp, "no")) no_prompt = 1; 1088 if((tmp != NULL) && !strcmp(tmp, "no")) no_prompt = 1;
968 1089
969 dn_sect=CONF_get_string(req_conf,SECTION,DISTINGUISHED_NAME); 1090 dn_sect=NCONF_get_string(req_conf,SECTION,DISTINGUISHED_NAME);
970 if (dn_sect == NULL) 1091 if (dn_sect == NULL)
971 { 1092 {
972 BIO_printf(bio_err,"unable to find '%s' in config\n", 1093 BIO_printf(bio_err,"unable to find '%s' in config\n",
973 DISTINGUISHED_NAME); 1094 DISTINGUISHED_NAME);
974 goto err; 1095 goto err;
975 } 1096 }
976 dn_sk=CONF_get_section(req_conf,dn_sect); 1097 dn_sk=NCONF_get_section(req_conf,dn_sect);
977 if (dn_sk == NULL) 1098 if (dn_sk == NULL)
978 { 1099 {
979 BIO_printf(bio_err,"unable to get '%s' section\n",dn_sect); 1100 BIO_printf(bio_err,"unable to get '%s' section\n",dn_sect);
980 goto err; 1101 goto err;
981 } 1102 }
982 1103
983 attr_sect=CONF_get_string(req_conf,SECTION,ATTRIBUTES); 1104 attr_sect=NCONF_get_string(req_conf,SECTION,ATTRIBUTES);
984 if (attr_sect == NULL) 1105 if (attr_sect == NULL)
1106 {
1107 ERR_clear_error();
985 attr_sk=NULL; 1108 attr_sk=NULL;
1109 }
986 else 1110 else
987 { 1111 {
988 attr_sk=CONF_get_section(req_conf,attr_sect); 1112 attr_sk=NCONF_get_section(req_conf,attr_sect);
989 if (attr_sk == NULL) 1113 if (attr_sk == NULL)
990 { 1114 {
991 BIO_printf(bio_err,"unable to get '%s' section\n",attr_sect); 1115 BIO_printf(bio_err,"unable to get '%s' section\n",attr_sect);
@@ -996,37 +1120,172 @@ static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, int attribs)
996 /* setup version number */ 1120 /* setup version number */
997 if (!X509_REQ_set_version(req,0L)) goto err; /* version 1 */ 1121 if (!X509_REQ_set_version(req,0L)) goto err; /* version 1 */
998 1122
999 if(no_prompt) i = auto_info(req, dn_sk, attr_sk, attribs); 1123 if (no_prompt)
1000 else i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs); 1124 i = auto_info(req, dn_sk, attr_sk, attribs, chtype);
1125 else
1126 {
1127 if (subj)
1128 i = build_subject(req, subj, chtype);
1129 else
1130 i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs, chtype);
1131 }
1001 if(!i) goto err; 1132 if(!i) goto err;
1002 1133
1003 X509_REQ_set_pubkey(req,pkey); 1134 if (!X509_REQ_set_pubkey(req,pkey)) goto err;
1004 1135
1005 ret=1; 1136 ret=1;
1006err: 1137err:
1007 return(ret); 1138 return(ret);
1008 } 1139 }
1009 1140
1141/*
1142 * subject is expected to be in the format /type0=value0/type1=value1/type2=...
1143 * where characters may be escaped by \
1144 */
1145static int build_subject(X509_REQ *req, char *subject, unsigned long chtype)
1146 {
1147 size_t buflen = strlen (subject)+1; /* to copy the types and values into. due to escaping, the copy can only become shorter */
1148 char *buf = malloc (buflen);
1149 size_t max_ne = buflen / 2 + 1; /* maximum number of name elements */
1150 char **ne_types = malloc (max_ne * sizeof (char *));
1151 char **ne_values = malloc (max_ne * sizeof (char *));
1152
1153 char *sp = subject, *bp = buf;
1154 int i, ne_num = 0;
1155
1156 X509_NAME *n = NULL;
1157 int nid;
1158
1159 if (!buf || !ne_types || !ne_values)
1160 {
1161 BIO_printf(bio_err, "malloc error\n");
1162 goto error0;
1163 }
1164
1165 if (*subject != '/')
1166 {
1167 BIO_printf(bio_err, "Subject does not start with '/'.\n");
1168 goto error0;
1169 }
1170 sp++; /* skip leading / */
1171
1172 while (*sp)
1173 {
1174 /* collect type */
1175 ne_types[ne_num] = bp;
1176 while (*sp)
1177 {
1178 if (*sp == '\\') /* is there anything to escape in the type...? */
1179 if (*++sp)
1180 *bp++ = *sp++;
1181 else
1182 {
1183 BIO_printf(bio_err, "escape character at end of string\n");
1184 goto error0;
1185 }
1186 else if (*sp == '=')
1187 {
1188 sp++;
1189 *bp++ = '\0';
1190 break;
1191 }
1192 else
1193 *bp++ = *sp++;
1194 }
1195 if (!*sp)
1196 {
1197 BIO_printf(bio_err, "end of string encountered while processing type of subject name element #%d\n", ne_num);
1198 goto error0;
1199 }
1200 ne_values[ne_num] = bp;
1201 while (*sp)
1202 {
1203 if (*sp == '\\')
1204 if (*++sp)
1205 *bp++ = *sp++;
1206 else
1207 {
1208 BIO_printf(bio_err, "escape character at end of string\n");
1209 goto error0;
1210 }
1211 else if (*sp == '/')
1212 {
1213 sp++;
1214 *bp++ = '\0';
1215 break;
1216 }
1217 else
1218 *bp++ = *sp++;
1219 }
1220 *bp++ = '\0';
1221 ne_num++;
1222 }
1223
1224 if (!(n = X509_NAME_new()))
1225 goto error0;
1226
1227 for(i = 0; i < ne_num; i++)
1228 {
1229 if ((nid=OBJ_txt2nid(ne_types[i])) == NID_undef)
1230 {
1231 BIO_printf(bio_err, "Subject Attribute %s has no known NID, skipped\n", ne_types[i]);
1232 continue;
1233 }
1234
1235 if (!*ne_values[i])
1236 {
1237 BIO_printf(bio_err, "No value provided for Subject Attribute %s, skipped\n", ne_types[i]);
1238 continue;
1239 }
1240
1241 if (!X509_NAME_add_entry_by_NID(n, nid, chtype, (unsigned char*)ne_values[i], -1,-1,0))
1242 goto error1;
1243
1244 }
1245
1246 if (!X509_REQ_set_subject_name(req, n))
1247 goto error1;
1248 X509_NAME_free(n);
1249 free (ne_values);
1250 free (ne_types);
1251 free (buf);
1252 return 1;
1253
1254error1:
1255 X509_NAME_free(n);
1256error0:
1257 free (ne_values);
1258 free (ne_types);
1259 free (buf);
1260 return 0;
1261}
1262
1010 1263
1011static int prompt_info(X509_REQ *req, 1264static int prompt_info(X509_REQ *req,
1012 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect, 1265 STACK_OF(CONF_VALUE) *dn_sk, char *dn_sect,
1013 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs) 1266 STACK_OF(CONF_VALUE) *attr_sk, char *attr_sect, int attribs,
1267 unsigned long chtype)
1014 { 1268 {
1015 int i; 1269 int i;
1016 char *p,*q; 1270 char *p,*q;
1017 char buf[100]; 1271 char buf[100];
1018 int nid,min,max; 1272 int nid;
1273 long n_min,n_max;
1019 char *type,*def,*value; 1274 char *type,*def,*value;
1020 CONF_VALUE *v; 1275 CONF_VALUE *v;
1021 X509_NAME *subj; 1276 X509_NAME *subj;
1022 subj = X509_REQ_get_subject_name(req); 1277 subj = X509_REQ_get_subject_name(req);
1023 BIO_printf(bio_err,"You are about to be asked to enter information that will be incorporated\n"); 1278
1024 BIO_printf(bio_err,"into your certificate request.\n"); 1279 if(!batch)
1025 BIO_printf(bio_err,"What you are about to enter is what is called a Distinguished Name or a DN.\n"); 1280 {
1026 BIO_printf(bio_err,"There are quite a few fields but you can leave some blank\n"); 1281 BIO_printf(bio_err,"You are about to be asked to enter information that will be incorporated\n");
1027 BIO_printf(bio_err,"For some fields there will be a default value,\n"); 1282 BIO_printf(bio_err,"into your certificate request.\n");
1028 BIO_printf(bio_err,"If you enter '.', the field will be left blank.\n"); 1283 BIO_printf(bio_err,"What you are about to enter is what is called a Distinguished Name or a DN.\n");
1029 BIO_printf(bio_err,"-----\n"); 1284 BIO_printf(bio_err,"There are quite a few fields but you can leave some blank\n");
1285 BIO_printf(bio_err,"For some fields there will be a default value,\n");
1286 BIO_printf(bio_err,"If you enter '.', the field will be left blank.\n");
1287 BIO_printf(bio_err,"-----\n");
1288 }
1030 1289
1031 1290
1032 if (sk_CONF_VALUE_num(dn_sk)) 1291 if (sk_CONF_VALUE_num(dn_sk))
@@ -1056,21 +1315,29 @@ start: for (;;)
1056 /* If OBJ not recognised ignore it */ 1315 /* If OBJ not recognised ignore it */
1057 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start; 1316 if ((nid=OBJ_txt2nid(type)) == NID_undef) goto start;
1058 sprintf(buf,"%s_default",v->name); 1317 sprintf(buf,"%s_default",v->name);
1059 if ((def=CONF_get_string(req_conf,dn_sect,buf)) == NULL) 1318 if ((def=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
1319 {
1320 ERR_clear_error();
1060 def=""; 1321 def="";
1322 }
1061 1323
1062 sprintf(buf,"%s_value",v->name); 1324 sprintf(buf,"%s_value",v->name);
1063 if ((value=CONF_get_string(req_conf,dn_sect,buf)) == NULL) 1325 if ((value=NCONF_get_string(req_conf,dn_sect,buf)) == NULL)
1326 {
1327 ERR_clear_error();
1064 value=NULL; 1328 value=NULL;
1329 }
1065 1330
1066 sprintf(buf,"%s_min",v->name); 1331 sprintf(buf,"%s_min",v->name);
1067 min=(int)CONF_get_number(req_conf,dn_sect,buf); 1332 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min))
1333 n_min = -1;
1068 1334
1069 sprintf(buf,"%s_max",v->name); 1335 sprintf(buf,"%s_max",v->name);
1070 max=(int)CONF_get_number(req_conf,dn_sect,buf); 1336 if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max))
1337 n_max = -1;
1071 1338
1072 if (!add_DN_object(subj,v->value,def,value,nid, 1339 if (!add_DN_object(subj,v->value,def,value,nid,
1073 min,max)) 1340 n_min,n_max, chtype))
1074 return 0; 1341 return 0;
1075 } 1342 }
1076 if (X509_NAME_entry_count(subj) == 0) 1343 if (X509_NAME_entry_count(subj) == 0)
@@ -1081,7 +1348,7 @@ start: for (;;)
1081 1348
1082 if (attribs) 1349 if (attribs)
1083 { 1350 {
1084 if ((attr_sk != NULL) && (sk_CONF_VALUE_num(attr_sk) > 0)) 1351 if ((attr_sk != NULL) && (sk_CONF_VALUE_num(attr_sk) > 0) && (!batch))
1085 { 1352 {
1086 BIO_printf(bio_err,"\nPlease enter the following 'extra' attributes\n"); 1353 BIO_printf(bio_err,"\nPlease enter the following 'extra' attributes\n");
1087 BIO_printf(bio_err,"to be sent with your certificate request\n"); 1354 BIO_printf(bio_err,"to be sent with your certificate request\n");
@@ -1101,23 +1368,32 @@ start2: for (;;)
1101 goto start2; 1368 goto start2;
1102 1369
1103 sprintf(buf,"%s_default",type); 1370 sprintf(buf,"%s_default",type);
1104 if ((def=CONF_get_string(req_conf,attr_sect,buf)) 1371 if ((def=NCONF_get_string(req_conf,attr_sect,buf))
1105 == NULL) 1372 == NULL)
1373 {
1374 ERR_clear_error();
1106 def=""; 1375 def="";
1376 }
1377
1107 1378
1108 sprintf(buf,"%s_value",type); 1379 sprintf(buf,"%s_value",type);
1109 if ((value=CONF_get_string(req_conf,attr_sect,buf)) 1380 if ((value=NCONF_get_string(req_conf,attr_sect,buf))
1110 == NULL) 1381 == NULL)
1382 {
1383 ERR_clear_error();
1111 value=NULL; 1384 value=NULL;
1385 }
1112 1386
1113 sprintf(buf,"%s_min",type); 1387 sprintf(buf,"%s_min",type);
1114 min=(int)CONF_get_number(req_conf,attr_sect,buf); 1388 if (!NCONF_get_number(req_conf,attr_sect,buf, &n_min))
1389 n_min = -1;
1115 1390
1116 sprintf(buf,"%s_max",type); 1391 sprintf(buf,"%s_max",type);
1117 max=(int)CONF_get_number(req_conf,attr_sect,buf); 1392 if (!NCONF_get_number(req_conf,attr_sect,buf, &n_max))
1393 n_max = -1;
1118 1394
1119 if (!add_attribute_object(req, 1395 if (!add_attribute_object(req,
1120 v->value,def,value,nid,min,max)) 1396 v->value,def,value,nid,n_min,n_max, chtype))
1121 return 0; 1397 return 0;
1122 } 1398 }
1123 } 1399 }
@@ -1133,7 +1409,7 @@ start2: for (;;)
1133 } 1409 }
1134 1410
1135static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk, 1411static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
1136 STACK_OF(CONF_VALUE) *attr_sk, int attribs) 1412 STACK_OF(CONF_VALUE) *attr_sk, int attribs, unsigned long chtype)
1137 { 1413 {
1138 int i; 1414 int i;
1139 char *p,*q; 1415 char *p,*q;
@@ -1161,7 +1437,7 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
1161 if(*p) type = p; 1437 if(*p) type = p;
1162 break; 1438 break;
1163 } 1439 }
1164 if (!X509_NAME_add_entry_by_txt(subj,type, MBSTRING_ASC, 1440 if (!X509_NAME_add_entry_by_txt(subj,type, chtype,
1165 (unsigned char *) v->value,-1,-1,0)) return 0; 1441 (unsigned char *) v->value,-1,-1,0)) return 0;
1166 1442
1167 } 1443 }
@@ -1176,7 +1452,7 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
1176 for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++) 1452 for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++)
1177 { 1453 {
1178 v=sk_CONF_VALUE_value(attr_sk,i); 1454 v=sk_CONF_VALUE_value(attr_sk,i);
1179 if(!X509_REQ_add1_attr_by_txt(req, v->name, MBSTRING_ASC, 1455 if(!X509_REQ_add1_attr_by_txt(req, v->name, chtype,
1180 (unsigned char *)v->value, -1)) return 0; 1456 (unsigned char *)v->value, -1)) return 0;
1181 } 1457 }
1182 } 1458 }
@@ -1185,14 +1461,14 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
1185 1461
1186 1462
1187static int add_DN_object(X509_NAME *n, char *text, char *def, char *value, 1463static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
1188 int nid, int min, int max) 1464 int nid, int n_min, int n_max, unsigned long chtype)
1189 { 1465 {
1190 int i,ret=0; 1466 int i,ret=0;
1191 MS_STATIC char buf[1024]; 1467 MS_STATIC char buf[1024];
1192start: 1468start:
1193 BIO_printf(bio_err,"%s [%s]:",text,def); 1469 if (!batch) BIO_printf(bio_err,"%s [%s]:",text,def);
1194 (void)BIO_flush(bio_err); 1470 (void)BIO_flush(bio_err);
1195 if (value != NULL) 1471 if(value != NULL)
1196 { 1472 {
1197 strcpy(buf,value); 1473 strcpy(buf,value);
1198 strcat(buf,"\n"); 1474 strcat(buf,"\n");
@@ -1201,7 +1477,15 @@ start:
1201 else 1477 else
1202 { 1478 {
1203 buf[0]='\0'; 1479 buf[0]='\0';
1204 fgets(buf,1024,stdin); 1480 if (!batch)
1481 {
1482 fgets(buf,1024,stdin);
1483 }
1484 else
1485 {
1486 buf[0] = '\n';
1487 buf[1] = '\0';
1488 }
1205 } 1489 }
1206 1490
1207 if (buf[0] == '\0') return(0); 1491 if (buf[0] == '\0') return(0);
@@ -1221,12 +1505,11 @@ start:
1221 return(0); 1505 return(0);
1222 } 1506 }
1223 buf[--i]='\0'; 1507 buf[--i]='\0';
1224
1225#ifdef CHARSET_EBCDIC 1508#ifdef CHARSET_EBCDIC
1226 ebcdic2ascii(buf, buf, i); 1509 ebcdic2ascii(buf, buf, i);
1227#endif 1510#endif
1228 if(!req_check_len(i, min, max)) goto start; 1511 if(!req_check_len(i, n_min, n_max)) goto start;
1229 if (!X509_NAME_add_entry_by_NID(n,nid, MBSTRING_ASC, 1512 if (!X509_NAME_add_entry_by_NID(n,nid, chtype,
1230 (unsigned char *) buf, -1,-1,0)) goto err; 1513 (unsigned char *) buf, -1,-1,0)) goto err;
1231 ret=1; 1514 ret=1;
1232err: 1515err:
@@ -1234,14 +1517,14 @@ err:
1234 } 1517 }
1235 1518
1236static int add_attribute_object(X509_REQ *req, char *text, 1519static int add_attribute_object(X509_REQ *req, char *text,
1237 char *def, char *value, int nid, int min, 1520 char *def, char *value, int nid, int n_min,
1238 int max) 1521 int n_max, unsigned long chtype)
1239 { 1522 {
1240 int i; 1523 int i;
1241 static char buf[1024]; 1524 static char buf[1024];
1242 1525
1243start: 1526start:
1244 BIO_printf(bio_err,"%s [%s]:",text,def); 1527 if (!batch) BIO_printf(bio_err,"%s [%s]:",text,def);
1245 (void)BIO_flush(bio_err); 1528 (void)BIO_flush(bio_err);
1246 if (value != NULL) 1529 if (value != NULL)
1247 { 1530 {
@@ -1252,7 +1535,15 @@ start:
1252 else 1535 else
1253 { 1536 {
1254 buf[0]='\0'; 1537 buf[0]='\0';
1255 fgets(buf,1024,stdin); 1538 if (!batch)
1539 {
1540 fgets(buf,1024,stdin);
1541 }
1542 else
1543 {
1544 buf[0] = '\n';
1545 buf[1] = '\0';
1546 }
1256 } 1547 }
1257 1548
1258 if (buf[0] == '\0') return(0); 1549 if (buf[0] == '\0') return(0);
@@ -1275,9 +1566,9 @@ start:
1275#ifdef CHARSET_EBCDIC 1566#ifdef CHARSET_EBCDIC
1276 ebcdic2ascii(buf, buf, i); 1567 ebcdic2ascii(buf, buf, i);
1277#endif 1568#endif
1278 if(!req_check_len(i, min, max)) goto start; 1569 if(!req_check_len(i, n_min, n_max)) goto start;
1279 1570
1280 if(!X509_REQ_add1_attr_by_NID(req, nid, MBSTRING_ASC, 1571 if(!X509_REQ_add1_attr_by_NID(req, nid, chtype,
1281 (unsigned char *)buf, -1)) { 1572 (unsigned char *)buf, -1)) {
1282 BIO_printf(bio_err, "Error adding attribute\n"); 1573 BIO_printf(bio_err, "Error adding attribute\n");
1283 ERR_print_errors(bio_err); 1574 ERR_print_errors(bio_err);
@@ -1289,7 +1580,7 @@ err:
1289 return(0); 1580 return(0);
1290 } 1581 }
1291 1582
1292#ifndef NO_RSA 1583#ifndef OPENSSL_NO_RSA
1293static void MS_CALLBACK req_cb(int p, int n, void *arg) 1584static void MS_CALLBACK req_cb(int p, int n, void *arg)
1294 { 1585 {
1295 char c='*'; 1586 char c='*';
@@ -1306,16 +1597,16 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
1306 } 1597 }
1307#endif 1598#endif
1308 1599
1309static int req_check_len(int len, int min, int max) 1600static int req_check_len(int len, int n_min, int n_max)
1310 { 1601 {
1311 if (len < min) 1602 if ((n_min > 0) && (len < n_min))
1312 { 1603 {
1313 BIO_printf(bio_err,"string is too short, it needs to be at least %d bytes long\n",min); 1604 BIO_printf(bio_err,"string is too short, it needs to be at least %d bytes long\n",n_min);
1314 return(0); 1605 return(0);
1315 } 1606 }
1316 if ((max != 0) && (len > max)) 1607 if ((n_max >= 0) && (len > n_max))
1317 { 1608 {
1318 BIO_printf(bio_err,"string is too long, it needs to be less than %d bytes long\n",max); 1609 BIO_printf(bio_err,"string is too long, it needs to be less than %d bytes long\n",n_max);
1319 return(0); 1610 return(0);
1320 } 1611 }
1321 return(1); 1612 return(1);
diff --git a/src/lib/libssl/src/apps/rsa.c b/src/lib/libssl/src/apps/rsa.c
index 7e9e5e2c38..60a3381527 100644
--- a/src/lib/libssl/src/apps/rsa.c
+++ b/src/lib/libssl/src/apps/rsa.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 <stdlib.h> 61#include <stdlib.h>
62#include <string.h> 62#include <string.h>
@@ -68,7 +68,6 @@
68#include <openssl/evp.h> 68#include <openssl/evp.h>
69#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/pem.h> 70#include <openssl/pem.h>
71#include <openssl/engine.h>
72 71
73#undef PROG 72#undef PROG
74#define PROG rsa_main 73#define PROG rsa_main
@@ -80,6 +79,9 @@
80 * -des - encrypt output if PEM format with DES in cbc mode 79 * -des - encrypt output if PEM format with DES in cbc mode
81 * -des3 - encrypt output if PEM format 80 * -des3 - encrypt output if PEM format
82 * -idea - encrypt output if PEM format 81 * -idea - encrypt output if PEM format
82 * -aes128 - encrypt output if PEM format
83 * -aes192 - encrypt output if PEM format
84 * -aes256 - encrypt output if PEM format
83 * -text - print a text version 85 * -text - print a text version
84 * -modulus - print the RSA key modulus 86 * -modulus - print the RSA key modulus
85 * -check - verify key consistency 87 * -check - verify key consistency
@@ -96,7 +98,7 @@ int MAIN(int argc, char **argv)
96 RSA *rsa=NULL; 98 RSA *rsa=NULL;
97 int i,badops=0, sgckey=0; 99 int i,badops=0, sgckey=0;
98 const EVP_CIPHER *enc=NULL; 100 const EVP_CIPHER *enc=NULL;
99 BIO *in=NULL,*out=NULL; 101 BIO *out=NULL;
100 int informat,outformat,text=0,check=0,noout=0; 102 int informat,outformat,text=0,check=0,noout=0;
101 int pubin = 0, pubout = 0; 103 int pubin = 0, pubout = 0;
102 char *infile,*outfile,*prog; 104 char *infile,*outfile,*prog;
@@ -111,6 +113,9 @@ int MAIN(int argc, char **argv)
111 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 113 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
112 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 114 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
113 115
116 if (!load_config(bio_err, NULL))
117 goto end;
118
114 infile=NULL; 119 infile=NULL;
115 outfile=NULL; 120 outfile=NULL;
116 informat=FORMAT_PEM; 121 informat=FORMAT_PEM;
@@ -194,9 +199,13 @@ bad:
194 BIO_printf(bio_err," -passout arg output file pass phrase source\n"); 199 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
195 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 200 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
196 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 201 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
197#ifndef NO_IDEA 202#ifndef OPENSSL_NO_IDEA
198 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n"); 203 BIO_printf(bio_err," -idea encrypt PEM output with cbc idea\n");
199#endif 204#endif
205#ifndef OPENSSL_NO_AES
206 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
207 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
208#endif
200 BIO_printf(bio_err," -text print the key in text\n"); 209 BIO_printf(bio_err," -text print the key in text\n");
201 BIO_printf(bio_err," -noout don't print key out\n"); 210 BIO_printf(bio_err," -noout don't print key out\n");
202 BIO_printf(bio_err," -modulus print the RSA key modulus\n"); 211 BIO_printf(bio_err," -modulus print the RSA key modulus\n");
@@ -209,23 +218,7 @@ bad:
209 218
210 ERR_load_crypto_strings(); 219 ERR_load_crypto_strings();
211 220
212 if (engine != NULL) 221 e = setup_engine(bio_err, engine, 0);
213 {
214 if((e = ENGINE_by_id(engine)) == NULL)
215 {
216 BIO_printf(bio_err,"invalid engine \"%s\"\n",
217 engine);
218 goto end;
219 }
220 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
221 {
222 BIO_printf(bio_err,"can't use that engine\n");
223 goto end;
224 }
225 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
226 /* Free our "structural" reference. */
227 ENGINE_free(e);
228 }
229 222
230 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 223 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
231 BIO_printf(bio_err, "Error getting passwords\n"); 224 BIO_printf(bio_err, "Error getting passwords\n");
@@ -237,69 +230,29 @@ bad:
237 goto end; 230 goto end;
238 } 231 }
239 232
240 in=BIO_new(BIO_s_file());
241 out=BIO_new(BIO_s_file()); 233 out=BIO_new(BIO_s_file());
242 if ((in == NULL) || (out == NULL))
243 {
244 ERR_print_errors(bio_err);
245 goto end;
246 }
247 234
248 if (infile == NULL) 235 {
249 BIO_set_fp(in,stdin,BIO_NOCLOSE); 236 EVP_PKEY *pkey;
250 else
251 {
252 if (BIO_read_filename(in,infile) <= 0)
253 {
254 perror(infile);
255 goto end;
256 }
257 }
258 237
259 BIO_printf(bio_err,"read RSA key\n"); 238 if (pubin)
260 if (informat == FORMAT_ASN1) { 239 pkey = load_pubkey(bio_err, infile,
261 if (pubin) rsa=d2i_RSA_PUBKEY_bio(in,NULL); 240 (informat == FORMAT_NETSCAPE && sgckey ?
262 else rsa=d2i_RSAPrivateKey_bio(in,NULL); 241 FORMAT_IISSGC : informat),
263 } 242 passin, e, "Public Key");
264#ifndef NO_RC4 243 else
265 else if (informat == FORMAT_NETSCAPE) 244 pkey = load_key(bio_err, infile,
266 { 245 (informat == FORMAT_NETSCAPE && sgckey ?
267 BUF_MEM *buf=NULL; 246 FORMAT_IISSGC : informat),
268 unsigned char *p; 247 passin, e, "Private Key");
269 int size=0;
270 248
271 buf=BUF_MEM_new(); 249 if (pkey != NULL)
272 for (;;) 250 rsa = pkey == NULL ? NULL : EVP_PKEY_get1_RSA(pkey);
273 { 251 EVP_PKEY_free(pkey);
274 if ((buf == NULL) || (!BUF_MEM_grow(buf,size+1024*10)))
275 goto end;
276 i=BIO_read(in,&(buf->data[size]),1024*10);
277 size+=i;
278 if (i == 0) break;
279 if (i < 0)
280 {
281 perror("reading private key");
282 BUF_MEM_free(buf);
283 goto end;
284 }
285 }
286 p=(unsigned char *)buf->data;
287 rsa=d2i_RSA_NET(NULL,&p,(long)size,NULL, sgckey);
288 BUF_MEM_free(buf);
289 }
290#endif
291 else if (informat == FORMAT_PEM) {
292 if(pubin) rsa=PEM_read_bio_RSA_PUBKEY(in,NULL,NULL,NULL);
293 else rsa=PEM_read_bio_RSAPrivateKey(in,NULL, NULL,passin);
294 } 252 }
295 else 253
296 {
297 BIO_printf(bio_err,"bad input format specified for key\n");
298 goto end;
299 }
300 if (rsa == NULL) 254 if (rsa == NULL)
301 { 255 {
302 BIO_printf(bio_err,"unable to load key\n");
303 ERR_print_errors(bio_err); 256 ERR_print_errors(bio_err);
304 goto end; 257 goto end;
305 } 258 }
@@ -307,7 +260,7 @@ bad:
307 if (outfile == NULL) 260 if (outfile == NULL)
308 { 261 {
309 BIO_set_fp(out,stdout,BIO_NOCLOSE); 262 BIO_set_fp(out,stdout,BIO_NOCLOSE);
310#ifdef VMS 263#ifdef OPENSSL_SYS_VMS
311 { 264 {
312 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 265 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
313 out = BIO_push(tmpbio, out); 266 out = BIO_push(tmpbio, out);
@@ -346,14 +299,14 @@ bad:
346 BIO_printf(out,"RSA key ok\n"); 299 BIO_printf(out,"RSA key ok\n");
347 else if (r == 0) 300 else if (r == 0)
348 { 301 {
349 long e; 302 long err;
350 303
351 while ((e = ERR_peek_error()) != 0 && 304 while ((err = ERR_peek_error()) != 0 &&
352 ERR_GET_LIB(e) == ERR_LIB_RSA && 305 ERR_GET_LIB(err) == ERR_LIB_RSA &&
353 ERR_GET_FUNC(e) == RSA_F_RSA_CHECK_KEY && 306 ERR_GET_FUNC(err) == RSA_F_RSA_CHECK_KEY &&
354 ERR_GET_REASON(e) != ERR_R_MALLOC_FAILURE) 307 ERR_GET_REASON(err) != ERR_R_MALLOC_FAILURE)
355 { 308 {
356 BIO_printf(out, "RSA key error: %s\n", ERR_reason_error_string(e)); 309 BIO_printf(out, "RSA key error: %s\n", ERR_reason_error_string(err));
357 ERR_get_error(); /* remove e from error stack */ 310 ERR_get_error(); /* remove e from error stack */
358 } 311 }
359 } 312 }
@@ -375,7 +328,7 @@ bad:
375 if(pubout || pubin) i=i2d_RSA_PUBKEY_bio(out,rsa); 328 if(pubout || pubin) i=i2d_RSA_PUBKEY_bio(out,rsa);
376 else i=i2d_RSAPrivateKey_bio(out,rsa); 329 else i=i2d_RSAPrivateKey_bio(out,rsa);
377 } 330 }
378#ifndef NO_RC4 331#ifndef OPENSSL_NO_RC4
379 else if (outformat == FORMAT_NETSCAPE) 332 else if (outformat == FORMAT_NETSCAPE)
380 { 333 {
381 unsigned char *p,*pp; 334 unsigned char *p,*pp;
@@ -411,14 +364,14 @@ bad:
411 else 364 else
412 ret=0; 365 ret=0;
413end: 366end:
414 if(in != NULL) BIO_free(in);
415 if(out != NULL) BIO_free_all(out); 367 if(out != NULL) BIO_free_all(out);
416 if(rsa != NULL) RSA_free(rsa); 368 if(rsa != NULL) RSA_free(rsa);
417 if(passin) OPENSSL_free(passin); 369 if(passin) OPENSSL_free(passin);
418 if(passout) OPENSSL_free(passout); 370 if(passout) OPENSSL_free(passout);
371 apps_shutdown();
419 EXIT(ret); 372 EXIT(ret);
420 } 373 }
421#else /* !NO_RSA */ 374#else /* !OPENSSL_NO_RSA */
422 375
423# if PEDANTIC 376# if PEDANTIC
424static void *dummy=&dummy; 377static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/apps/rsautl.c b/src/lib/libssl/src/apps/rsautl.c
index 95fce436bb..9b02e6782e 100644
--- a/src/lib/libssl/src/apps/rsautl.c
+++ b/src/lib/libssl/src/apps/rsautl.c
@@ -56,13 +56,12 @@
56 * 56 *
57 */ 57 */
58 58
59#ifndef NO_RSA 59#ifndef OPENSSL_NO_RSA
60 60
61#include "apps.h" 61#include "apps.h"
62#include <string.h> 62#include <string.h>
63#include <openssl/err.h> 63#include <openssl/err.h>
64#include <openssl/pem.h> 64#include <openssl/pem.h>
65#include <openssl/engine.h>
66 65
67#define RSA_SIGN 1 66#define RSA_SIGN 1
68#define RSA_VERIFY 2 67#define RSA_VERIFY 2
@@ -86,6 +85,7 @@ int MAIN(int argc, char **argv)
86 ENGINE *e = NULL; 85 ENGINE *e = NULL;
87 BIO *in = NULL, *out = NULL; 86 BIO *in = NULL, *out = NULL;
88 char *infile = NULL, *outfile = NULL; 87 char *infile = NULL, *outfile = NULL;
88 char *engine = NULL;
89 char *keyfile = NULL; 89 char *keyfile = NULL;
90 char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY; 90 char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
91 int keyform = FORMAT_PEM; 91 int keyform = FORMAT_PEM;
@@ -97,7 +97,6 @@ int MAIN(int argc, char **argv)
97 unsigned char *rsa_in = NULL, *rsa_out = NULL, pad; 97 unsigned char *rsa_in = NULL, *rsa_out = NULL, pad;
98 int rsa_inlen, rsa_outlen = 0; 98 int rsa_inlen, rsa_outlen = 0;
99 int keysize; 99 int keysize;
100 char *engine=NULL;
101 100
102 int ret = 1; 101 int ret = 1;
103 102
@@ -105,6 +104,9 @@ int MAIN(int argc, char **argv)
105 argv++; 104 argv++;
106 105
107 if(!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); 106 if(!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
107
108 if (!load_config(bio_err, NULL))
109 goto end;
108 ERR_load_crypto_strings(); 110 ERR_load_crypto_strings();
109 OpenSSL_add_all_algorithms(); 111 OpenSSL_add_all_algorithms();
110 pad = RSA_PKCS1_PADDING; 112 pad = RSA_PKCS1_PADDING;
@@ -120,6 +122,9 @@ int MAIN(int argc, char **argv)
120 } else if(!strcmp(*argv, "-inkey")) { 122 } else if(!strcmp(*argv, "-inkey")) {
121 if (--argc < 1) badarg = 1; 123 if (--argc < 1) badarg = 1;
122 keyfile = *(++argv); 124 keyfile = *(++argv);
125 } else if (strcmp(*argv,"-keyform") == 0) {
126 if (--argc < 1) badarg = 1;
127 keyform=str2fmt(*(++argv));
123 } else if(!strcmp(*argv, "-engine")) { 128 } else if(!strcmp(*argv, "-engine")) {
124 if (--argc < 1) badarg = 1; 129 if (--argc < 1) badarg = 1;
125 engine = *(++argv); 130 engine = *(++argv);
@@ -157,38 +162,25 @@ int MAIN(int argc, char **argv)
157 goto end; 162 goto end;
158 } 163 }
159 164
160 if (engine != NULL) 165 e = setup_engine(bio_err, engine, 0);
161 {
162 if((e = ENGINE_by_id(engine)) == NULL)
163 {
164 BIO_printf(bio_err,"invalid engine \"%s\"\n",
165 engine);
166 goto end;
167 }
168 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
169 {
170 BIO_printf(bio_err,"can't use that engine\n");
171 goto end;
172 }
173 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
174 /* Free our "structural" reference. */
175 ENGINE_free(e);
176 }
177 166
178/* FIXME: seed PRNG only if needed */ 167/* FIXME: seed PRNG only if needed */
179 app_RAND_load_file(NULL, bio_err, 0); 168 app_RAND_load_file(NULL, bio_err, 0);
180 169
181 switch(key_type) { 170 switch(key_type) {
182 case KEY_PRIVKEY: 171 case KEY_PRIVKEY:
183 pkey = load_key(bio_err, keyfile, keyform, NULL); 172 pkey = load_key(bio_err, keyfile, keyform,
173 NULL, e, "Private Key");
184 break; 174 break;
185 175
186 case KEY_PUBKEY: 176 case KEY_PUBKEY:
187 pkey = load_pubkey(bio_err, keyfile, keyform); 177 pkey = load_pubkey(bio_err, keyfile, keyform,
178 NULL, e, "Public Key");
188 break; 179 break;
189 180
190 case KEY_CERT: 181 case KEY_CERT:
191 x = load_cert(bio_err, keyfile, keyform); 182 x = load_cert(bio_err, keyfile, keyform,
183 NULL, e, "Certificate");
192 if(x) { 184 if(x) {
193 pkey = X509_get_pubkey(x); 185 pkey = X509_get_pubkey(x);
194 X509_free(x); 186 X509_free(x);
@@ -197,7 +189,6 @@ int MAIN(int argc, char **argv)
197 } 189 }
198 190
199 if(!pkey) { 191 if(!pkey) {
200 BIO_printf(bio_err, "Error loading key\n");
201 return 1; 192 return 1;
202 } 193 }
203 194
@@ -227,7 +218,7 @@ int MAIN(int argc, char **argv)
227 } 218 }
228 } else { 219 } else {
229 out = BIO_new_fp(stdout, BIO_NOCLOSE); 220 out = BIO_new_fp(stdout, BIO_NOCLOSE);
230#ifdef VMS 221#ifdef OPENSSL_SYS_VMS
231 { 222 {
232 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 223 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
233 out = BIO_push(tmpbio, out); 224 out = BIO_push(tmpbio, out);
@@ -302,9 +293,9 @@ static void usage()
302 BIO_printf(bio_err, "-in file input file\n"); 293 BIO_printf(bio_err, "-in file input file\n");
303 BIO_printf(bio_err, "-out file output file\n"); 294 BIO_printf(bio_err, "-out file output file\n");
304 BIO_printf(bio_err, "-inkey file input key\n"); 295 BIO_printf(bio_err, "-inkey file input key\n");
296 BIO_printf(bio_err, "-keyform arg private key format - default PEM\n");
305 BIO_printf(bio_err, "-pubin input is an RSA public\n"); 297 BIO_printf(bio_err, "-pubin input is an RSA public\n");
306 BIO_printf(bio_err, "-certin input is a certificate carrying an RSA public key\n"); 298 BIO_printf(bio_err, "-certin input is a certificate carrying an RSA public key\n");
307 BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n");
308 BIO_printf(bio_err, "-ssl use SSL v2 padding\n"); 299 BIO_printf(bio_err, "-ssl use SSL v2 padding\n");
309 BIO_printf(bio_err, "-raw use no padding\n"); 300 BIO_printf(bio_err, "-raw use no padding\n");
310 BIO_printf(bio_err, "-pkcs use PKCS#1 v1.5 padding (default)\n"); 301 BIO_printf(bio_err, "-pkcs use PKCS#1 v1.5 padding (default)\n");
@@ -314,6 +305,8 @@ static void usage()
314 BIO_printf(bio_err, "-encrypt encrypt with public key\n"); 305 BIO_printf(bio_err, "-encrypt encrypt with public key\n");
315 BIO_printf(bio_err, "-decrypt decrypt with private key\n"); 306 BIO_printf(bio_err, "-decrypt decrypt with private key\n");
316 BIO_printf(bio_err, "-hexdump hex dump output\n"); 307 BIO_printf(bio_err, "-hexdump hex dump output\n");
308 BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n");
309
317} 310}
318 311
319#endif 312#endif
diff --git a/src/lib/libssl/src/apps/s_apps.h b/src/lib/libssl/src/apps/s_apps.h
index 57af7c0f8c..ff18a72fe0 100644
--- a/src/lib/libssl/src/apps/s_apps.h
+++ b/src/lib/libssl/src/apps/s_apps.h
@@ -55,9 +55,64 @@
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 <sys/types.h> 112#include <sys/types.h>
60#if (defined(VMS) || defined(__VMS)) && !defined(FD_SET) 113#include <openssl/opensslconf.h>
114
115#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET)
61/* VAX C does not defined fd_set and friends, but it's actually quite simple */ 116/* VAX C does not defined fd_set and friends, but it's actually quite simple */
62/* These definitions are borrowed from SOCKETSHR. /Richard Levitte */ 117/* These definitions are borrowed from SOCKETSHR. /Richard Levitte */
63#define MAX_NOFILE 32 118#define MAX_NOFILE 32
@@ -87,13 +142,9 @@ typedef fd_mask fd_set;
87int do_server(int port, int *ret, int (*cb) (), char *context); 142int do_server(int port, int *ret, int (*cb) (), char *context);
88#ifdef HEADER_X509_H 143#ifdef HEADER_X509_H
89int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx); 144int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
90#else
91int MS_CALLBACK verify_callback(int ok, char *ctx);
92#endif 145#endif
93#ifdef HEADER_SSL_H 146#ifdef HEADER_SSL_H
94int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file); 147int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
95#else
96int set_cert_stuff(char *ctx, char *cert_file, char *key_file);
97#endif 148#endif
98int init_client(int *sock, char *server, int port); 149int init_client(int *sock, char *server, int port);
99int should_retry(int i); 150int should_retry(int i);
@@ -104,8 +155,6 @@ long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp,
104 int argi, long argl, long ret); 155 int argi, long argl, long ret);
105 156
106#ifdef HEADER_SSL_H 157#ifdef HEADER_SSL_H
107void MS_CALLBACK apps_ssl_info_callback(SSL *s, int where, int ret); 158void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret);
108#else 159void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
109void MS_CALLBACK apps_ssl_info_callback(char *s, int where, int ret);
110#endif 160#endif
111
diff --git a/src/lib/libssl/src/apps/s_cb.c b/src/lib/libssl/src/apps/s_cb.c
index fd622597d6..ca5b24548c 100644
--- a/src/lib/libssl/src/apps/s_cb.c
+++ b/src/lib/libssl/src/apps/s_cb.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 <stdlib.h> 113#include <stdlib.h>
@@ -200,7 +253,7 @@ long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp, int argi,
200 return(ret); 253 return(ret);
201 } 254 }
202 255
203void MS_CALLBACK apps_ssl_info_callback(SSL *s, int where, int ret) 256void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret)
204 { 257 {
205 char *str; 258 char *str;
206 int w; 259 int w;
@@ -236,3 +289,261 @@ void MS_CALLBACK apps_ssl_info_callback(SSL *s, int where, int ret)
236 } 289 }
237 } 290 }
238 291
292
293void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)
294 {
295 BIO *bio = arg;
296 const char *str_write_p, *str_version, *str_content_type = "", *str_details1 = "", *str_details2= "";
297
298 str_write_p = write_p ? ">>>" : "<<<";
299
300 switch (version)
301 {
302 case SSL2_VERSION:
303 str_version = "SSL 2.0";
304 break;
305 case SSL3_VERSION:
306 str_version = "SSL 3.0 ";
307 break;
308 case TLS1_VERSION:
309 str_version = "TLS 1.0 ";
310 break;
311 default:
312 str_version = "???";
313 }
314
315 if (version == SSL2_VERSION)
316 {
317 str_details1 = "???";
318
319 if (len > 0)
320 {
321 switch (((unsigned char*)buf)[0])
322 {
323 case 0:
324 str_details1 = ", ERROR:";
325 str_details2 = " ???";
326 if (len >= 3)
327 {
328 unsigned err = (((unsigned char*)buf)[1]<<8) + ((unsigned char*)buf)[2];
329
330 switch (err)
331 {
332 case 0x0001:
333 str_details2 = " NO-CIPHER-ERROR";
334 break;
335 case 0x0002:
336 str_details2 = " NO-CERTIFICATE-ERROR";
337 break;
338 case 0x0004:
339 str_details2 = " BAD-CERTIFICATE-ERROR";
340 break;
341 case 0x0006:
342 str_details2 = " UNSUPPORTED-CERTIFICATE-TYPE-ERROR";
343 break;
344 }
345 }
346
347 break;
348 case 1:
349 str_details1 = ", CLIENT-HELLO";
350 break;
351 case 2:
352 str_details1 = ", CLIENT-MASTER-KEY";
353 break;
354 case 3:
355 str_details1 = ", CLIENT-FINISHED";
356 break;
357 case 4:
358 str_details1 = ", SERVER-HELLO";
359 break;
360 case 5:
361 str_details1 = ", SERVER-VERIFY";
362 break;
363 case 6:
364 str_details1 = ", SERVER-FINISHED";
365 break;
366 case 7:
367 str_details1 = ", REQUEST-CERTIFICATE";
368 break;
369 case 8:
370 str_details1 = ", CLIENT-CERTIFICATE";
371 break;
372 }
373 }
374 }
375
376 if (version == SSL3_VERSION || version == TLS1_VERSION)
377 {
378 switch (content_type)
379 {
380 case 20:
381 str_content_type = "ChangeCipherSpec";
382 break;
383 case 21:
384 str_content_type = "Alert";
385 break;
386 case 22:
387 str_content_type = "Handshake";
388 break;
389 }
390
391 if (content_type == 21) /* Alert */
392 {
393 str_details1 = ", ???";
394
395 if (len == 2)
396 {
397 switch (((unsigned char*)buf)[0])
398 {
399 case 1:
400 str_details1 = ", warning";
401 break;
402 case 2:
403 str_details1 = ", fatal";
404 break;
405 }
406
407 str_details2 = " ???";
408 switch (((unsigned char*)buf)[1])
409 {
410 case 0:
411 str_details2 = " close_notify";
412 break;
413 case 10:
414 str_details2 = " unexpected_message";
415 break;
416 case 20:
417 str_details2 = " bad_record_mac";
418 break;
419 case 21:
420 str_details2 = " decryption_failed";
421 break;
422 case 22:
423 str_details2 = " record_overflow";
424 break;
425 case 30:
426 str_details2 = " decompression_failure";
427 break;
428 case 40:
429 str_details2 = " handshake_failure";
430 break;
431 case 42:
432 str_details2 = " bad_certificate";
433 break;
434 case 43:
435 str_details2 = " unsupported_certificate";
436 break;
437 case 44:
438 str_details2 = " certificate_revoked";
439 break;
440 case 45:
441 str_details2 = " certificate_expired";
442 break;
443 case 46:
444 str_details2 = " certificate_unknown";
445 break;
446 case 47:
447 str_details2 = " illegal_parameter";
448 break;
449 case 48:
450 str_details2 = " unknown_ca";
451 break;
452 case 49:
453 str_details2 = " access_denied";
454 break;
455 case 50:
456 str_details2 = " decode_error";
457 break;
458 case 51:
459 str_details2 = " decrypt_error";
460 break;
461 case 60:
462 str_details2 = " export_restriction";
463 break;
464 case 70:
465 str_details2 = " protocol_version";
466 break;
467 case 71:
468 str_details2 = " insufficient_security";
469 break;
470 case 80:
471 str_details2 = " internal_error";
472 break;
473 case 90:
474 str_details2 = " user_canceled";
475 break;
476 case 100:
477 str_details2 = " no_renegotiation";
478 break;
479 }
480 }
481 }
482
483 if (content_type == 22) /* Handshake */
484 {
485 str_details1 = "???";
486
487 if (len > 0)
488 {
489 switch (((unsigned char*)buf)[0])
490 {
491 case 0:
492 str_details1 = ", HelloRequest";
493 break;
494 case 1:
495 str_details1 = ", ClientHello";
496 break;
497 case 2:
498 str_details1 = ", ServerHello";
499 break;
500 case 11:
501 str_details1 = ", Certificate";
502 break;
503 case 12:
504 str_details1 = ", ServerKeyExchange";
505 break;
506 case 13:
507 str_details1 = ", CertificateRequest";
508 break;
509 case 14:
510 str_details1 = ", ServerHelloDone";
511 break;
512 case 15:
513 str_details1 = ", CertificateVerify";
514 break;
515 case 16:
516 str_details1 = ", ClientKeyExchange";
517 break;
518 case 20:
519 str_details1 = ", Finished";
520 break;
521 }
522 }
523 }
524 }
525
526 BIO_printf(bio, "%s %s%s [length %04lx]%s%s\n", str_write_p, str_version, str_content_type, (unsigned long)len, str_details1, str_details2);
527
528 if (len > 0)
529 {
530 size_t num, i;
531
532 BIO_printf(bio, " ");
533 num = len;
534#if 0
535 if (num > 16)
536 num = 16;
537#endif
538 for (i = 0; i < num; i++)
539 {
540 if (i % 16 == 0 && i > 0)
541 BIO_printf(bio, "\n ");
542 BIO_printf(bio, " %02x", ((unsigned char*)buf)[i]);
543 }
544 if (i < len)
545 BIO_printf(bio, " ...");
546 BIO_printf(bio, "\n");
547 }
548 BIO_flush(bio);
549 }
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c
index 0e1a61b789..9c0dbc2bf6 100644
--- a/src/lib/libssl/src/apps/s_client.c
+++ b/src/lib/libssl/src/apps/s_client.c
@@ -55,12 +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 <assert.h> 112#include <assert.h>
60#include <stdio.h> 113#include <stdio.h>
61#include <stdlib.h> 114#include <stdlib.h>
62#include <string.h> 115#include <string.h>
63#ifdef NO_STDIO 116#include <openssl/e_os2.h>
117#ifdef OPENSSL_NO_STDIO
64#define APPS_WIN16 118#define APPS_WIN16
65#endif 119#endif
66 120
@@ -68,7 +122,7 @@
68 recursive header file inclusion, resulting in the compiler complaining 122 recursive header file inclusion, resulting in the compiler complaining
69 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which 123 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
70 is needed to have fileno() declared correctly... So let's define u_int */ 124 is needed to have fileno() declared correctly... So let's define u_int */
71#if defined(VMS) && defined(__DECC) && !defined(__U_INT) 125#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__U_INT)
72#define __U_INT 126#define __U_INT
73typedef unsigned int u_int; 127typedef unsigned int u_int;
74#endif 128#endif
@@ -80,15 +134,14 @@ typedef unsigned int u_int;
80#include <openssl/err.h> 134#include <openssl/err.h>
81#include <openssl/pem.h> 135#include <openssl/pem.h>
82#include <openssl/rand.h> 136#include <openssl/rand.h>
83#include <openssl/engine.h>
84#include "s_apps.h" 137#include "s_apps.h"
85 138
86#ifdef WINDOWS 139#ifdef OPENSSL_SYS_WINDOWS
87#include <conio.h> 140#include <conio.h>
88#endif 141#endif
89 142
90 143
91#if (defined(VMS) && __VMS_VER < 70000000) 144#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
92/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 145/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
93#undef FIONBIO 146#undef FIONBIO
94#endif 147#endif
@@ -113,6 +166,7 @@ static int c_nbio=0;
113#endif 166#endif
114static int c_Pause=0; 167static int c_Pause=0;
115static int c_debug=0; 168static int c_debug=0;
169static int c_msg=0;
116static int c_showcerts=0; 170static int c_showcerts=0;
117 171
118static void sc_usage(void); 172static void sc_usage(void);
@@ -139,6 +193,7 @@ static void sc_usage(void)
139 BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n"); 193 BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n");
140 BIO_printf(bio_err," -showcerts - show all certificates in the chain\n"); 194 BIO_printf(bio_err," -showcerts - show all certificates in the chain\n");
141 BIO_printf(bio_err," -debug - extra output\n"); 195 BIO_printf(bio_err," -debug - extra output\n");
196 BIO_printf(bio_err," -msg - Show protocol messages\n");
142 BIO_printf(bio_err," -nbio_test - more ssl protocol testing\n"); 197 BIO_printf(bio_err," -nbio_test - more ssl protocol testing\n");
143 BIO_printf(bio_err," -state - print the 'ssl' states\n"); 198 BIO_printf(bio_err," -state - print the 'ssl' states\n");
144#ifdef FIONBIO 199#ifdef FIONBIO
@@ -152,10 +207,16 @@ static void sc_usage(void)
152 BIO_printf(bio_err," -tls1 - just use TLSv1\n"); 207 BIO_printf(bio_err," -tls1 - just use TLSv1\n");
153 BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n"); 208 BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
154 BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n"); 209 BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n");
210 BIO_printf(bio_err," -serverpref - Use server's cipher preferences (only SSLv2)\n");
155 BIO_printf(bio_err," -cipher - preferred cipher to use, use the 'openssl ciphers'\n"); 211 BIO_printf(bio_err," -cipher - preferred cipher to use, use the 'openssl ciphers'\n");
156 BIO_printf(bio_err," command to see what is available\n"); 212 BIO_printf(bio_err," command to see what is available\n");
157 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 213 BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n");
214 BIO_printf(bio_err," for those protocols that support it, where\n");
215 BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n");
216 BIO_printf(bio_err," only \"smtp\" is supported.\n");
158 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); 217 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
218 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
219
159 } 220 }
160 221
161int MAIN(int, char **); 222int MAIN(int, char **);
@@ -164,8 +225,9 @@ int MAIN(int argc, char **argv)
164 { 225 {
165 int off=0; 226 int off=0;
166 SSL *con=NULL,*con2=NULL; 227 SSL *con=NULL,*con2=NULL;
228 X509_STORE *store = NULL;
167 int s,k,width,state=0; 229 int s,k,width,state=0;
168 char *cbuf=NULL,*sbuf=NULL; 230 char *cbuf=NULL,*sbuf=NULL,*mbuf=NULL;
169 int cbuf_len,cbuf_off; 231 int cbuf_len,cbuf_off;
170 int sbuf_len,sbuf_off; 232 int sbuf_len,sbuf_off;
171 fd_set readfds,writefds; 233 fd_set readfds,writefds;
@@ -179,21 +241,22 @@ int MAIN(int argc, char **argv)
179 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending; 241 int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
180 SSL_CTX *ctx=NULL; 242 SSL_CTX *ctx=NULL;
181 int ret=1,in_init=1,i,nbio_test=0; 243 int ret=1,in_init=1,i,nbio_test=0;
182 int prexit = 0; 244 int smtp_starttls = 0;
245 int prexit = 0, vflags = 0;
183 SSL_METHOD *meth=NULL; 246 SSL_METHOD *meth=NULL;
184 BIO *sbio; 247 BIO *sbio;
185 char *inrand=NULL; 248 char *inrand=NULL;
186 char *engine_id=NULL; 249 char *engine_id=NULL;
187 ENGINE *e=NULL; 250 ENGINE *e=NULL;
188#ifdef WINDOWS 251#ifdef OPENSSL_SYS_WINDOWS
189 struct timeval tv; 252 struct timeval tv;
190#endif 253#endif
191 254
192#if !defined(NO_SSL2) && !defined(NO_SSL3) 255#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
193 meth=SSLv23_client_method(); 256 meth=SSLv23_client_method();
194#elif !defined(NO_SSL3) 257#elif !defined(OPENSSL_NO_SSL3)
195 meth=SSLv3_client_method(); 258 meth=SSLv3_client_method();
196#elif !defined(NO_SSL2) 259#elif !defined(OPENSSL_NO_SSL2)
197 meth=SSLv2_client_method(); 260 meth=SSLv2_client_method();
198#endif 261#endif
199 262
@@ -202,13 +265,18 @@ int MAIN(int argc, char **argv)
202 c_quiet=0; 265 c_quiet=0;
203 c_ign_eof=0; 266 c_ign_eof=0;
204 c_debug=0; 267 c_debug=0;
268 c_msg=0;
205 c_showcerts=0; 269 c_showcerts=0;
206 270
207 if (bio_err == NULL) 271 if (bio_err == NULL)
208 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 272 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
209 273
274 if (!load_config(bio_err, NULL))
275 goto end;
276
210 if ( ((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) || 277 if ( ((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
211 ((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL)) 278 ((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
279 ((mbuf=OPENSSL_malloc(BUFSIZZ)) == NULL))
212 { 280 {
213 BIO_printf(bio_err,"out of memory\n"); 281 BIO_printf(bio_err,"out of memory\n");
214 goto end; 282 goto end;
@@ -253,6 +321,10 @@ int MAIN(int argc, char **argv)
253 if (--argc < 1) goto bad; 321 if (--argc < 1) goto bad;
254 cert_file= *(++argv); 322 cert_file= *(++argv);
255 } 323 }
324 else if (strcmp(*argv,"-crl_check") == 0)
325 vflags |= X509_V_FLAG_CRL_CHECK;
326 else if (strcmp(*argv,"-crl_check_all") == 0)
327 vflags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;
256 else if (strcmp(*argv,"-prexit") == 0) 328 else if (strcmp(*argv,"-prexit") == 0)
257 prexit=1; 329 prexit=1;
258 else if (strcmp(*argv,"-crlf") == 0) 330 else if (strcmp(*argv,"-crlf") == 0)
@@ -268,21 +340,23 @@ int MAIN(int argc, char **argv)
268 c_Pause=1; 340 c_Pause=1;
269 else if (strcmp(*argv,"-debug") == 0) 341 else if (strcmp(*argv,"-debug") == 0)
270 c_debug=1; 342 c_debug=1;
343 else if (strcmp(*argv,"-msg") == 0)
344 c_msg=1;
271 else if (strcmp(*argv,"-showcerts") == 0) 345 else if (strcmp(*argv,"-showcerts") == 0)
272 c_showcerts=1; 346 c_showcerts=1;
273 else if (strcmp(*argv,"-nbio_test") == 0) 347 else if (strcmp(*argv,"-nbio_test") == 0)
274 nbio_test=1; 348 nbio_test=1;
275 else if (strcmp(*argv,"-state") == 0) 349 else if (strcmp(*argv,"-state") == 0)
276 state=1; 350 state=1;
277#ifndef NO_SSL2 351#ifndef OPENSSL_NO_SSL2
278 else if (strcmp(*argv,"-ssl2") == 0) 352 else if (strcmp(*argv,"-ssl2") == 0)
279 meth=SSLv2_client_method(); 353 meth=SSLv2_client_method();
280#endif 354#endif
281#ifndef NO_SSL3 355#ifndef OPENSSL_NO_SSL3
282 else if (strcmp(*argv,"-ssl3") == 0) 356 else if (strcmp(*argv,"-ssl3") == 0)
283 meth=SSLv3_client_method(); 357 meth=SSLv3_client_method();
284#endif 358#endif
285#ifndef NO_TLS1 359#ifndef OPENSSL_NO_TLS1
286 else if (strcmp(*argv,"-tls1") == 0) 360 else if (strcmp(*argv,"-tls1") == 0)
287 meth=TLSv1_client_method(); 361 meth=TLSv1_client_method();
288#endif 362#endif
@@ -313,6 +387,8 @@ int MAIN(int argc, char **argv)
313 off|=SSL_OP_NO_SSLv3; 387 off|=SSL_OP_NO_SSLv3;
314 else if (strcmp(*argv,"-no_ssl2") == 0) 388 else if (strcmp(*argv,"-no_ssl2") == 0)
315 off|=SSL_OP_NO_SSLv2; 389 off|=SSL_OP_NO_SSLv2;
390 else if (strcmp(*argv,"-serverpref") == 0)
391 off|=SSL_OP_CIPHER_SERVER_PREFERENCE;
316 else if (strcmp(*argv,"-cipher") == 0) 392 else if (strcmp(*argv,"-cipher") == 0)
317 { 393 {
318 if (--argc < 1) goto bad; 394 if (--argc < 1) goto bad;
@@ -322,16 +398,25 @@ int MAIN(int argc, char **argv)
322 else if (strcmp(*argv,"-nbio") == 0) 398 else if (strcmp(*argv,"-nbio") == 0)
323 { c_nbio=1; } 399 { c_nbio=1; }
324#endif 400#endif
325 else if (strcmp(*argv,"-rand") == 0) 401 else if (strcmp(*argv,"-starttls") == 0)
326 { 402 {
327 if (--argc < 1) goto bad; 403 if (--argc < 1) goto bad;
328 inrand= *(++argv); 404 ++argv;
405 if (strcmp(*argv,"smtp") == 0)
406 smtp_starttls = 1;
407 else
408 goto bad;
329 } 409 }
330 else if (strcmp(*argv,"-engine") == 0) 410 else if (strcmp(*argv,"-engine") == 0)
331 { 411 {
332 if (--argc < 1) goto bad; 412 if (--argc < 1) goto bad;
333 engine_id = *(++argv); 413 engine_id = *(++argv);
334 } 414 }
415 else if (strcmp(*argv,"-rand") == 0)
416 {
417 if (--argc < 1) goto bad;
418 inrand= *(++argv);
419 }
335 else 420 else
336 { 421 {
337 BIO_printf(bio_err,"unknown option %s\n",*argv); 422 BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -359,7 +444,7 @@ bad:
359 444
360 if (bio_c_out == NULL) 445 if (bio_c_out == NULL)
361 { 446 {
362 if (c_quiet) 447 if (c_quiet && !c_debug && !c_msg)
363 { 448 {
364 bio_c_out=BIO_new(BIO_s_null()); 449 bio_c_out=BIO_new(BIO_s_null());
365 } 450 }
@@ -373,28 +458,7 @@ bad:
373 OpenSSL_add_ssl_algorithms(); 458 OpenSSL_add_ssl_algorithms();
374 SSL_load_error_strings(); 459 SSL_load_error_strings();
375 460
376 if (engine_id != NULL) 461 e = setup_engine(bio_err, engine_id, 1);
377 {
378 if((e = ENGINE_by_id(engine_id)) == NULL)
379 {
380 BIO_printf(bio_err,"invalid engine\n");
381 ERR_print_errors(bio_err);
382 goto end;
383 }
384 if (c_debug)
385 {
386 ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
387 0, bio_err, 0);
388 }
389 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
390 {
391 BIO_printf(bio_err,"can't use that engine\n");
392 ERR_print_errors(bio_err);
393 goto end;
394 }
395 BIO_printf(bio_err,"engine \"%s\" set.\n", engine_id);
396 ENGINE_free(e);
397 }
398 462
399 ctx=SSL_CTX_new(meth); 463 ctx=SSL_CTX_new(meth);
400 if (ctx == NULL) 464 if (ctx == NULL)
@@ -432,8 +496,16 @@ bad:
432 /* goto end; */ 496 /* goto end; */
433 } 497 }
434 498
499 store = SSL_CTX_get_cert_store(ctx);
500 X509_STORE_set_flags(store, vflags);
435 501
436 con=SSL_new(ctx); 502 con=SSL_new(ctx);
503#ifndef OPENSSL_NO_KRB5
504 if (con && (con->kssl_ctx = kssl_ctx_new()) != NULL)
505 {
506 kssl_ctx_setstring(con->kssl_ctx, KSSL_SERVER, host);
507 }
508#endif /* OPENSSL_NO_KRB5 */
437/* SSL_set_cipher_list(con,"RC4-MD5"); */ 509/* SSL_set_cipher_list(con,"RC4-MD5"); */
438 510
439re_start: 511re_start:
@@ -475,6 +547,11 @@ re_start:
475 BIO_set_callback(sbio,bio_dump_cb); 547 BIO_set_callback(sbio,bio_dump_cb);
476 BIO_set_callback_arg(sbio,bio_c_out); 548 BIO_set_callback_arg(sbio,bio_c_out);
477 } 549 }
550 if (c_msg)
551 {
552 SSL_set_msg_callback(con, msg_cb);
553 SSL_set_msg_callback_arg(con, bio_c_out);
554 }
478 555
479 SSL_set_bio(con,sbio,sbio); 556 SSL_set_bio(con,sbio,sbio);
480 SSL_set_connect_state(con); 557 SSL_set_connect_state(con);
@@ -493,6 +570,14 @@ re_start:
493 sbuf_len=0; 570 sbuf_len=0;
494 sbuf_off=0; 571 sbuf_off=0;
495 572
573 /* This is an ugly hack that does a lot of assumptions */
574 if (smtp_starttls)
575 {
576 BIO_read(sbio,mbuf,BUFSIZZ);
577 BIO_printf(sbio,"STARTTLS\r\n");
578 BIO_read(sbio,sbuf,BUFSIZZ);
579 }
580
496 for (;;) 581 for (;;)
497 { 582 {
498 FD_ZERO(&readfds); 583 FD_ZERO(&readfds);
@@ -512,6 +597,13 @@ re_start:
512 print_stuff(bio_c_out,con,full_log); 597 print_stuff(bio_c_out,con,full_log);
513 if (full_log > 0) full_log--; 598 if (full_log > 0) full_log--;
514 599
600 if (smtp_starttls)
601 {
602 BIO_printf(bio_err,"%s",mbuf);
603 /* We don't need to know any more */
604 smtp_starttls = 0;
605 }
606
515 if (reconnect) 607 if (reconnect)
516 { 608 {
517 reconnect--; 609 reconnect--;
@@ -528,7 +620,7 @@ re_start:
528 620
529 if (!ssl_pending) 621 if (!ssl_pending)
530 { 622 {
531#ifndef WINDOWS 623#ifndef OPENSSL_SYS_WINDOWS
532 if (tty_on) 624 if (tty_on)
533 { 625 {
534 if (read_tty) FD_SET(fileno(stdin),&readfds); 626 if (read_tty) FD_SET(fileno(stdin),&readfds);
@@ -555,7 +647,7 @@ re_start:
555 * will choke the compiler: if you do have a cast then 647 * will choke the compiler: if you do have a cast then
556 * you can either go for (int *) or (void *). 648 * you can either go for (int *) or (void *).
557 */ 649 */
558#ifdef WINDOWS 650#ifdef OPENSSL_SYS_WINDOWS
559 /* Under Windows we make the assumption that we can 651 /* Under Windows we make the assumption that we can
560 * always write to the tty: therefore if we need to 652 * always write to the tty: therefore if we need to
561 * write to the tty we just fall through. Otherwise 653 * write to the tty we just fall through. Otherwise
@@ -654,7 +746,7 @@ re_start:
654 goto shut; 746 goto shut;
655 } 747 }
656 } 748 }
657#ifdef WINDOWS 749#ifdef OPENSSL_SYS_WINDOWS
658 /* Assume Windows can always write */ 750 /* Assume Windows can always write */
659 else if (!ssl_pending && write_tty) 751 else if (!ssl_pending && write_tty)
660#else 752#else
@@ -735,7 +827,7 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
735 } 827 }
736 } 828 }
737 829
738#ifdef WINDOWS 830#ifdef OPENSSL_SYS_WINDOWS
739 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) 831 else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
740#else 832#else
741 else if (FD_ISSET(fileno(stdin),&readfds)) 833 else if (FD_ISSET(fileno(stdin),&readfds))
@@ -802,11 +894,13 @@ end:
802 if (ctx != NULL) SSL_CTX_free(ctx); 894 if (ctx != NULL) SSL_CTX_free(ctx);
803 if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); OPENSSL_free(cbuf); } 895 if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); OPENSSL_free(cbuf); }
804 if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); OPENSSL_free(sbuf); } 896 if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); OPENSSL_free(sbuf); }
897 if (mbuf != NULL) { memset(mbuf,0,BUFSIZZ); OPENSSL_free(mbuf); }
805 if (bio_c_out != NULL) 898 if (bio_c_out != NULL)
806 { 899 {
807 BIO_free(bio_c_out); 900 BIO_free(bio_c_out);
808 bio_c_out=NULL; 901 bio_c_out=NULL;
809 } 902 }
903 apps_shutdown();
810 EXIT(ret); 904 EXIT(ret);
811 } 905 }
812 906
@@ -928,5 +1022,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
928 BIO_printf(bio,"---\n"); 1022 BIO_printf(bio,"---\n");
929 if (peer != NULL) 1023 if (peer != NULL)
930 X509_free(peer); 1024 X509_free(peer);
1025 /* flush, or debugging output gets mixed with http response */
1026 BIO_flush(bio);
931 } 1027 }
932 1028
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c
index a107b8c14a..78d90fad55 100644
--- a/src/lib/libssl/src/apps/s_server.c
+++ b/src/lib/libssl/src/apps/s_server.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 <assert.h> 112#include <assert.h>
60#include <stdio.h> 113#include <stdio.h>
@@ -62,7 +115,8 @@
62#include <string.h> 115#include <string.h>
63#include <sys/types.h> 116#include <sys/types.h>
64#include <sys/stat.h> 117#include <sys/stat.h>
65#ifdef NO_STDIO 118#include <openssl/e_os2.h>
119#ifdef OPENSSL_NO_STDIO
66#define APPS_WIN16 120#define APPS_WIN16
67#endif 121#endif
68 122
@@ -70,7 +124,7 @@
70 recursive header file inclusion, resulting in the compiler complaining 124 recursive header file inclusion, resulting in the compiler complaining
71 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which 125 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
72 is needed to have fileno() declared correctly... So let's define u_int */ 126 is needed to have fileno() declared correctly... So let's define u_int */
73#if defined(VMS) && defined(__DECC) && !defined(__U_INT) 127#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__U_INT)
74#define __U_INT 128#define __U_INT
75typedef unsigned int u_int; 129typedef unsigned int u_int;
76#endif 130#endif
@@ -84,19 +138,18 @@ typedef unsigned int u_int;
84#include <openssl/x509.h> 138#include <openssl/x509.h>
85#include <openssl/ssl.h> 139#include <openssl/ssl.h>
86#include <openssl/rand.h> 140#include <openssl/rand.h>
87#include <openssl/engine.h>
88#include "s_apps.h" 141#include "s_apps.h"
89 142
90#ifdef WINDOWS 143#ifdef OPENSSL_SYS_WINDOWS
91#include <conio.h> 144#include <conio.h>
92#endif 145#endif
93 146
94#if (defined(VMS) && __VMS_VER < 70000000) 147#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
95/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 148/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
96#undef FIONBIO 149#undef FIONBIO
97#endif 150#endif
98 151
99#ifndef NO_RSA 152#ifndef OPENSSL_NO_RSA
100static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength); 153static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength);
101#endif 154#endif
102static int sv_body(char *hostname, int s, unsigned char *context); 155static int sv_body(char *hostname, int s, unsigned char *context);
@@ -105,7 +158,9 @@ static void close_accept_socket(void );
105static void sv_usage(void); 158static void sv_usage(void);
106static int init_ssl_connection(SSL *s); 159static int init_ssl_connection(SSL *s);
107static void print_stats(BIO *bp,SSL_CTX *ctx); 160static void print_stats(BIO *bp,SSL_CTX *ctx);
108#ifndef NO_DH 161static int generate_session_id(const SSL *ssl, unsigned char *id,
162 unsigned int *id_len);
163#ifndef OPENSSL_NO_DH
109static DH *load_dh_param(char *dhfile); 164static DH *load_dh_param(char *dhfile);
110static DH *get_dh512(void); 165static DH *get_dh512(void);
111#endif 166#endif
@@ -121,7 +176,7 @@ static void s_server_init(void);
121# endif 176# endif
122#endif 177#endif
123 178
124#ifndef NO_DH 179#ifndef OPENSSL_NO_DH
125static unsigned char dh512_p[]={ 180static unsigned char dh512_p[]={
126 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75, 181 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
127 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F, 182 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
@@ -175,10 +230,12 @@ static int www=0;
175 230
176static BIO *bio_s_out=NULL; 231static BIO *bio_s_out=NULL;
177static int s_debug=0; 232static int s_debug=0;
233static int s_msg=0;
178static int s_quiet=0; 234static int s_quiet=0;
179 235
180static int hack=0; 236static int hack=0;
181static char *engine_id=NULL; 237static char *engine_id=NULL;
238static const char *session_id_prefix=NULL;
182 239
183#ifdef MONOLITH 240#ifdef MONOLITH
184static void s_server_init(void) 241static void s_server_init(void)
@@ -199,6 +256,7 @@ static void s_server_init(void)
199 256
200 bio_s_out=NULL; 257 bio_s_out=NULL;
201 s_debug=0; 258 s_debug=0;
259 s_msg=0;
202 s_quiet=0; 260 s_quiet=0;
203 hack=0; 261 hack=0;
204 engine_id=NULL; 262 engine_id=NULL;
@@ -227,11 +285,13 @@ static void sv_usage(void)
227 BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n"); 285 BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n");
228 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n"); 286 BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
229 BIO_printf(bio_err," -debug - Print more output\n"); 287 BIO_printf(bio_err," -debug - Print more output\n");
288 BIO_printf(bio_err," -msg - Show protocol messages\n");
230 BIO_printf(bio_err," -state - Print the SSL states\n"); 289 BIO_printf(bio_err," -state - Print the SSL states\n");
231 BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n"); 290 BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n");
232 BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n"); 291 BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n");
233 BIO_printf(bio_err," -nocert - Don't use any certificates (Anon-DH)\n"); 292 BIO_printf(bio_err," -nocert - Don't use any certificates (Anon-DH)\n");
234 BIO_printf(bio_err," -cipher arg - play with 'openssl ciphers' to see what goes here\n"); 293 BIO_printf(bio_err," -cipher arg - play with 'openssl ciphers' to see what goes here\n");
294 BIO_printf(bio_err," -serverpref - Use server's cipher preferences\n");
235 BIO_printf(bio_err," -quiet - No server output\n"); 295 BIO_printf(bio_err," -quiet - No server output\n");
236 BIO_printf(bio_err," -no_tmp_rsa - Do not generate a tmp RSA key\n"); 296 BIO_printf(bio_err," -no_tmp_rsa - Do not generate a tmp RSA key\n");
237 BIO_printf(bio_err," -ssl2 - Just talk SSLv2\n"); 297 BIO_printf(bio_err," -ssl2 - Just talk SSLv2\n");
@@ -240,14 +300,17 @@ static void sv_usage(void)
240 BIO_printf(bio_err," -no_ssl2 - Just disable SSLv2\n"); 300 BIO_printf(bio_err," -no_ssl2 - Just disable SSLv2\n");
241 BIO_printf(bio_err," -no_ssl3 - Just disable SSLv3\n"); 301 BIO_printf(bio_err," -no_ssl3 - Just disable SSLv3\n");
242 BIO_printf(bio_err," -no_tls1 - Just disable TLSv1\n"); 302 BIO_printf(bio_err," -no_tls1 - Just disable TLSv1\n");
243#ifndef NO_DH 303#ifndef OPENSSL_NO_DH
244 BIO_printf(bio_err," -no_dhe - Disable ephemeral DH\n"); 304 BIO_printf(bio_err," -no_dhe - Disable ephemeral DH\n");
245#endif 305#endif
246 BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n"); 306 BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n");
247 BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); 307 BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n");
248 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); 308 BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
249 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 309 BIO_printf(bio_err," -HTTP - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
310 BIO_printf(bio_err," with the assumption it contains a complete HTTP response.\n");
250 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); 311 BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
312 BIO_printf(bio_err," -id_prefix arg - Generate SSL/TLS session IDs prefixed by 'arg'\n");
313 BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
251 } 314 }
252 315
253static int local_argc=0; 316static int local_argc=0;
@@ -407,6 +470,8 @@ int MAIN(int, char **);
407 470
408int MAIN(int argc, char *argv[]) 471int MAIN(int argc, char *argv[])
409 { 472 {
473 X509_STORE *store = NULL;
474 int vflags = 0;
410 short port=PORT; 475 short port=PORT;
411 char *CApath=NULL,*CAfile=NULL; 476 char *CApath=NULL,*CAfile=NULL;
412 char *context = NULL; 477 char *context = NULL;
@@ -417,18 +482,14 @@ int MAIN(int argc, char *argv[])
417 int no_tmp_rsa=0,no_dhe=0,nocert=0; 482 int no_tmp_rsa=0,no_dhe=0,nocert=0;
418 int state=0; 483 int state=0;
419 SSL_METHOD *meth=NULL; 484 SSL_METHOD *meth=NULL;
420 char *inrand=NULL;
421 char *engine_id=NULL;
422 ENGINE *e=NULL; 485 ENGINE *e=NULL;
423#ifndef NO_DH 486 char *inrand=NULL;
424 DH *dh=NULL;
425#endif
426 487
427#if !defined(NO_SSL2) && !defined(NO_SSL3) 488#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
428 meth=SSLv23_server_method(); 489 meth=SSLv23_server_method();
429#elif !defined(NO_SSL3) 490#elif !defined(OPENSSL_NO_SSL3)
430 meth=SSLv3_server_method(); 491 meth=SSLv3_server_method();
431#elif !defined(NO_SSL2) 492#elif !defined(OPENSSL_NO_SSL2)
432 meth=SSLv2_server_method(); 493 meth=SSLv2_server_method();
433#endif 494#endif
434 495
@@ -443,6 +504,9 @@ int MAIN(int argc, char *argv[])
443 if (bio_err == NULL) 504 if (bio_err == NULL)
444 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 505 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
445 506
507 if (!load_config(bio_err, NULL))
508 goto end;
509
446 verify_depth=0; 510 verify_depth=0;
447#ifdef FIONBIO 511#ifdef FIONBIO
448 s_nbio=0; 512 s_nbio=0;
@@ -515,6 +579,16 @@ int MAIN(int argc, char *argv[])
515 if (--argc < 1) goto bad; 579 if (--argc < 1) goto bad;
516 CApath= *(++argv); 580 CApath= *(++argv);
517 } 581 }
582 else if (strcmp(*argv,"-crl_check") == 0)
583 {
584 vflags |= X509_V_FLAG_CRL_CHECK;
585 }
586 else if (strcmp(*argv,"-crl_check") == 0)
587 {
588 vflags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;
589 }
590 else if (strcmp(*argv,"-serverpref") == 0)
591 { off|=SSL_OP_CIPHER_SERVER_PREFERENCE; }
518 else if (strcmp(*argv,"-cipher") == 0) 592 else if (strcmp(*argv,"-cipher") == 0)
519 { 593 {
520 if (--argc < 1) goto bad; 594 if (--argc < 1) goto bad;
@@ -538,6 +612,8 @@ int MAIN(int argc, char *argv[])
538 } 612 }
539 else if (strcmp(*argv,"-debug") == 0) 613 else if (strcmp(*argv,"-debug") == 0)
540 { s_debug=1; } 614 { s_debug=1; }
615 else if (strcmp(*argv,"-msg") == 0)
616 { s_msg=1; }
541 else if (strcmp(*argv,"-hack") == 0) 617 else if (strcmp(*argv,"-hack") == 0)
542 { hack=1; } 618 { hack=1; }
543 else if (strcmp(*argv,"-state") == 0) 619 else if (strcmp(*argv,"-state") == 0)
@@ -556,34 +632,41 @@ int MAIN(int argc, char *argv[])
556 { www=1; } 632 { www=1; }
557 else if (strcmp(*argv,"-WWW") == 0) 633 else if (strcmp(*argv,"-WWW") == 0)
558 { www=2; } 634 { www=2; }
635 else if (strcmp(*argv,"-HTTP") == 0)
636 { www=3; }
559 else if (strcmp(*argv,"-no_ssl2") == 0) 637 else if (strcmp(*argv,"-no_ssl2") == 0)
560 { off|=SSL_OP_NO_SSLv2; } 638 { off|=SSL_OP_NO_SSLv2; }
561 else if (strcmp(*argv,"-no_ssl3") == 0) 639 else if (strcmp(*argv,"-no_ssl3") == 0)
562 { off|=SSL_OP_NO_SSLv3; } 640 { off|=SSL_OP_NO_SSLv3; }
563 else if (strcmp(*argv,"-no_tls1") == 0) 641 else if (strcmp(*argv,"-no_tls1") == 0)
564 { off|=SSL_OP_NO_TLSv1; } 642 { off|=SSL_OP_NO_TLSv1; }
565#ifndef NO_SSL2 643#ifndef OPENSSL_NO_SSL2
566 else if (strcmp(*argv,"-ssl2") == 0) 644 else if (strcmp(*argv,"-ssl2") == 0)
567 { meth=SSLv2_server_method(); } 645 { meth=SSLv2_server_method(); }
568#endif 646#endif
569#ifndef NO_SSL3 647#ifndef OPENSSL_NO_SSL3
570 else if (strcmp(*argv,"-ssl3") == 0) 648 else if (strcmp(*argv,"-ssl3") == 0)
571 { meth=SSLv3_server_method(); } 649 { meth=SSLv3_server_method(); }
572#endif 650#endif
573#ifndef NO_TLS1 651#ifndef OPENSSL_NO_TLS1
574 else if (strcmp(*argv,"-tls1") == 0) 652 else if (strcmp(*argv,"-tls1") == 0)
575 { meth=TLSv1_server_method(); } 653 { meth=TLSv1_server_method(); }
576#endif 654#endif
577 else if (strcmp(*argv,"-rand") == 0) 655 else if (strcmp(*argv, "-id_prefix") == 0)
578 { 656 {
579 if (--argc < 1) goto bad; 657 if (--argc < 1) goto bad;
580 inrand= *(++argv); 658 session_id_prefix = *(++argv);
581 } 659 }
582 else if (strcmp(*argv,"-engine") == 0) 660 else if (strcmp(*argv,"-engine") == 0)
583 { 661 {
584 if (--argc < 1) goto bad; 662 if (--argc < 1) goto bad;
585 engine_id= *(++argv); 663 engine_id= *(++argv);
586 } 664 }
665 else if (strcmp(*argv,"-rand") == 0)
666 {
667 if (--argc < 1) goto bad;
668 inrand= *(++argv);
669 }
587 else 670 else
588 { 671 {
589 BIO_printf(bio_err,"unknown option %s\n",*argv); 672 BIO_printf(bio_err,"unknown option %s\n",*argv);
@@ -611,7 +694,7 @@ bad:
611 694
612 if (bio_s_out == NULL) 695 if (bio_s_out == NULL)
613 { 696 {
614 if (s_quiet && !s_debug) 697 if (s_quiet && !s_debug && !s_msg)
615 { 698 {
616 bio_s_out=BIO_new(BIO_s_null()); 699 bio_s_out=BIO_new(BIO_s_null());
617 } 700 }
@@ -622,7 +705,7 @@ bad:
622 } 705 }
623 } 706 }
624 707
625#if !defined(NO_RSA) || !defined(NO_DSA) 708#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
626 if (nocert) 709 if (nocert)
627#endif 710#endif
628 { 711 {
@@ -635,28 +718,7 @@ bad:
635 SSL_load_error_strings(); 718 SSL_load_error_strings();
636 OpenSSL_add_ssl_algorithms(); 719 OpenSSL_add_ssl_algorithms();
637 720
638 if (engine_id != NULL) 721 e = setup_engine(bio_err, engine_id, 1);
639 {
640 if((e = ENGINE_by_id(engine_id)) == NULL)
641 {
642 BIO_printf(bio_err,"invalid engine\n");
643 ERR_print_errors(bio_err);
644 goto end;
645 }
646 if (s_debug)
647 {
648 ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
649 0, bio_err, 0);
650 }
651 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
652 {
653 BIO_printf(bio_err,"can't use that engine\n");
654 ERR_print_errors(bio_err);
655 goto end;
656 }
657 BIO_printf(bio_err,"engine \"%s\" set.\n", engine_id);
658 ENGINE_free(e);
659 }
660 722
661 ctx=SSL_CTX_new(meth); 723 ctx=SSL_CTX_new(meth);
662 if (ctx == NULL) 724 if (ctx == NULL)
@@ -664,12 +726,26 @@ bad:
664 ERR_print_errors(bio_err); 726 ERR_print_errors(bio_err);
665 goto end; 727 goto end;
666 } 728 }
667 729 if (session_id_prefix)
730 {
731 if(strlen(session_id_prefix) >= 32)
732 BIO_printf(bio_err,
733"warning: id_prefix is too long, only one new session will be possible\n");
734 else if(strlen(session_id_prefix) >= 16)
735 BIO_printf(bio_err,
736"warning: id_prefix is too long if you use SSLv2\n");
737 if(!SSL_CTX_set_generate_session_id(ctx, generate_session_id))
738 {
739 BIO_printf(bio_err,"error setting 'id_prefix'\n");
740 ERR_print_errors(bio_err);
741 goto end;
742 }
743 BIO_printf(bio_err,"id_prefix '%s' set.\n", session_id_prefix);
744 }
668 SSL_CTX_set_quiet_shutdown(ctx,1); 745 SSL_CTX_set_quiet_shutdown(ctx,1);
669 if (bugs) SSL_CTX_set_options(ctx,SSL_OP_ALL); 746 if (bugs) SSL_CTX_set_options(ctx,SSL_OP_ALL);
670 if (hack) SSL_CTX_set_options(ctx,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG); 747 if (hack) SSL_CTX_set_options(ctx,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
671 SSL_CTX_set_options(ctx,off); 748 SSL_CTX_set_options(ctx,off);
672 if (hack) SSL_CTX_set_options(ctx,SSL_OP_NON_EXPORT_FIRST);
673 749
674 if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback); 750 if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
675 751
@@ -694,11 +770,19 @@ bad:
694 ERR_print_errors(bio_err); 770 ERR_print_errors(bio_err);
695 /* goto end; */ 771 /* goto end; */
696 } 772 }
773 store = SSL_CTX_get_cert_store(ctx);
774 X509_STORE_set_flags(store, vflags);
697 775
698#ifndef NO_DH 776#ifndef OPENSSL_NO_DH
699 if (!no_dhe) 777 if (!no_dhe)
700 { 778 {
701 dh=load_dh_param(dhfile ? dhfile : s_cert_file); 779 DH *dh=NULL;
780
781 if (dhfile)
782 dh = load_dh_param(dhfile);
783 else if (s_cert_file)
784 dh = load_dh_param(s_cert_file);
785
702 if (dh != NULL) 786 if (dh != NULL)
703 { 787 {
704 BIO_printf(bio_s_out,"Setting temp DH parameters\n"); 788 BIO_printf(bio_s_out,"Setting temp DH parameters\n");
@@ -723,7 +807,7 @@ bad:
723 goto end; 807 goto end;
724 } 808 }
725 809
726#ifndef NO_RSA 810#ifndef OPENSSL_NO_RSA
727#if 1 811#if 1
728 if (!no_tmp_rsa) 812 if (!no_tmp_rsa)
729 SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb); 813 SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb);
@@ -775,6 +859,7 @@ end:
775 BIO_free(bio_s_out); 859 BIO_free(bio_s_out);
776 bio_s_out=NULL; 860 bio_s_out=NULL;
777 } 861 }
862 apps_shutdown();
778 EXIT(ret); 863 EXIT(ret);
779 } 864 }
780 865
@@ -812,7 +897,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
812 unsigned long l; 897 unsigned long l;
813 SSL *con=NULL; 898 SSL *con=NULL;
814 BIO *sbio; 899 BIO *sbio;
815#ifdef WINDOWS 900#ifdef OPENSSL_SYS_WINDOWS
816 struct timeval tv; 901 struct timeval tv;
817#endif 902#endif
818 903
@@ -835,6 +920,15 @@ static int sv_body(char *hostname, int s, unsigned char *context)
835 920
836 if (con == NULL) { 921 if (con == NULL) {
837 con=SSL_new(ctx); 922 con=SSL_new(ctx);
923#ifndef OPENSSL_NO_KRB5
924 if ((con->kssl_ctx = kssl_ctx_new()) != NULL)
925 {
926 kssl_ctx_setstring(con->kssl_ctx, KSSL_SERVICE,
927 KRB5SVC);
928 kssl_ctx_setstring(con->kssl_ctx, KSSL_KEYTAB,
929 KRB5KEYTAB);
930 }
931#endif /* OPENSSL_NO_KRB5 */
838 if(context) 932 if(context)
839 SSL_set_session_id_context(con, context, 933 SSL_set_session_id_context(con, context,
840 strlen((char *)context)); 934 strlen((char *)context));
@@ -859,6 +953,11 @@ static int sv_body(char *hostname, int s, unsigned char *context)
859 BIO_set_callback(SSL_get_rbio(con),bio_dump_cb); 953 BIO_set_callback(SSL_get_rbio(con),bio_dump_cb);
860 BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out); 954 BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out);
861 } 955 }
956 if (s_msg)
957 {
958 SSL_set_msg_callback(con, msg_cb);
959 SSL_set_msg_callback_arg(con, bio_s_out);
960 }
862 961
863 width=s+1; 962 width=s+1;
864 for (;;) 963 for (;;)
@@ -872,7 +971,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
872 if (!read_from_sslcon) 971 if (!read_from_sslcon)
873 { 972 {
874 FD_ZERO(&readfds); 973 FD_ZERO(&readfds);
875#ifndef WINDOWS 974#ifndef OPENSSL_SYS_WINDOWS
876 FD_SET(fileno(stdin),&readfds); 975 FD_SET(fileno(stdin),&readfds);
877#endif 976#endif
878 FD_SET(s,&readfds); 977 FD_SET(s,&readfds);
@@ -882,7 +981,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
882 * the compiler: if you do have a cast then you can either 981 * the compiler: if you do have a cast then you can either
883 * go for (int *) or (void *). 982 * go for (int *) or (void *).
884 */ 983 */
885#ifdef WINDOWS 984#ifdef OPENSSL_SYS_WINDOWS
886 /* Under Windows we can't select on stdin: only 985 /* Under Windows we can't select on stdin: only
887 * on sockets. As a workaround we timeout the select every 986 * on sockets. As a workaround we timeout the select every
888 * second and check for any keypress. In a proper Windows 987 * second and check for any keypress. In a proper Windows
@@ -1148,7 +1247,7 @@ static int init_ssl_connection(SSL *con)
1148 return(1); 1247 return(1);
1149 } 1248 }
1150 1249
1151#ifndef NO_DH 1250#ifndef OPENSSL_NO_DH
1152static DH *load_dh_param(char *dhfile) 1251static DH *load_dh_param(char *dhfile)
1153 { 1252 {
1154 DH *ret=NULL; 1253 DH *ret=NULL;
@@ -1217,6 +1316,13 @@ static int www_body(char *hostname, int s, unsigned char *context)
1217 if (!BIO_set_write_buffer_size(io,bufsize)) goto err; 1316 if (!BIO_set_write_buffer_size(io,bufsize)) goto err;
1218 1317
1219 if ((con=SSL_new(ctx)) == NULL) goto err; 1318 if ((con=SSL_new(ctx)) == NULL) goto err;
1319#ifndef OPENSSL_NO_KRB5
1320 if ((con->kssl_ctx = kssl_ctx_new()) != NULL)
1321 {
1322 kssl_ctx_setstring(con->kssl_ctx, KSSL_SERVICE, KRB5SVC);
1323 kssl_ctx_setstring(con->kssl_ctx, KSSL_KEYTAB, KRB5KEYTAB);
1324 }
1325#endif /* OPENSSL_NO_KRB5 */
1220 if(context) SSL_set_session_id_context(con, context, 1326 if(context) SSL_set_session_id_context(con, context,
1221 strlen((char *)context)); 1327 strlen((char *)context));
1222 1328
@@ -1244,6 +1350,11 @@ static int www_body(char *hostname, int s, unsigned char *context)
1244 BIO_set_callback(SSL_get_rbio(con),bio_dump_cb); 1350 BIO_set_callback(SSL_get_rbio(con),bio_dump_cb);
1245 BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out); 1351 BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out);
1246 } 1352 }
1353 if (s_msg)
1354 {
1355 SSL_set_msg_callback(con, msg_cb);
1356 SSL_set_msg_callback_arg(con, bio_s_out);
1357 }
1247 1358
1248 blank=0; 1359 blank=0;
1249 for (;;) 1360 for (;;)
@@ -1284,7 +1395,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
1284 else 1395 else
1285 { 1396 {
1286 BIO_printf(bio_s_out,"read R BLOCK\n"); 1397 BIO_printf(bio_s_out,"read R BLOCK\n");
1287#ifndef MSDOS 1398#ifndef OPENSSL_SYS_MSDOS
1288 sleep(1); 1399 sleep(1);
1289#endif 1400#endif
1290 continue; 1401 continue;
@@ -1378,7 +1489,8 @@ static int www_body(char *hostname, int s, unsigned char *context)
1378 BIO_puts(io,"</BODY></HTML>\r\n\r\n"); 1489 BIO_puts(io,"</BODY></HTML>\r\n\r\n");
1379 break; 1490 break;
1380 } 1491 }
1381 else if ((www == 2) && (strncmp("GET /",buf,5) == 0)) 1492 else if ((www == 2 || www == 3)
1493 && (strncmp("GET /",buf,5) == 0))
1382 { 1494 {
1383 BIO *file; 1495 BIO *file;
1384 char *p,*e; 1496 char *p,*e;
@@ -1468,13 +1580,16 @@ static int www_body(char *hostname, int s, unsigned char *context)
1468 if (!s_quiet) 1580 if (!s_quiet)
1469 BIO_printf(bio_err,"FILE:%s\n",p); 1581 BIO_printf(bio_err,"FILE:%s\n",p);
1470 1582
1471 i=strlen(p); 1583 if (www == 2)
1472 if ( ((i > 5) && (strcmp(&(p[i-5]),".html") == 0)) || 1584 {
1473 ((i > 4) && (strcmp(&(p[i-4]),".php") == 0)) || 1585 i=strlen(p);
1474 ((i > 4) && (strcmp(&(p[i-4]),".htm") == 0))) 1586 if ( ((i > 5) && (strcmp(&(p[i-5]),".html") == 0)) ||
1475 BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n"); 1587 ((i > 4) && (strcmp(&(p[i-4]),".php") == 0)) ||
1476 else 1588 ((i > 4) && (strcmp(&(p[i-4]),".htm") == 0)))
1477 BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n"); 1589 BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n");
1590 else
1591 BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n");
1592 }
1478 /* send the file */ 1593 /* send the file */
1479 total_bytes=0; 1594 total_bytes=0;
1480 for (;;) 1595 for (;;)
@@ -1552,7 +1667,7 @@ err:
1552 return(ret); 1667 return(ret);
1553 } 1668 }
1554 1669
1555#ifndef NO_RSA 1670#ifndef OPENSSL_NO_RSA
1556static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength) 1671static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1557 { 1672 {
1558 static RSA *rsa_tmp=NULL; 1673 static RSA *rsa_tmp=NULL;
@@ -1574,3 +1689,26 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1574 return(rsa_tmp); 1689 return(rsa_tmp);
1575 } 1690 }
1576#endif 1691#endif
1692
1693#define MAX_SESSION_ID_ATTEMPTS 10
1694static int generate_session_id(const SSL *ssl, unsigned char *id,
1695 unsigned int *id_len)
1696 {
1697 unsigned int count = 0;
1698 do {
1699 RAND_pseudo_bytes(id, *id_len);
1700 /* Prefix the session_id with the required prefix. NB: If our
1701 * prefix is too long, clip it - but there will be worse effects
1702 * anyway, eg. the server could only possibly create 1 session
1703 * ID (ie. the prefix!) so all future session negotiations will
1704 * fail due to conflicts. */
1705 memcpy(id, session_id_prefix,
1706 (strlen(session_id_prefix) < *id_len) ?
1707 strlen(session_id_prefix) : *id_len);
1708 }
1709 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
1710 (++count < MAX_SESSION_ID_ATTEMPTS));
1711 if(count >= MAX_SESSION_ID_ATTEMPTS)
1712 return 0;
1713 return 1;
1714 }
diff --git a/src/lib/libssl/src/apps/s_socket.c b/src/lib/libssl/src/apps/s_socket.c
index 9812e6d505..bd499d020c 100644
--- a/src/lib/libssl/src/apps/s_socket.c
+++ b/src/lib/libssl/src/apps/s_socket.c
@@ -62,11 +62,13 @@
62#include <errno.h> 62#include <errno.h>
63#include <signal.h> 63#include <signal.h>
64 64
65#include <openssl/e_os2.h>
66
65/* With IPv6, it looks like Digital has mixed up the proper order of 67/* With IPv6, it looks like Digital has mixed up the proper order of
66 recursive header file inclusion, resulting in the compiler complaining 68 recursive header file inclusion, resulting in the compiler complaining
67 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which 69 that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
68 is needed to have fileno() declared correctly... So let's define u_int */ 70 is needed to have fileno() declared correctly... So let's define u_int */
69#if defined(VMS) && defined(__DECC) && !defined(__U_INT) 71#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__U_INT)
70#define __U_INT 72#define __U_INT
71typedef unsigned int u_int; 73typedef unsigned int u_int;
72#endif 74#endif
@@ -80,7 +82,7 @@ typedef unsigned int u_int;
80#include <openssl/ssl.h> 82#include <openssl/ssl.h>
81 83
82static struct hostent *GetHostByName(char *name); 84static struct hostent *GetHostByName(char *name);
83#ifdef WINDOWS 85#ifdef OPENSSL_SYS_WINDOWS
84static void sock_cleanup(void); 86static void sock_cleanup(void);
85#endif 87#endif
86static int sock_init(void); 88static int sock_init(void);
@@ -90,17 +92,17 @@ static int init_server_long(int *sock, int port,char *ip);
90static int do_accept(int acc_sock, int *sock, char **host); 92static int do_accept(int acc_sock, int *sock, char **host);
91static int host_ip(char *str, unsigned char ip[4]); 93static int host_ip(char *str, unsigned char ip[4]);
92 94
93#ifdef WIN16 95#ifdef OPENSSL_SYS_WIN16
94#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 96#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
95#else 97#else
96#define SOCKET_PROTOCOL IPPROTO_TCP 98#define SOCKET_PROTOCOL IPPROTO_TCP
97#endif 99#endif
98 100
99#ifdef WINDOWS 101#ifdef OPENSSL_SYS_WINDOWS
100static struct WSAData wsa_state; 102static struct WSAData wsa_state;
101static int wsa_init_done=0; 103static int wsa_init_done=0;
102 104
103#ifdef WIN16 105#ifdef OPENSSL_SYS_WIN16
104static HWND topWnd=0; 106static HWND topWnd=0;
105static FARPROC lpTopWndProc=NULL; 107static FARPROC lpTopWndProc=NULL;
106static FARPROC lpTopHookProc=NULL; 108static FARPROC lpTopHookProc=NULL;
@@ -129,10 +131,10 @@ static BOOL CALLBACK enumproc(HWND hwnd,LPARAM lParam)
129 return(FALSE); 131 return(FALSE);
130 } 132 }
131 133
132#endif /* WIN32 */ 134#endif /* OPENSSL_SYS_WIN32 */
133#endif /* WINDOWS */ 135#endif /* OPENSSL_SYS_WINDOWS */
134 136
135#ifdef WINDOWS 137#ifdef OPENSSL_SYS_WINDOWS
136static void sock_cleanup(void) 138static void sock_cleanup(void)
137 { 139 {
138 if (wsa_init_done) 140 if (wsa_init_done)
@@ -146,7 +148,7 @@ static void sock_cleanup(void)
146 148
147static int sock_init(void) 149static int sock_init(void)
148 { 150 {
149#ifdef WINDOWS 151#ifdef OPENSSL_SYS_WINDOWS
150 if (!wsa_init_done) 152 if (!wsa_init_done)
151 { 153 {
152 int err; 154 int err;
@@ -163,15 +165,15 @@ static int sock_init(void)
163 return(0); 165 return(0);
164 } 166 }
165 167
166#ifdef WIN16 168#ifdef OPENSSL_SYS_WIN16
167 EnumTaskWindows(GetCurrentTask(),enumproc,0L); 169 EnumTaskWindows(GetCurrentTask(),enumproc,0L);
168 lpTopWndProc=(FARPROC)GetWindowLong(topWnd,GWL_WNDPROC); 170 lpTopWndProc=(FARPROC)GetWindowLong(topWnd,GWL_WNDPROC);
169 lpTopHookProc=MakeProcInstance((FARPROC)topHookProc,_hInstance); 171 lpTopHookProc=MakeProcInstance((FARPROC)topHookProc,_hInstance);
170 172
171 SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopHookProc); 173 SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopHookProc);
172#endif /* WIN16 */ 174#endif /* OPENSSL_SYS_WIN16 */
173 } 175 }
174#endif /* WINDOWS */ 176#endif /* OPENSSL_SYS_WINDOWS */
175 return(1); 177 return(1);
176 } 178 }
177 179
@@ -209,7 +211,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port)
209 s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); 211 s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
210 if (s == INVALID_SOCKET) { perror("socket"); return(0); } 212 if (s == INVALID_SOCKET) { perror("socket"); return(0); }
211 213
212#ifndef MPE 214#ifndef OPENSSL_SYS_MPE
213 i=0; 215 i=0;
214 i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); 216 i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
215 if (i < 0) { perror("keepalive"); return(0); } 217 if (i < 0) { perror("keepalive"); return(0); }
@@ -285,7 +287,7 @@ static int init_server_long(int *sock, int port, char *ip)
285#endif 287#endif
286 if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1) 288 if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
287 { 289 {
288#ifndef WINDOWS 290#ifndef OPENSSL_SYS_WINDOWS
289 perror("bind"); 291 perror("bind");
290#endif 292#endif
291 goto err; 293 goto err;
@@ -318,7 +320,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
318 320
319 if (!sock_init()) return(0); 321 if (!sock_init()) return(0);
320 322
321#ifndef WINDOWS 323#ifndef OPENSSL_SYS_WINDOWS
322redoit: 324redoit:
323#endif 325#endif
324 326
@@ -332,7 +334,7 @@ redoit:
332 ret=accept(acc_sock,(struct sockaddr *)&from,(void *)&len); 334 ret=accept(acc_sock,(struct sockaddr *)&from,(void *)&len);
333 if (ret == INVALID_SOCKET) 335 if (ret == INVALID_SOCKET)
334 { 336 {
335#ifdef WINDOWS 337#ifdef OPENSSL_SYS_WINDOWS
336 i=WSAGetLastError(); 338 i=WSAGetLastError();
337 BIO_printf(bio_err,"accept error %d\n",i); 339 BIO_printf(bio_err,"accept error %d\n",i);
338#else 340#else
diff --git a/src/lib/libssl/src/apps/s_time.c b/src/lib/libssl/src/apps/s_time.c
index 39fd3b8b4d..2fb853d071 100644
--- a/src/lib/libssl/src/apps/s_time.c
+++ b/src/lib/libssl/src/apps/s_time.c
@@ -67,22 +67,25 @@
67#include <stdlib.h> 67#include <stdlib.h>
68#include <string.h> 68#include <string.h>
69 69
70#ifdef NO_STDIO 70#define USE_SOCKETS
71#include "apps.h"
72#ifdef OPENSSL_NO_STDIO
71#define APPS_WIN16 73#define APPS_WIN16
72#endif 74#endif
73#define USE_SOCKETS
74#include <openssl/x509.h> 75#include <openssl/x509.h>
75#include <openssl/ssl.h> 76#include <openssl/ssl.h>
76#include <openssl/pem.h> 77#include <openssl/pem.h>
77#include "apps.h"
78#include "s_apps.h" 78#include "s_apps.h"
79#include <openssl/err.h> 79#include <openssl/err.h>
80#ifdef WIN32_STUFF 80#ifdef WIN32_STUFF
81#include "winmain.h" 81#include "winmain.h"
82#include "wintext.h" 82#include "wintext.h"
83#endif 83#endif
84#if !defined(OPENSSL_SYS_MSDOS)
85#include OPENSSL_UNISTD
86#endif
84 87
85#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 88#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
86#define TIMES 89#define TIMES
87#endif 90#endif
88 91
@@ -98,11 +101,11 @@
98 The __TMS macro will show if it was. If it wasn't defined, we should 101 The __TMS macro will show if it was. If it wasn't defined, we should
99 undefine TIMES, since that tells the rest of the program how things 102 undefine TIMES, since that tells the rest of the program how things
100 should be handled. -- Richard Levitte */ 103 should be handled. -- Richard Levitte */
101#if defined(VMS) && defined(__DECC) && !defined(__TMS) 104#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
102#undef TIMES 105#undef TIMES
103#endif 106#endif
104 107
105#ifndef TIMES 108#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS)
106#include <sys/timeb.h> 109#include <sys/timeb.h>
107#endif 110#endif
108 111
@@ -119,11 +122,19 @@
119/* The following if from times(3) man page. It may need to be changed 122/* The following if from times(3) man page. It may need to be changed
120*/ 123*/
121#ifndef HZ 124#ifndef HZ
122#ifndef CLK_TCK 125# ifdef _SC_CLK_TCK
123#define HZ 100.0 126# define HZ ((double)sysconf(_SC_CLK_TCK))
124#else /* CLK_TCK */ 127# else
125#define HZ ((double)CLK_TCK) 128# ifndef CLK_TCK
126#endif 129# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
130# define HZ 100.0
131# else /* _BSD_CLK_TCK_ */
132# define HZ ((double)_BSD_CLK_TCK_)
133# endif
134# else /* CLK_TCK */
135# define HZ ((double)CLK_TCK)
136# endif
137# endif
127#endif 138#endif
128 139
129#undef PROG 140#undef PROG
@@ -139,6 +150,8 @@
139#undef BUFSIZZ 150#undef BUFSIZZ
140#define BUFSIZZ 1024*10 151#define BUFSIZZ 1024*10
141 152
153#undef min
154#undef max
142#define min(a,b) (((a) < (b)) ? (a) : (b)) 155#define min(a,b) (((a) < (b)) ? (a) : (b))
143#define max(a,b) (((a) > (b)) ? (a) : (b)) 156#define max(a,b) (((a) > (b)) ? (a) : (b))
144 157
@@ -174,7 +187,7 @@ static int perform=0;
174#ifdef FIONBIO 187#ifdef FIONBIO
175static int t_nbio=0; 188static int t_nbio=0;
176#endif 189#endif
177#ifdef WIN32 190#ifdef OPENSSL_SYS_WIN32
178static int exitNow = 0; /* Set when it's time to exit main */ 191static int exitNow = 0; /* Set when it's time to exit main */
179#endif 192#endif
180 193
@@ -198,7 +211,7 @@ static void s_time_init(void)
198#ifdef FIONBIO 211#ifdef FIONBIO
199 t_nbio=0; 212 t_nbio=0;
200#endif 213#endif
201#ifdef WIN32 214#ifdef OPENSSL_SYS_WIN32
202 exitNow = 0; /* Set when it's time to exit main */ 215 exitNow = 0; /* Set when it's time to exit main */
203#endif 216#endif
204 } 217 }
@@ -314,11 +327,11 @@ static int parseArgs(int argc, char **argv)
314 } 327 }
315 else if(strcmp(*argv,"-bugs") == 0) 328 else if(strcmp(*argv,"-bugs") == 0)
316 st_bugs=1; 329 st_bugs=1;
317#ifndef NO_SSL2 330#ifndef OPENSSL_NO_SSL2
318 else if(strcmp(*argv,"-ssl2") == 0) 331 else if(strcmp(*argv,"-ssl2") == 0)
319 s_time_meth=SSLv2_client_method(); 332 s_time_meth=SSLv2_client_method();
320#endif 333#endif
321#ifndef NO_SSL3 334#ifndef OPENSSL_NO_SSL3
322 else if(strcmp(*argv,"-ssl3") == 0) 335 else if(strcmp(*argv,"-ssl3") == 0)
323 s_time_meth=SSLv3_client_method(); 336 s_time_meth=SSLv3_client_method();
324#endif 337#endif
@@ -368,6 +381,22 @@ static double tm_Time_F(int s)
368 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; 381 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
369 return((ret == 0.0)?1e-6:ret); 382 return((ret == 0.0)?1e-6:ret);
370 } 383 }
384#elif defined(OPENSSL_SYS_VXWORKS)
385 {
386 static unsigned long tick_start, tick_end;
387
388 if( s == START )
389 {
390 tick_start = tickGet();
391 return 0;
392 }
393 else
394 {
395 tick_end = tickGet();
396 ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
397 return((ret == 0.0)?1e-6:ret);
398 }
399 }
371#else /* !times() */ 400#else /* !times() */
372 static struct timeb tstart,tend; 401 static struct timeb tstart,tend;
373 long i; 402 long i;
@@ -406,11 +435,11 @@ int MAIN(int argc, char **argv)
406 if (bio_err == NULL) 435 if (bio_err == NULL)
407 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 436 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
408 437
409#if !defined(NO_SSL2) && !defined(NO_SSL3) 438#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
410 s_time_meth=SSLv23_client_method(); 439 s_time_meth=SSLv23_client_method();
411#elif !defined(NO_SSL3) 440#elif !defined(OPENSSL_NO_SSL3)
412 s_time_meth=SSLv3_client_method(); 441 s_time_meth=SSLv3_client_method();
413#elif !defined(NO_SSL2) 442#elif !defined(OPENSSL_NO_SSL2)
414 s_time_meth=SSLv2_client_method(); 443 s_time_meth=SSLv2_client_method();
415#endif 444#endif
416 445
@@ -443,7 +472,6 @@ int MAIN(int argc, char **argv)
443 472
444 if (tm_cipher == NULL ) { 473 if (tm_cipher == NULL ) {
445 fprintf( stderr, "No CIPHER specified\n" ); 474 fprintf( stderr, "No CIPHER specified\n" );
446/* EXIT(1); */
447 } 475 }
448 476
449 if (!(perform & 1)) goto next; 477 if (!(perform & 1)) goto next;
@@ -610,6 +638,7 @@ end:
610 SSL_CTX_free(tm_ctx); 638 SSL_CTX_free(tm_ctx);
611 tm_ctx=NULL; 639 tm_ctx=NULL;
612 } 640 }
641 apps_shutdown();
613 EXIT(ret); 642 EXIT(ret);
614 } 643 }
615 644
diff --git a/src/lib/libssl/src/apps/sess_id.c b/src/lib/libssl/src/apps/sess_id.c
index 60cc3f1e49..41c3b3f4a3 100644
--- a/src/lib/libssl/src/apps/sess_id.c
+++ b/src/lib/libssl/src/apps/sess_id.c
@@ -156,7 +156,7 @@ int MAIN(int argc, char **argv)
156 { 156 {
157bad: 157bad:
158 for (pp=sess_id_usage; (*pp != NULL); pp++) 158 for (pp=sess_id_usage; (*pp != NULL); pp++)
159 BIO_printf(bio_err,*pp); 159 BIO_printf(bio_err,"%s",*pp);
160 goto end; 160 goto end;
161 } 161 }
162 162
@@ -208,7 +208,7 @@ bad:
208 if (outfile == NULL) 208 if (outfile == NULL)
209 { 209 {
210 BIO_set_fp(out,stdout,BIO_NOCLOSE); 210 BIO_set_fp(out,stdout,BIO_NOCLOSE);
211#ifdef VMS 211#ifdef OPENSSL_SYS_VMS
212 { 212 {
213 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 213 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
214 out = BIO_push(tmpbio, out); 214 out = BIO_push(tmpbio, out);
@@ -272,6 +272,7 @@ bad:
272end: 272end:
273 if (out != NULL) BIO_free_all(out); 273 if (out != NULL) BIO_free_all(out);
274 if (x != NULL) SSL_SESSION_free(x); 274 if (x != NULL) SSL_SESSION_free(x);
275 apps_shutdown();
275 EXIT(ret); 276 EXIT(ret);
276 } 277 }
277 278
diff --git a/src/lib/libssl/src/apps/smime.c b/src/lib/libssl/src/apps/smime.c
index 7bf71ef868..90fe026f56 100644
--- a/src/lib/libssl/src/apps/smime.c
+++ b/src/lib/libssl/src/apps/smime.c
@@ -64,11 +64,9 @@
64#include <openssl/crypto.h> 64#include <openssl/crypto.h>
65#include <openssl/pem.h> 65#include <openssl/pem.h>
66#include <openssl/err.h> 66#include <openssl/err.h>
67#include <openssl/engine.h>
68 67
69#undef PROG 68#undef PROG
70#define PROG smime_main 69#define PROG smime_main
71static X509_STORE *setup_verify(char *CAfile, char *CApath);
72static int save_certs(char *signerfile, STACK_OF(X509) *signers); 70static int save_certs(char *signerfile, STACK_OF(X509) *signers);
73 71
74#define SMIME_OP 0x10 72#define SMIME_OP 0x10
@@ -90,7 +88,7 @@ int MAIN(int argc, char **argv)
90 char *infile = NULL, *outfile = NULL; 88 char *infile = NULL, *outfile = NULL;
91 char *signerfile = NULL, *recipfile = NULL; 89 char *signerfile = NULL, *recipfile = NULL;
92 char *certfile = NULL, *keyfile = NULL, *contfile=NULL; 90 char *certfile = NULL, *keyfile = NULL, *contfile=NULL;
93 EVP_CIPHER *cipher = NULL; 91 const EVP_CIPHER *cipher = NULL;
94 PKCS7 *p7 = NULL; 92 PKCS7 *p7 = NULL;
95 X509_STORE *store = NULL; 93 X509_STORE *store = NULL;
96 X509 *cert = NULL, *recip = NULL, *signer = NULL; 94 X509 *cert = NULL, *recip = NULL, *signer = NULL;
@@ -98,31 +96,41 @@ int MAIN(int argc, char **argv)
98 STACK_OF(X509) *encerts = NULL, *other = NULL; 96 STACK_OF(X509) *encerts = NULL, *other = NULL;
99 BIO *in = NULL, *out = NULL, *indata = NULL; 97 BIO *in = NULL, *out = NULL, *indata = NULL;
100 int badarg = 0; 98 int badarg = 0;
101 int flags = PKCS7_DETACHED; 99 int flags = PKCS7_DETACHED, store_flags = 0;
102 char *to = NULL, *from = NULL, *subject = NULL; 100 char *to = NULL, *from = NULL, *subject = NULL;
103 char *CAfile = NULL, *CApath = NULL; 101 char *CAfile = NULL, *CApath = NULL;
104 char *passargin = NULL, *passin = NULL; 102 char *passargin = NULL, *passin = NULL;
105 char *inrand = NULL; 103 char *inrand = NULL;
106 int need_rand = 0; 104 int need_rand = 0;
107 int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; 105 int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
106 int keyform = FORMAT_PEM;
108 char *engine=NULL; 107 char *engine=NULL;
109 108
110 args = argv + 1; 109 args = argv + 1;
111 ret = 1; 110 ret = 1;
112 111
112 apps_startup();
113
114 if (bio_err == NULL)
115 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
116 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
117
118 if (!load_config(bio_err, NULL))
119 goto end;
120
113 while (!badarg && *args && *args[0] == '-') { 121 while (!badarg && *args && *args[0] == '-') {
114 if (!strcmp (*args, "-encrypt")) operation = SMIME_ENCRYPT; 122 if (!strcmp (*args, "-encrypt")) operation = SMIME_ENCRYPT;
115 else if (!strcmp (*args, "-decrypt")) operation = SMIME_DECRYPT; 123 else if (!strcmp (*args, "-decrypt")) operation = SMIME_DECRYPT;
116 else if (!strcmp (*args, "-sign")) operation = SMIME_SIGN; 124 else if (!strcmp (*args, "-sign")) operation = SMIME_SIGN;
117 else if (!strcmp (*args, "-verify")) operation = SMIME_VERIFY; 125 else if (!strcmp (*args, "-verify")) operation = SMIME_VERIFY;
118 else if (!strcmp (*args, "-pk7out")) operation = SMIME_PK7OUT; 126 else if (!strcmp (*args, "-pk7out")) operation = SMIME_PK7OUT;
119#ifndef NO_DES 127#ifndef OPENSSL_NO_DES
120 else if (!strcmp (*args, "-des3")) 128 else if (!strcmp (*args, "-des3"))
121 cipher = EVP_des_ede3_cbc(); 129 cipher = EVP_des_ede3_cbc();
122 else if (!strcmp (*args, "-des")) 130 else if (!strcmp (*args, "-des"))
123 cipher = EVP_des_cbc(); 131 cipher = EVP_des_cbc();
124#endif 132#endif
125#ifndef NO_RC2 133#ifndef OPENSSL_NO_RC2
126 else if (!strcmp (*args, "-rc2-40")) 134 else if (!strcmp (*args, "-rc2-40"))
127 cipher = EVP_rc2_40_cbc(); 135 cipher = EVP_rc2_40_cbc();
128 else if (!strcmp (*args, "-rc2-128")) 136 else if (!strcmp (*args, "-rc2-128"))
@@ -130,6 +138,14 @@ int MAIN(int argc, char **argv)
130 else if (!strcmp (*args, "-rc2-64")) 138 else if (!strcmp (*args, "-rc2-64"))
131 cipher = EVP_rc2_64_cbc(); 139 cipher = EVP_rc2_64_cbc();
132#endif 140#endif
141#ifndef OPENSSL_NO_AES
142 else if (!strcmp(*args,"-aes128"))
143 cipher = EVP_aes_128_cbc();
144 else if (!strcmp(*args,"-aes192"))
145 cipher = EVP_aes_192_cbc();
146 else if (!strcmp(*args,"-aes256"))
147 cipher = EVP_aes_256_cbc();
148#endif
133 else if (!strcmp (*args, "-text")) 149 else if (!strcmp (*args, "-text"))
134 flags |= PKCS7_TEXT; 150 flags |= PKCS7_TEXT;
135 else if (!strcmp (*args, "-nointern")) 151 else if (!strcmp (*args, "-nointern"))
@@ -150,6 +166,10 @@ int MAIN(int argc, char **argv)
150 flags |= PKCS7_BINARY; 166 flags |= PKCS7_BINARY;
151 else if (!strcmp (*args, "-nosigs")) 167 else if (!strcmp (*args, "-nosigs"))
152 flags |= PKCS7_NOSIGS; 168 flags |= PKCS7_NOSIGS;
169 else if (!strcmp (*args, "-crl_check"))
170 store_flags |= X509_V_FLAG_CRL_CHECK;
171 else if (!strcmp (*args, "-crl_check_all"))
172 store_flags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;
153 else if (!strcmp(*args,"-rand")) { 173 else if (!strcmp(*args,"-rand")) {
154 if (args[1]) { 174 if (args[1]) {
155 args++; 175 args++;
@@ -196,6 +216,11 @@ int MAIN(int argc, char **argv)
196 args++; 216 args++;
197 keyfile = *args; 217 keyfile = *args;
198 } else badarg = 1; 218 } else badarg = 1;
219 } else if (!strcmp (*args, "-keyform")) {
220 if (args[1]) {
221 args++;
222 keyform = str2fmt(*args);
223 } else badarg = 1;
199 } else if (!strcmp (*args, "-certfile")) { 224 } else if (!strcmp (*args, "-certfile")) {
200 if (args[1]) { 225 if (args[1]) {
201 args++; 226 args++;
@@ -267,15 +292,19 @@ int MAIN(int argc, char **argv)
267 BIO_printf (bio_err, "-sign sign message\n"); 292 BIO_printf (bio_err, "-sign sign message\n");
268 BIO_printf (bio_err, "-verify verify signed message\n"); 293 BIO_printf (bio_err, "-verify verify signed message\n");
269 BIO_printf (bio_err, "-pk7out output PKCS#7 structure\n"); 294 BIO_printf (bio_err, "-pk7out output PKCS#7 structure\n");
270#ifndef NO_DES 295#ifndef OPENSSL_NO_DES
271 BIO_printf (bio_err, "-des3 encrypt with triple DES\n"); 296 BIO_printf (bio_err, "-des3 encrypt with triple DES\n");
272 BIO_printf (bio_err, "-des encrypt with DES\n"); 297 BIO_printf (bio_err, "-des encrypt with DES\n");
273#endif 298#endif
274#ifndef NO_RC2 299#ifndef OPENSSL_NO_RC2
275 BIO_printf (bio_err, "-rc2-40 encrypt with RC2-40 (default)\n"); 300 BIO_printf (bio_err, "-rc2-40 encrypt with RC2-40 (default)\n");
276 BIO_printf (bio_err, "-rc2-64 encrypt with RC2-64\n"); 301 BIO_printf (bio_err, "-rc2-64 encrypt with RC2-64\n");
277 BIO_printf (bio_err, "-rc2-128 encrypt with RC2-128\n"); 302 BIO_printf (bio_err, "-rc2-128 encrypt with RC2-128\n");
278#endif 303#endif
304#ifndef OPENSSL_NO_AES
305 BIO_printf (bio_err, "-aes128, -aes192, -aes256\n");
306 BIO_printf (bio_err, " encrypt PEM output with cbc aes\n");
307#endif
279 BIO_printf (bio_err, "-nointern don't search certificates in message for signer\n"); 308 BIO_printf (bio_err, "-nointern don't search certificates in message for signer\n");
280 BIO_printf (bio_err, "-nosigs don't verify message signature\n"); 309 BIO_printf (bio_err, "-nosigs don't verify message signature\n");
281 BIO_printf (bio_err, "-noverify don't verify signers certificate\n"); 310 BIO_printf (bio_err, "-noverify don't verify signers certificate\n");
@@ -289,6 +318,7 @@ int MAIN(int argc, char **argv)
289 BIO_printf (bio_err, "-in file input file\n"); 318 BIO_printf (bio_err, "-in file input file\n");
290 BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n"); 319 BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n");
291 BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n"); 320 BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n");
321 BIO_printf (bio_err, "-keyform arg input private key format (PEM or ENGINE)\n");
292 BIO_printf (bio_err, "-out file output file\n"); 322 BIO_printf (bio_err, "-out file output file\n");
293 BIO_printf (bio_err, "-outform arg output format SMIME (default), PEM or DER\n"); 323 BIO_printf (bio_err, "-outform arg output format SMIME (default), PEM or DER\n");
294 BIO_printf (bio_err, "-content file supply or override content for detached signature\n"); 324 BIO_printf (bio_err, "-content file supply or override content for detached signature\n");
@@ -298,6 +328,8 @@ int MAIN(int argc, char **argv)
298 BIO_printf (bio_err, "-text include or delete text MIME headers\n"); 328 BIO_printf (bio_err, "-text include or delete text MIME headers\n");
299 BIO_printf (bio_err, "-CApath dir trusted certificates directory\n"); 329 BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
300 BIO_printf (bio_err, "-CAfile file trusted certificates file\n"); 330 BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
331 BIO_printf (bio_err, "-crl_check check revocation status of signer's certificate using CRLs\n");
332 BIO_printf (bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
301 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n"); 333 BIO_printf (bio_err, "-engine e use engine e, possibly a hardware device.\n");
302 BIO_printf (bio_err, "-passin arg input file pass phrase source\n"); 334 BIO_printf (bio_err, "-passin arg input file pass phrase source\n");
303 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); 335 BIO_printf(bio_err, "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
@@ -307,23 +339,7 @@ int MAIN(int argc, char **argv)
307 goto end; 339 goto end;
308 } 340 }
309 341
310 if (engine != NULL) 342 e = setup_engine(bio_err, engine, 0);
311 {
312 if((e = ENGINE_by_id(engine)) == NULL)
313 {
314 BIO_printf(bio_err,"invalid engine \"%s\"\n",
315 engine);
316 goto end;
317 }
318 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
319 {
320 BIO_printf(bio_err,"can't use that engine\n");
321 goto end;
322 }
323 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
324 /* Free our "structural" reference. */
325 ENGINE_free(e);
326 }
327 343
328 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { 344 if(!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
329 BIO_printf(bio_err, "Error getting password\n"); 345 BIO_printf(bio_err, "Error getting password\n");
@@ -351,7 +367,7 @@ int MAIN(int argc, char **argv)
351 367
352 if(operation == SMIME_ENCRYPT) { 368 if(operation == SMIME_ENCRYPT) {
353 if (!cipher) { 369 if (!cipher) {
354#ifndef NO_RC2 370#ifndef OPENSSL_NO_RC2
355 cipher = EVP_rc2_40_cbc(); 371 cipher = EVP_rc2_40_cbc();
356#else 372#else
357 BIO_printf(bio_err, "No cipher selected\n"); 373 BIO_printf(bio_err, "No cipher selected\n");
@@ -360,8 +376,11 @@ int MAIN(int argc, char **argv)
360 } 376 }
361 encerts = sk_X509_new_null(); 377 encerts = sk_X509_new_null();
362 while (*args) { 378 while (*args) {
363 if(!(cert = load_cert(bio_err,*args,FORMAT_PEM))) { 379 if(!(cert = load_cert(bio_err,*args,FORMAT_PEM,
380 NULL, e, "recipient certificate file"))) {
381#if 0 /* An appropriate message is already printed */
364 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", *args); 382 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", *args);
383#endif
365 goto end; 384 goto end;
366 } 385 }
367 sk_X509_push(encerts, cert); 386 sk_X509_push(encerts, cert);
@@ -371,23 +390,32 @@ int MAIN(int argc, char **argv)
371 } 390 }
372 391
373 if(signerfile && (operation == SMIME_SIGN)) { 392 if(signerfile && (operation == SMIME_SIGN)) {
374 if(!(signer = load_cert(bio_err,signerfile,FORMAT_PEM))) { 393 if(!(signer = load_cert(bio_err,signerfile,FORMAT_PEM, NULL,
394 e, "signer certificate"))) {
395#if 0 /* An appropri message has already been printed */
375 BIO_printf(bio_err, "Can't read signer certificate file %s\n", signerfile); 396 BIO_printf(bio_err, "Can't read signer certificate file %s\n", signerfile);
397#endif
376 goto end; 398 goto end;
377 } 399 }
378 } 400 }
379 401
380 if(certfile) { 402 if(certfile) {
381 if(!(other = load_certs(bio_err,certfile,FORMAT_PEM))) { 403 if(!(other = load_certs(bio_err,certfile,FORMAT_PEM, NULL,
404 e, "certificate file"))) {
405#if 0 /* An appropriate message has already been printed */
382 BIO_printf(bio_err, "Can't read certificate file %s\n", certfile); 406 BIO_printf(bio_err, "Can't read certificate file %s\n", certfile);
407#endif
383 ERR_print_errors(bio_err); 408 ERR_print_errors(bio_err);
384 goto end; 409 goto end;
385 } 410 }
386 } 411 }
387 412
388 if(recipfile && (operation == SMIME_DECRYPT)) { 413 if(recipfile && (operation == SMIME_DECRYPT)) {
389 if(!(recip = load_cert(bio_err,recipfile,FORMAT_PEM))) { 414 if(!(recip = load_cert(bio_err,recipfile,FORMAT_PEM,NULL,
415 e, "recipient certificate file"))) {
416#if 0 /* An appropriate message has alrady been printed */
390 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", recipfile); 417 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", recipfile);
418#endif
391 ERR_print_errors(bio_err); 419 ERR_print_errors(bio_err);
392 goto end; 420 goto end;
393 } 421 }
@@ -400,11 +428,11 @@ int MAIN(int argc, char **argv)
400 } else keyfile = NULL; 428 } else keyfile = NULL;
401 429
402 if(keyfile) { 430 if(keyfile) {
403 if(!(key = load_key(bio_err,keyfile, FORMAT_PEM, passin))) { 431 key = load_key(bio_err, keyfile, keyform, passin, e,
404 BIO_printf(bio_err, "Can't read recipient certificate file %s\n", keyfile); 432 "signing key file");
405 ERR_print_errors(bio_err); 433 if (!key) {
406 goto end; 434 goto end;
407 } 435 }
408 } 436 }
409 437
410 if (infile) { 438 if (infile) {
@@ -423,7 +451,7 @@ int MAIN(int argc, char **argv)
423 } 451 }
424 } else { 452 } else {
425 out = BIO_new_fp(stdout, BIO_NOCLOSE); 453 out = BIO_new_fp(stdout, BIO_NOCLOSE);
426#ifdef VMS 454#ifdef OPENSSL_SYS_VMS
427 { 455 {
428 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 456 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
429 out = BIO_push(tmpbio, out); 457 out = BIO_push(tmpbio, out);
@@ -432,16 +460,21 @@ int MAIN(int argc, char **argv)
432 } 460 }
433 461
434 if(operation == SMIME_VERIFY) { 462 if(operation == SMIME_VERIFY) {
435 if(!(store = setup_verify(CAfile, CApath))) goto end; 463 if(!(store = setup_verify(bio_err, CAfile, CApath))) goto end;
464 X509_STORE_set_flags(store, store_flags);
436 } 465 }
437 466
467
438 ret = 3; 468 ret = 3;
439 469
440 if(operation == SMIME_ENCRYPT) { 470 if(operation == SMIME_ENCRYPT) {
441 p7 = PKCS7_encrypt(encerts, in, cipher, flags); 471 p7 = PKCS7_encrypt(encerts, in, cipher, flags);
442 } else if(operation == SMIME_SIGN) { 472 } else if(operation == SMIME_SIGN) {
443 p7 = PKCS7_sign(signer, key, other, in, flags); 473 p7 = PKCS7_sign(signer, key, other, in, flags);
444 BIO_reset(in); 474 if (BIO_reset(in) != 0 && (flags & PKCS7_DETACHED)) {
475 BIO_printf(bio_err, "Can't rewind input file\n");
476 goto end;
477 }
445 } else { 478 } else {
446 if(informat == FORMAT_SMIME) 479 if(informat == FORMAT_SMIME)
447 p7 = SMIME_read_PKCS7(in, &indata); 480 p7 = SMIME_read_PKCS7(in, &indata);
@@ -481,9 +514,9 @@ int MAIN(int argc, char **argv)
481 } else if(operation == SMIME_VERIFY) { 514 } else if(operation == SMIME_VERIFY) {
482 STACK_OF(X509) *signers; 515 STACK_OF(X509) *signers;
483 if(PKCS7_verify(p7, other, store, indata, out, flags)) { 516 if(PKCS7_verify(p7, other, store, indata, out, flags)) {
484 BIO_printf(bio_err, "Verification Successful\n"); 517 BIO_printf(bio_err, "Verification successful\n");
485 } else { 518 } else {
486 BIO_printf(bio_err, "Verification Failure\n"); 519 BIO_printf(bio_err, "Verification failure\n");
487 goto end; 520 goto end;
488 } 521 }
489 signers = PKCS7_get0_signers(p7, other, flags); 522 signers = PKCS7_get0_signers(p7, other, flags);
@@ -531,36 +564,6 @@ end:
531 return (ret); 564 return (ret);
532} 565}
533 566
534static X509_STORE *setup_verify(char *CAfile, char *CApath)
535{
536 X509_STORE *store;
537 X509_LOOKUP *lookup;
538 if(!(store = X509_STORE_new())) goto end;
539 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
540 if (lookup == NULL) goto end;
541 if (CAfile) {
542 if(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {
543 BIO_printf(bio_err, "Error loading file %s\n", CAfile);
544 goto end;
545 }
546 } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
547
548 lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
549 if (lookup == NULL) goto end;
550 if (CApath) {
551 if(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {
552 BIO_printf(bio_err, "Error loading directory %s\n", CApath);
553 goto end;
554 }
555 } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
556
557 ERR_clear_error();
558 return store;
559 end:
560 X509_STORE_free(store);
561 return NULL;
562}
563
564static int save_certs(char *signerfile, STACK_OF(X509) *signers) 567static int save_certs(char *signerfile, STACK_OF(X509) *signers)
565{ 568{
566 int i; 569 int i;
diff --git a/src/lib/libssl/src/apps/speed.c b/src/lib/libssl/src/apps/speed.c
index 9c91f718e0..78bf686b1b 100644
--- a/src/lib/libssl/src/apps/speed.c
+++ b/src/lib/libssl/src/apps/speed.c
@@ -1,4 +1,4 @@
1/* apps/speed.c */ 1/* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
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 *
@@ -75,20 +75,24 @@
75#include <string.h> 75#include <string.h>
76#include <math.h> 76#include <math.h>
77#include "apps.h" 77#include "apps.h"
78#ifdef NO_STDIO 78#ifdef OPENSSL_NO_STDIO
79#define APPS_WIN16 79#define APPS_WIN16
80#endif 80#endif
81#include <openssl/crypto.h> 81#include <openssl/crypto.h>
82#include <openssl/rand.h> 82#include <openssl/rand.h>
83#include <openssl/err.h> 83#include <openssl/err.h>
84#include <openssl/engine.h> 84#include <openssl/evp.h>
85#include <openssl/objects.h>
86#if !defined(OPENSSL_SYS_MSDOS)
87#include OPENSSL_UNISTD
88#endif
85 89
86#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 90#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
87# define USE_TOD 91# define USE_TOD
88#elif !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 92#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
89# define TIMES 93# define TIMES
90#endif 94#endif
91#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(MPE) && !defined(__NetBSD__) 95#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
92# define TIMEB 96# define TIMEB
93#endif 97#endif
94 98
@@ -108,7 +112,7 @@
108 The __TMS macro will show if it was. If it wasn't defined, we should 112 The __TMS macro will show if it was. If it wasn't defined, we should
109 undefine TIMES, since that tells the rest of the program how things 113 undefine TIMES, since that tells the rest of the program how things
110 should be handled. -- Richard Levitte */ 114 should be handled. -- Richard Levitte */
111#if defined(VMS) && defined(__DECC) && !defined(__TMS) 115#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
112#undef TIMES 116#undef TIMES
113#endif 117#endif
114 118
@@ -116,7 +120,7 @@
116#include <sys/timeb.h> 120#include <sys/timeb.h>
117#endif 121#endif
118 122
119#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) 123#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS)
120#error "It seems neither struct tms nor struct timeb is supported in this platform!" 124#error "It seems neither struct tms nor struct timeb is supported in this platform!"
121#endif 125#endif
122 126
@@ -126,78 +130,112 @@
126#include <sys/param.h> 130#include <sys/param.h>
127#endif 131#endif
128 132
129#ifndef NO_DES 133#ifndef OPENSSL_NO_DES
130#include <openssl/des.h> 134#include <openssl/des.h>
131#endif 135#endif
132#ifndef NO_MD2 136#ifndef OPENSSL_NO_AES
137#include <openssl/aes.h>
138#endif
139#ifndef OPENSSL_NO_MD2
133#include <openssl/md2.h> 140#include <openssl/md2.h>
134#endif 141#endif
135#ifndef NO_MDC2 142#ifndef OPENSSL_NO_MDC2
136#include <openssl/mdc2.h> 143#include <openssl/mdc2.h>
137#endif 144#endif
138#ifndef NO_MD4 145#ifndef OPENSSL_NO_MD4
139#include <openssl/md4.h> 146#include <openssl/md4.h>
140#endif 147#endif
141#ifndef NO_MD5 148#ifndef OPENSSL_NO_MD5
142#include <openssl/md5.h> 149#include <openssl/md5.h>
143#endif 150#endif
144#ifndef NO_HMAC 151#ifndef OPENSSL_NO_HMAC
145#include <openssl/hmac.h> 152#include <openssl/hmac.h>
146#endif 153#endif
147#include <openssl/evp.h> 154#include <openssl/evp.h>
148#ifndef NO_SHA 155#ifndef OPENSSL_NO_SHA
149#include <openssl/sha.h> 156#include <openssl/sha.h>
150#endif 157#endif
151#ifndef NO_RIPEMD 158#ifndef OPENSSL_NO_RIPEMD
152#include <openssl/ripemd.h> 159#include <openssl/ripemd.h>
153#endif 160#endif
154#ifndef NO_RC4 161#ifndef OPENSSL_NO_RC4
155#include <openssl/rc4.h> 162#include <openssl/rc4.h>
156#endif 163#endif
157#ifndef NO_RC5 164#ifndef OPENSSL_NO_RC5
158#include <openssl/rc5.h> 165#include <openssl/rc5.h>
159#endif 166#endif
160#ifndef NO_RC2 167#ifndef OPENSSL_NO_RC2
161#include <openssl/rc2.h> 168#include <openssl/rc2.h>
162#endif 169#endif
163#ifndef NO_IDEA 170#ifndef OPENSSL_NO_IDEA
164#include <openssl/idea.h> 171#include <openssl/idea.h>
165#endif 172#endif
166#ifndef NO_BF 173#ifndef OPENSSL_NO_BF
167#include <openssl/blowfish.h> 174#include <openssl/blowfish.h>
168#endif 175#endif
169#ifndef NO_CAST 176#ifndef OPENSSL_NO_CAST
170#include <openssl/cast.h> 177#include <openssl/cast.h>
171#endif 178#endif
172#ifndef NO_RSA 179#ifndef OPENSSL_NO_RSA
173#include <openssl/rsa.h> 180#include <openssl/rsa.h>
174#include "./testrsa.h" 181#include "./testrsa.h"
175#endif 182#endif
176#include <openssl/x509.h> 183#include <openssl/x509.h>
177#ifndef NO_DSA 184#ifndef OPENSSL_NO_DSA
178#include "./testdsa.h" 185#include "./testdsa.h"
179#endif 186#endif
180 187
181/* The following if from times(3) man page. It may need to be changed */ 188/* The following if from times(3) man page. It may need to be changed */
182#ifndef HZ 189#ifndef HZ
183# ifndef CLK_TCK 190# ifdef _SC_CLK_TCK
184# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ 191# define HZ ((double)sysconf(_SC_CLK_TCK))
185# define HZ 100.0 192# else
186# else /* _BSD_CLK_TCK_ */ 193# ifndef CLK_TCK
187# define HZ ((double)_BSD_CLK_TCK_) 194# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
195# define HZ 100.0
196# else /* _BSD_CLK_TCK_ */
197# define HZ ((double)_BSD_CLK_TCK_)
198# endif
199# else /* CLK_TCK */
200# define HZ ((double)CLK_TCK)
188# endif 201# endif
189# else /* CLK_TCK */
190# define HZ ((double)CLK_TCK)
191# endif 202# endif
192#endif 203#endif
193 204
205#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2)
206# define HAVE_FORK 1
207#endif
208
194#undef BUFSIZE 209#undef BUFSIZE
195#define BUFSIZE ((long)1024*8+1) 210#define BUFSIZE ((long)1024*8+1)
196int run=0; 211int run=0;
197 212
198static double Time_F(int s, int usertime); 213static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
199static void print_message(char *s,long num,int length); 214static int mr=0;
215static int usertime=1;
216
217static double Time_F(int s);
218static void print_message(const char *s,long num,int length);
200static void pkey_print_message(char *str,char *str2,long num,int bits,int sec); 219static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
220static void print_result(int alg,int run_no,int count,double time_used);
221#ifdef HAVE_FORK
222static int do_multi(int multi);
223#endif
224
225#define ALGOR_NUM 19
226#define SIZE_NUM 5
227#define RSA_NUM 4
228#define DSA_NUM 3
229static const char *names[ALGOR_NUM]={
230 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
231 "des cbc","des ede3","idea cbc",
232 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
233 "aes-128 cbc","aes-192 cbc","aes-256 cbc"};
234static double results[ALGOR_NUM][SIZE_NUM];
235static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
236static double rsa_results[RSA_NUM][2];
237static double dsa_results[DSA_NUM][2];
238
201#ifdef SIGALRM 239#ifdef SIGALRM
202#if defined(__STDC__) || defined(sgi) || defined(_AIX) 240#if defined(__STDC__) || defined(sgi) || defined(_AIX)
203#define SIGRETTYPE void 241#define SIGRETTYPE void
@@ -219,7 +257,7 @@ static SIGRETTYPE sig_done(int sig)
219#define START 0 257#define START 0
220#define STOP 1 258#define STOP 1
221 259
222static double Time_F(int s, int usertime) 260static double Time_F(int s)
223 { 261 {
224 double ret; 262 double ret;
225 263
@@ -228,6 +266,7 @@ static double Time_F(int s, int usertime)
228 { 266 {
229 static struct rusage tstart,tend; 267 static struct rusage tstart,tend;
230 268
269 getrusage_used = 1;
231 if (s == START) 270 if (s == START)
232 { 271 {
233 getrusage(RUSAGE_SELF,&tstart); 272 getrusage(RUSAGE_SELF,&tstart);
@@ -249,6 +288,7 @@ static double Time_F(int s, int usertime)
249 static struct timeval tstart,tend; 288 static struct timeval tstart,tend;
250 long i; 289 long i;
251 290
291 gettimeofday_used = 1;
252 if (s == START) 292 if (s == START)
253 { 293 {
254 gettimeofday(&tstart,NULL); 294 gettimeofday(&tstart,NULL);
@@ -269,6 +309,7 @@ static double Time_F(int s, int usertime)
269 { 309 {
270 static struct tms tstart,tend; 310 static struct tms tstart,tend;
271 311
312 times_used = 1;
272 if (s == START) 313 if (s == START)
273 { 314 {
274 times(&tstart); 315 times(&tstart);
@@ -285,11 +326,28 @@ static double Time_F(int s, int usertime)
285# if defined(TIMES) && defined(TIMEB) 326# if defined(TIMES) && defined(TIMEB)
286 else 327 else
287# endif 328# endif
288# ifdef TIMEB 329# ifdef OPENSSL_SYS_VXWORKS
330 {
331 static unsigned long tick_start, tick_end;
332
333 if( s == START )
334 {
335 tick_start = tickGet();
336 return 0;
337 }
338 else
339 {
340 tick_end = tickGet();
341 ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
342 return((ret < 0.001)?0.001:ret);
343 }
344 }
345# elif defined(TIMEB)
289 { 346 {
290 static struct timeb tstart,tend; 347 static struct timeb tstart,tend;
291 long i; 348 long i;
292 349
350 ftime_used = 1;
293 if (s == START) 351 if (s == START)
294 { 352 {
295 ftime(&tstart); 353 ftime(&tstart);
@@ -311,63 +369,82 @@ int MAIN(int, char **);
311 369
312int MAIN(int argc, char **argv) 370int MAIN(int argc, char **argv)
313 { 371 {
314 ENGINE *e; 372 ENGINE *e = NULL;
315 unsigned char *buf=NULL,*buf2=NULL; 373 unsigned char *buf=NULL,*buf2=NULL;
316 int mret=1; 374 int mret=1;
317#define ALGOR_NUM 15 375 long count=0,save_count=0, rsa_count;
318#define SIZE_NUM 5
319#define RSA_NUM 4
320#define DSA_NUM 3
321 long count,rsa_count;
322 int i,j,k; 376 int i,j,k;
377#ifndef OPENSSL_NO_RSA
323 unsigned rsa_num; 378 unsigned rsa_num;
324#ifndef NO_MD2 379#endif
380 unsigned char md[EVP_MAX_MD_SIZE];
381#ifndef OPENSSL_NO_MD2
325 unsigned char md2[MD2_DIGEST_LENGTH]; 382 unsigned char md2[MD2_DIGEST_LENGTH];
326#endif 383#endif
327#ifndef NO_MDC2 384#ifndef OPENSSL_NO_MDC2
328 unsigned char mdc2[MDC2_DIGEST_LENGTH]; 385 unsigned char mdc2[MDC2_DIGEST_LENGTH];
329#endif 386#endif
330#ifndef NO_MD4 387#ifndef OPENSSL_NO_MD4
331 unsigned char md4[MD4_DIGEST_LENGTH]; 388 unsigned char md4[MD4_DIGEST_LENGTH];
332#endif 389#endif
333#ifndef NO_MD5 390#ifndef OPENSSL_NO_MD5
334 unsigned char md5[MD5_DIGEST_LENGTH]; 391 unsigned char md5[MD5_DIGEST_LENGTH];
335 unsigned char hmac[MD5_DIGEST_LENGTH]; 392 unsigned char hmac[MD5_DIGEST_LENGTH];
336#endif 393#endif
337#ifndef NO_SHA 394#ifndef OPENSSL_NO_SHA
338 unsigned char sha[SHA_DIGEST_LENGTH]; 395 unsigned char sha[SHA_DIGEST_LENGTH];
339#endif 396#endif
340#ifndef NO_RIPEMD 397#ifndef OPENSSL_NO_RIPEMD
341 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH]; 398 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
342#endif 399#endif
343#ifndef NO_RC4 400#ifndef OPENSSL_NO_RC4
344 RC4_KEY rc4_ks; 401 RC4_KEY rc4_ks;
345#endif 402#endif
346#ifndef NO_RC5 403#ifndef OPENSSL_NO_RC5
347 RC5_32_KEY rc5_ks; 404 RC5_32_KEY rc5_ks;
348#endif 405#endif
349#ifndef NO_RC2 406#ifndef OPENSSL_NO_RC2
350 RC2_KEY rc2_ks; 407 RC2_KEY rc2_ks;
351#endif 408#endif
352#ifndef NO_IDEA 409#ifndef OPENSSL_NO_IDEA
353 IDEA_KEY_SCHEDULE idea_ks; 410 IDEA_KEY_SCHEDULE idea_ks;
354#endif 411#endif
355#ifndef NO_BF 412#ifndef OPENSSL_NO_BF
356 BF_KEY bf_ks; 413 BF_KEY bf_ks;
357#endif 414#endif
358#ifndef NO_CAST 415#ifndef OPENSSL_NO_CAST
359 CAST_KEY cast_ks; 416 CAST_KEY cast_ks;
360#endif 417#endif
361 static unsigned char key16[16]= 418 static const unsigned char key16[16]=
362 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0, 419 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
363 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; 420 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
364 unsigned char iv[8]; 421 static const unsigned char key24[24]=
365#ifndef NO_DES 422 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
366 des_cblock *buf_as_des_cblock = NULL; 423 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
367 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; 424 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
368 static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; 425 static const unsigned char key32[32]=
369 static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; 426 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
370 des_key_schedule sch,sch2,sch3; 427 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
428 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
429 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
430#ifndef OPENSSL_NO_AES
431#define MAX_BLOCK_SIZE 128
432#else
433#define MAX_BLOCK_SIZE 64
434#endif
435 unsigned char DES_iv[8];
436 unsigned char iv[MAX_BLOCK_SIZE/8];
437#ifndef OPENSSL_NO_DES
438 DES_cblock *buf_as_des_cblock = NULL;
439 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
440 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
441 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
442 DES_key_schedule sch;
443 DES_key_schedule sch2;
444 DES_key_schedule sch3;
445#endif
446#ifndef OPENSSL_NO_AES
447 AES_KEY aes_ks1, aes_ks2, aes_ks3;
371#endif 448#endif
372#define D_MD2 0 449#define D_MD2 0
373#define D_MDC2 1 450#define D_MDC2 1
@@ -384,13 +461,12 @@ int MAIN(int argc, char **argv)
384#define D_CBC_RC5 12 461#define D_CBC_RC5 12
385#define D_CBC_BF 13 462#define D_CBC_BF 13
386#define D_CBC_CAST 14 463#define D_CBC_CAST 14
387 double d,results[ALGOR_NUM][SIZE_NUM]; 464#define D_CBC_128_AES 15
388 static int lengths[SIZE_NUM]={8,64,256,1024,8*1024}; 465#define D_CBC_192_AES 16
466#define D_CBC_256_AES 17
467#define D_EVP 18
468 double d=0.0;
389 long c[ALGOR_NUM][SIZE_NUM]; 469 long c[ALGOR_NUM][SIZE_NUM];
390 static char *names[ALGOR_NUM]={
391 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
392 "des cbc","des ede3","idea cbc",
393 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"};
394#define R_DSA_512 0 470#define R_DSA_512 0
395#define R_DSA_1024 1 471#define R_DSA_1024 1
396#define R_DSA_2048 2 472#define R_DSA_2048 2
@@ -398,10 +474,9 @@ int MAIN(int argc, char **argv)
398#define R_RSA_1024 1 474#define R_RSA_1024 1
399#define R_RSA_2048 2 475#define R_RSA_2048 2
400#define R_RSA_4096 3 476#define R_RSA_4096 3
401#ifndef NO_RSA 477#ifndef OPENSSL_NO_RSA
402 RSA *rsa_key[RSA_NUM]; 478 RSA *rsa_key[RSA_NUM];
403 long rsa_c[RSA_NUM][2]; 479 long rsa_c[RSA_NUM][2];
404 double rsa_results[RSA_NUM][2];
405 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096}; 480 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
406 static unsigned char *rsa_data[RSA_NUM]= 481 static unsigned char *rsa_data[RSA_NUM]=
407 {test512,test1024,test2048,test4096}; 482 {test512,test1024,test2048,test4096};
@@ -409,17 +484,21 @@ int MAIN(int argc, char **argv)
409 sizeof(test512),sizeof(test1024), 484 sizeof(test512),sizeof(test1024),
410 sizeof(test2048),sizeof(test4096)}; 485 sizeof(test2048),sizeof(test4096)};
411#endif 486#endif
412#ifndef NO_DSA 487#ifndef OPENSSL_NO_DSA
413 DSA *dsa_key[DSA_NUM]; 488 DSA *dsa_key[DSA_NUM];
414 long dsa_c[DSA_NUM][2]; 489 long dsa_c[DSA_NUM][2];
415 double dsa_results[DSA_NUM][2];
416 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048}; 490 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
417#endif 491#endif
418 int rsa_doit[RSA_NUM]; 492 int rsa_doit[RSA_NUM];
419 int dsa_doit[DSA_NUM]; 493 int dsa_doit[DSA_NUM];
420 int doit[ALGOR_NUM]; 494 int doit[ALGOR_NUM];
421 int pr_header=0; 495 int pr_header=0;
422 int usertime=1; 496 const EVP_CIPHER *evp_cipher=NULL;
497 const EVP_MD *evp_md=NULL;
498 int decrypt=0;
499#ifdef HAVE_FORK
500 int multi=0;
501#endif
423 502
424#ifndef TIMES 503#ifndef TIMES
425 usertime=-1; 504 usertime=-1;
@@ -427,7 +506,7 @@ int MAIN(int argc, char **argv)
427 506
428 apps_startup(); 507 apps_startup();
429 memset(results, 0, sizeof(results)); 508 memset(results, 0, sizeof(results));
430#ifndef NO_DSA 509#ifndef OPENSSL_NO_DSA
431 memset(dsa_key,0,sizeof(dsa_key)); 510 memset(dsa_key,0,sizeof(dsa_key));
432#endif 511#endif
433 512
@@ -435,7 +514,10 @@ int MAIN(int argc, char **argv)
435 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 514 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
436 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 515 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
437 516
438#ifndef NO_RSA 517 if (!load_config(bio_err, NULL))
518 goto end;
519
520#ifndef OPENSSL_NO_RSA
439 memset(rsa_key,0,sizeof(rsa_key)); 521 memset(rsa_key,0,sizeof(rsa_key));
440 for (i=0; i<RSA_NUM; i++) 522 for (i=0; i<RSA_NUM; i++)
441 rsa_key[i]=NULL; 523 rsa_key[i]=NULL;
@@ -446,8 +528,8 @@ int MAIN(int argc, char **argv)
446 BIO_printf(bio_err,"out of memory\n"); 528 BIO_printf(bio_err,"out of memory\n");
447 goto end; 529 goto end;
448 } 530 }
449#ifndef NO_DES 531#ifndef OPENSSL_NO_DES
450 buf_as_des_cblock = (des_cblock *)buf; 532 buf_as_des_cblock = (DES_cblock *)buf;
451#endif 533#endif
452 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL) 534 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
453 { 535 {
@@ -456,6 +538,7 @@ int MAIN(int argc, char **argv)
456 } 538 }
457 539
458 memset(c,0,sizeof(c)); 540 memset(c,0,sizeof(c));
541 memset(DES_iv,0,sizeof(DES_iv));
459 memset(iv,0,sizeof(iv)); 542 memset(iv,0,sizeof(iv));
460 543
461 for (i=0; i<ALGOR_NUM; i++) 544 for (i=0; i<ALGOR_NUM; i++)
@@ -471,65 +554,108 @@ int MAIN(int argc, char **argv)
471 while (argc) 554 while (argc)
472 { 555 {
473 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0)) 556 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
557 {
474 usertime = 0; 558 usertime = 0;
475 else 559 j--; /* Otherwise, -elapsed gets confused with
476 if ((argc > 0) && (strcmp(*argv,"-engine") == 0)) 560 an algorithm. */
561 }
562 else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
477 { 563 {
478 argc--; 564 argc--;
479 argv++; 565 argv++;
480 if(argc == 0) 566 if(argc == 0)
481 { 567 {
482 BIO_printf(bio_err,"no engine given\n"); 568 BIO_printf(bio_err,"no EVP given\n");
483 goto end; 569 goto end;
484 } 570 }
485 if((e = ENGINE_by_id(*argv)) == NULL) 571 evp_cipher=EVP_get_cipherbyname(*argv);
572 if(!evp_cipher)
486 { 573 {
487 BIO_printf(bio_err,"invalid engine \"%s\"\n", 574 evp_md=EVP_get_digestbyname(*argv);
488 *argv); 575 }
576 if(!evp_cipher && !evp_md)
577 {
578 BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
489 goto end; 579 goto end;
490 } 580 }
491 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) 581 doit[D_EVP]=1;
582 }
583 else if (argc > 0 && !strcmp(*argv,"-decrypt"))
584 {
585 decrypt=1;
586 j--; /* Otherwise, -elapsed gets confused with
587 an algorithm. */
588 }
589 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
590 {
591 argc--;
592 argv++;
593 if(argc == 0)
492 { 594 {
493 BIO_printf(bio_err,"can't use that engine\n"); 595 BIO_printf(bio_err,"no engine given\n");
494 goto end; 596 goto end;
495 } 597 }
496 BIO_printf(bio_err,"engine \"%s\" set.\n", *argv); 598 e = setup_engine(bio_err, *argv, 0);
497 /* Free our "structural" reference. */ 599 /* j will be increased again further down. We just
498 ENGINE_free(e);
499 /* It will be increased again further down. We just
500 don't want speed to confuse an engine with an 600 don't want speed to confuse an engine with an
501 algorithm, especially when none is given (which 601 algorithm, especially when none is given (which
502 means all of them should be run) */ 602 means all of them should be run) */
503 j--; 603 j--;
504 } 604 }
605#ifdef HAVE_FORK
606 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
607 {
608 argc--;
609 argv++;
610 if(argc == 0)
611 {
612 BIO_printf(bio_err,"no multi count given\n");
613 goto end;
614 }
615 multi=atoi(argv[0]);
616 if(multi <= 0)
617 {
618 BIO_printf(bio_err,"bad multi count\n");
619 goto end;
620 }
621 j--; /* Otherwise, -mr gets confused with
622 an algorithm. */
623 }
624#endif
625 else if (argc > 0 && !strcmp(*argv,"-mr"))
626 {
627 mr=1;
628 j--; /* Otherwise, -mr gets confused with
629 an algorithm. */
630 }
505 else 631 else
506#ifndef NO_MD2 632#ifndef OPENSSL_NO_MD2
507 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1; 633 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
508 else 634 else
509#endif 635#endif
510#ifndef NO_MDC2 636#ifndef OPENSSL_NO_MDC2
511 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1; 637 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
512 else 638 else
513#endif 639#endif
514#ifndef NO_MD4 640#ifndef OPENSSL_NO_MD4
515 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1; 641 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
516 else 642 else
517#endif 643#endif
518#ifndef NO_MD5 644#ifndef OPENSSL_NO_MD5
519 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1; 645 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
520 else 646 else
521#endif 647#endif
522#ifndef NO_MD5 648#ifndef OPENSSL_NO_MD5
523 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1; 649 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
524 else 650 else
525#endif 651#endif
526#ifndef NO_SHA 652#ifndef OPENSSL_NO_SHA
527 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1; 653 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
528 else 654 else
529 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1; 655 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1;
530 else 656 else
531#endif 657#endif
532#ifndef NO_RIPEMD 658#ifndef OPENSSL_NO_RIPEMD
533 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1; 659 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
534 else 660 else
535 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1; 661 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
@@ -537,17 +663,23 @@ int MAIN(int argc, char **argv)
537 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1; 663 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
538 else 664 else
539#endif 665#endif
540#ifndef NO_RC4 666#ifndef OPENSSL_NO_RC4
541 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1; 667 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
542 else 668 else
543#endif 669#endif
544#ifndef NO_DES 670#ifndef OPENSSL_NO_DES
545 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1; 671 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
546 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1; 672 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
547 else 673 else
548#endif 674#endif
549#ifndef NO_RSA 675#ifndef OPENSSL_NO_AES
550#ifdef RSAref 676 if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
677 else if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
678 else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
679 else
680#endif
681#ifndef OPENSSL_NO_RSA
682#if 0 /* was: #ifdef RSAref */
551 if (strcmp(*argv,"rsaref") == 0) 683 if (strcmp(*argv,"rsaref") == 0)
552 { 684 {
553 RSA_set_default_openssl_method(RSA_PKCS1_RSAref()); 685 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
@@ -558,12 +690,12 @@ int MAIN(int argc, char **argv)
558#ifndef RSA_NULL 690#ifndef RSA_NULL
559 if (strcmp(*argv,"openssl") == 0) 691 if (strcmp(*argv,"openssl") == 0)
560 { 692 {
561 RSA_set_default_openssl_method(RSA_PKCS1_SSLeay()); 693 RSA_set_default_method(RSA_PKCS1_SSLeay());
562 j--; 694 j--;
563 } 695 }
564 else 696 else
565#endif 697#endif
566#endif /* !NO_RSA */ 698#endif /* !OPENSSL_NO_RSA */
567 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2; 699 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
568 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2; 700 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
569 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2; 701 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
@@ -572,34 +704,34 @@ int MAIN(int argc, char **argv)
572 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2; 704 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
573 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2; 705 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
574 else 706 else
575#ifndef NO_RC2 707#ifndef OPENSSL_NO_RC2
576 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1; 708 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
577 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1; 709 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
578 else 710 else
579#endif 711#endif
580#ifndef NO_RC5 712#ifndef OPENSSL_NO_RC5
581 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1; 713 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
582 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1; 714 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
583 else 715 else
584#endif 716#endif
585#ifndef NO_IDEA 717#ifndef OPENSSL_NO_IDEA
586 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1; 718 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
587 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1; 719 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
588 else 720 else
589#endif 721#endif
590#ifndef NO_BF 722#ifndef OPENSSL_NO_BF
591 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1; 723 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
592 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1; 724 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
593 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1; 725 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
594 else 726 else
595#endif 727#endif
596#ifndef NO_CAST 728#ifndef OPENSSL_NO_CAST
597 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1; 729 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
598 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1; 730 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
599 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1; 731 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
600 else 732 else
601#endif 733#endif
602#ifndef NO_DES 734#ifndef OPENSSL_NO_DES
603 if (strcmp(*argv,"des") == 0) 735 if (strcmp(*argv,"des") == 0)
604 { 736 {
605 doit[D_CBC_DES]=1; 737 doit[D_CBC_DES]=1;
@@ -607,7 +739,16 @@ int MAIN(int argc, char **argv)
607 } 739 }
608 else 740 else
609#endif 741#endif
610#ifndef NO_RSA 742#ifndef OPENSSL_NO_AES
743 if (strcmp(*argv,"aes") == 0)
744 {
745 doit[D_CBC_128_AES]=1;
746 doit[D_CBC_192_AES]=1;
747 doit[D_CBC_256_AES]=1;
748 }
749 else
750#endif
751#ifndef OPENSSL_NO_RSA
611 if (strcmp(*argv,"rsa") == 0) 752 if (strcmp(*argv,"rsa") == 0)
612 { 753 {
613 rsa_doit[R_RSA_512]=1; 754 rsa_doit[R_RSA_512]=1;
@@ -617,7 +758,7 @@ int MAIN(int argc, char **argv)
617 } 758 }
618 else 759 else
619#endif 760#endif
620#ifndef NO_DSA 761#ifndef OPENSSL_NO_DSA
621 if (strcmp(*argv,"dsa") == 0) 762 if (strcmp(*argv,"dsa") == 0)
622 { 763 {
623 dsa_doit[R_DSA_512]=1; 764 dsa_doit[R_DSA_512]=1;
@@ -629,77 +770,89 @@ int MAIN(int argc, char **argv)
629 BIO_printf(bio_err,"Error: bad option or value\n"); 770 BIO_printf(bio_err,"Error: bad option or value\n");
630 BIO_printf(bio_err,"\n"); 771 BIO_printf(bio_err,"\n");
631 BIO_printf(bio_err,"Available values:\n"); 772 BIO_printf(bio_err,"Available values:\n");
632#ifndef NO_MD2 773#ifndef OPENSSL_NO_MD2
633 BIO_printf(bio_err,"md2 "); 774 BIO_printf(bio_err,"md2 ");
634#endif 775#endif
635#ifndef NO_MDC2 776#ifndef OPENSSL_NO_MDC2
636 BIO_printf(bio_err,"mdc2 "); 777 BIO_printf(bio_err,"mdc2 ");
637#endif 778#endif
638#ifndef NO_MD4 779#ifndef OPENSSL_NO_MD4
639 BIO_printf(bio_err,"md4 "); 780 BIO_printf(bio_err,"md4 ");
640#endif 781#endif
641#ifndef NO_MD5 782#ifndef OPENSSL_NO_MD5
642 BIO_printf(bio_err,"md5 "); 783 BIO_printf(bio_err,"md5 ");
643#ifndef NO_HMAC 784#ifndef OPENSSL_NO_HMAC
644 BIO_printf(bio_err,"hmac "); 785 BIO_printf(bio_err,"hmac ");
645#endif 786#endif
646#endif 787#endif
647#ifndef NO_SHA1 788#ifndef OPENSSL_NO_SHA1
648 BIO_printf(bio_err,"sha1 "); 789 BIO_printf(bio_err,"sha1 ");
649#endif 790#endif
650#ifndef NO_RIPEMD160 791#ifndef OPENSSL_NO_RIPEMD160
651 BIO_printf(bio_err,"rmd160"); 792 BIO_printf(bio_err,"rmd160");
652#endif 793#endif
653#if !defined(NO_MD2) || !defined(NO_MDC2) || !defined(NO_MD4) || !defined(NO_MD5) || !defined(NO_SHA1) || !defined(NO_RIPEMD160) 794#if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
795 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
796 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
654 BIO_printf(bio_err,"\n"); 797 BIO_printf(bio_err,"\n");
655#endif 798#endif
656 799
657#ifndef NO_IDEA 800#ifndef OPENSSL_NO_IDEA
658 BIO_printf(bio_err,"idea-cbc "); 801 BIO_printf(bio_err,"idea-cbc ");
659#endif 802#endif
660#ifndef NO_RC2 803#ifndef OPENSSL_NO_RC2
661 BIO_printf(bio_err,"rc2-cbc "); 804 BIO_printf(bio_err,"rc2-cbc ");
662#endif 805#endif
663#ifndef NO_RC5 806#ifndef OPENSSL_NO_RC5
664 BIO_printf(bio_err,"rc5-cbc "); 807 BIO_printf(bio_err,"rc5-cbc ");
665#endif 808#endif
666#ifndef NO_BF 809#ifndef OPENSSL_NO_BF
667 BIO_printf(bio_err,"bf-cbc"); 810 BIO_printf(bio_err,"bf-cbc");
668#endif 811#endif
669#if !defined(NO_IDEA) || !defined(NO_RC2) || !defined(NO_BF) || !defined(NO_RC5) 812#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
813 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
670 BIO_printf(bio_err,"\n"); 814 BIO_printf(bio_err,"\n");
671#endif 815#endif
672 816#ifndef OPENSSL_NO_DES
673 BIO_printf(bio_err,"des-cbc des-ede3 "); 817 BIO_printf(bio_err,"des-cbc des-ede3 ");
674#ifndef NO_RC4 818#endif
819#ifndef OPENSSL_NO_AES
820 BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
821#endif
822#ifndef OPENSSL_NO_RC4
675 BIO_printf(bio_err,"rc4"); 823 BIO_printf(bio_err,"rc4");
676#endif 824#endif
677 BIO_printf(bio_err,"\n"); 825 BIO_printf(bio_err,"\n");
678 826
679#ifndef NO_RSA 827#ifndef OPENSSL_NO_RSA
680 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n"); 828 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
681#endif 829#endif
682 830
683#ifndef NO_DSA 831#ifndef OPENSSL_NO_DSA
684 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n"); 832 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
685#endif 833#endif
686 834
687#ifndef NO_IDEA 835#ifndef OPENSSL_NO_IDEA
688 BIO_printf(bio_err,"idea "); 836 BIO_printf(bio_err,"idea ");
689#endif 837#endif
690#ifndef NO_RC2 838#ifndef OPENSSL_NO_RC2
691 BIO_printf(bio_err,"rc2 "); 839 BIO_printf(bio_err,"rc2 ");
692#endif 840#endif
693#ifndef NO_DES 841#ifndef OPENSSL_NO_DES
694 BIO_printf(bio_err,"des "); 842 BIO_printf(bio_err,"des ");
695#endif 843#endif
696#ifndef NO_RSA 844#ifndef OPENSSL_NO_AES
845 BIO_printf(bio_err,"aes ");
846#endif
847#ifndef OPENSSL_NO_RSA
697 BIO_printf(bio_err,"rsa "); 848 BIO_printf(bio_err,"rsa ");
698#endif 849#endif
699#ifndef NO_BF 850#ifndef OPENSSL_NO_BF
700 BIO_printf(bio_err,"blowfish"); 851 BIO_printf(bio_err,"blowfish");
701#endif 852#endif
702#if !defined(NO_IDEA) || !defined(NO_RC2) || !defined(NO_DES) || !defined(NO_RSA) || !defined(NO_BF) 853#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
854 !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
855 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
703 BIO_printf(bio_err,"\n"); 856 BIO_printf(bio_err,"\n");
704#endif 857#endif
705 858
@@ -709,6 +862,12 @@ int MAIN(int argc, char **argv)
709 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n"); 862 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
710#endif 863#endif
711 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); 864 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
865 BIO_printf(bio_err,"-evp e use EVP e.\n");
866 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
867 BIO_printf(bio_err,"-mr produce machine readable output.\n");
868#ifdef HAVE_FORK
869 BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
870#endif
712 goto end; 871 goto end;
713 } 872 }
714 argc--; 873 argc--;
@@ -716,10 +875,18 @@ int MAIN(int argc, char **argv)
716 j++; 875 j++;
717 } 876 }
718 877
878#ifdef HAVE_FORK
879 if(multi && do_multi(multi))
880 goto show_res;
881#endif
882
719 if (j == 0) 883 if (j == 0)
720 { 884 {
721 for (i=0; i<ALGOR_NUM; i++) 885 for (i=0; i<ALGOR_NUM; i++)
722 doit[i]=1; 886 {
887 if (i != D_EVP)
888 doit[i]=1;
889 }
723 for (i=0; i<RSA_NUM; i++) 890 for (i=0; i<RSA_NUM; i++)
724 rsa_doit[i]=1; 891 rsa_doit[i]=1;
725 for (i=0; i<DSA_NUM; i++) 892 for (i=0; i<DSA_NUM; i++)
@@ -728,18 +895,18 @@ int MAIN(int argc, char **argv)
728 for (i=0; i<ALGOR_NUM; i++) 895 for (i=0; i<ALGOR_NUM; i++)
729 if (doit[i]) pr_header++; 896 if (doit[i]) pr_header++;
730 897
731 if (usertime == 0) 898 if (usertime == 0 && !mr)
732 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n"); 899 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
733 if (usertime <= 0) 900 if (usertime <= 0 && !mr)
734 { 901 {
735 BIO_printf(bio_err,"To get the most accurate results, try to run this\n"); 902 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
736 BIO_printf(bio_err,"program when this computer is idle.\n"); 903 BIO_printf(bio_err,"program when this computer is idle.\n");
737 } 904 }
738 905
739#ifndef NO_RSA 906#ifndef OPENSSL_NO_RSA
740 for (i=0; i<RSA_NUM; i++) 907 for (i=0; i<RSA_NUM; i++)
741 { 908 {
742 unsigned char *p; 909 const unsigned char *p;
743 910
744 p=rsa_data[i]; 911 p=rsa_data[i];
745 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]); 912 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
@@ -751,7 +918,9 @@ int MAIN(int argc, char **argv)
751#if 0 918#if 0
752 else 919 else
753 { 920 {
754 BIO_printf(bio_err,"Loaded RSA key, %d bit modulus and e= 0x",BN_num_bits(rsa_key[i]->n)); 921 BIO_printf(bio_err,mr ? "+RK:%d:"
922 : "Loaded RSA key, %d bit modulus and e= 0x",
923 BN_num_bits(rsa_key[i]->n));
755 BN_print(bio_err,rsa_key[i]->e); 924 BN_print(bio_err,rsa_key[i]->e);
756 BIO_printf(bio_err,"\n"); 925 BIO_printf(bio_err,"\n");
757 } 926 }
@@ -759,51 +928,57 @@ int MAIN(int argc, char **argv)
759 } 928 }
760#endif 929#endif
761 930
762#ifndef NO_DSA 931#ifndef OPENSSL_NO_DSA
763 dsa_key[0]=get_dsa512(); 932 dsa_key[0]=get_dsa512();
764 dsa_key[1]=get_dsa1024(); 933 dsa_key[1]=get_dsa1024();
765 dsa_key[2]=get_dsa2048(); 934 dsa_key[2]=get_dsa2048();
766#endif 935#endif
767 936
768#ifndef NO_DES 937#ifndef OPENSSL_NO_DES
769 des_set_key_unchecked(&key,sch); 938 DES_set_key_unchecked(&key,&sch);
770 des_set_key_unchecked(&key2,sch2); 939 DES_set_key_unchecked(&key2,&sch2);
771 des_set_key_unchecked(&key3,sch3); 940 DES_set_key_unchecked(&key3,&sch3);
772#endif 941#endif
773#ifndef NO_IDEA 942#ifndef OPENSSL_NO_AES
943 AES_set_encrypt_key(key16,128,&aes_ks1);
944 AES_set_encrypt_key(key24,192,&aes_ks2);
945 AES_set_encrypt_key(key32,256,&aes_ks3);
946#endif
947#ifndef OPENSSL_NO_IDEA
774 idea_set_encrypt_key(key16,&idea_ks); 948 idea_set_encrypt_key(key16,&idea_ks);
775#endif 949#endif
776#ifndef NO_RC4 950#ifndef OPENSSL_NO_RC4
777 RC4_set_key(&rc4_ks,16,key16); 951 RC4_set_key(&rc4_ks,16,key16);
778#endif 952#endif
779#ifndef NO_RC2 953#ifndef OPENSSL_NO_RC2
780 RC2_set_key(&rc2_ks,16,key16,128); 954 RC2_set_key(&rc2_ks,16,key16,128);
781#endif 955#endif
782#ifndef NO_RC5 956#ifndef OPENSSL_NO_RC5
783 RC5_32_set_key(&rc5_ks,16,key16,12); 957 RC5_32_set_key(&rc5_ks,16,key16,12);
784#endif 958#endif
785#ifndef NO_BF 959#ifndef OPENSSL_NO_BF
786 BF_set_key(&bf_ks,16,key16); 960 BF_set_key(&bf_ks,16,key16);
787#endif 961#endif
788#ifndef NO_CAST 962#ifndef OPENSSL_NO_CAST
789 CAST_set_key(&cast_ks,16,key16); 963 CAST_set_key(&cast_ks,16,key16);
790#endif 964#endif
791#ifndef NO_RSA 965#ifndef OPENSSL_NO_RSA
792 memset(rsa_c,0,sizeof(rsa_c)); 966 memset(rsa_c,0,sizeof(rsa_c));
793#endif 967#endif
794#ifndef SIGALRM 968#ifndef SIGALRM
795#ifndef NO_DES 969#ifndef OPENSSL_NO_DES
796 BIO_printf(bio_err,"First we calculate the approximate speed ...\n"); 970 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
797 count=10; 971 count=10;
798 do { 972 do {
799 long i; 973 long i;
800 count*=2; 974 count*=2;
801 Time_F(START,usertime); 975 Time_F(START);
802 for (i=count; i; i--) 976 for (i=count; i; i--)
803 des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock, 977 DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
804 &(sch[0]),DES_ENCRYPT); 978 &sch,DES_ENCRYPT);
805 d=Time_F(STOP,usertime); 979 d=Time_F(STOP);
806 } while (d <3); 980 } while (d <3);
981 save_count=count;
807 c[D_MD2][0]=count/10; 982 c[D_MD2][0]=count/10;
808 c[D_MDC2][0]=count/10; 983 c[D_MDC2][0]=count/10;
809 c[D_MD4][0]=count; 984 c[D_MD4][0]=count;
@@ -845,7 +1020,7 @@ int MAIN(int argc, char **argv)
845 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1; 1020 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
846 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1; 1021 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
847 } 1022 }
848#ifndef NO_RSA 1023#ifndef OPENSSL_NO_RSA
849 rsa_c[R_RSA_512][0]=count/2000; 1024 rsa_c[R_RSA_512][0]=count/2000;
850 rsa_c[R_RSA_512][1]=count/400; 1025 rsa_c[R_RSA_512][1]=count/400;
851 for (i=1; i<RSA_NUM; i++) 1026 for (i=1; i<RSA_NUM; i++)
@@ -865,7 +1040,7 @@ int MAIN(int argc, char **argv)
865 } 1040 }
866#endif 1041#endif
867 1042
868#ifndef NO_DSA 1043#ifndef OPENSSL_NO_DSA
869 dsa_c[R_DSA_512][0]=count/1000; 1044 dsa_c[R_DSA_512][0]=count/1000;
870 dsa_c[R_DSA_512][1]=count/1000/2; 1045 dsa_c[R_DSA_512][1]=count/1000/2;
871 for (i=1; i<DSA_NUM; i++) 1046 for (i=1; i<DSA_NUM; i++)
@@ -890,167 +1065,152 @@ int MAIN(int argc, char **argv)
890#else 1065#else
891/* not worth fixing */ 1066/* not worth fixing */
892# error "You cannot disable DES on systems without SIGALRM." 1067# error "You cannot disable DES on systems without SIGALRM."
893#endif /* NO_DES */ 1068#endif /* OPENSSL_NO_DES */
894#else 1069#else
895#define COND(c) (run) 1070#define COND(c) (run)
896#define COUNT(d) (count) 1071#define COUNT(d) (count)
897 signal(SIGALRM,sig_done); 1072 signal(SIGALRM,sig_done);
898#endif /* SIGALRM */ 1073#endif /* SIGALRM */
899 1074
900#ifndef NO_MD2 1075#ifndef OPENSSL_NO_MD2
901 if (doit[D_MD2]) 1076 if (doit[D_MD2])
902 { 1077 {
903 for (j=0; j<SIZE_NUM; j++) 1078 for (j=0; j<SIZE_NUM; j++)
904 { 1079 {
905 print_message(names[D_MD2],c[D_MD2][j],lengths[j]); 1080 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
906 Time_F(START,usertime); 1081 Time_F(START);
907 for (count=0,run=1; COND(c[D_MD2][j]); count++) 1082 for (count=0,run=1; COND(c[D_MD2][j]); count++)
908 MD2(buf,(unsigned long)lengths[j],&(md2[0])); 1083 EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
909 d=Time_F(STOP,usertime); 1084 d=Time_F(STOP);
910 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1085 print_result(D_MD2,j,count,d);
911 count,names[D_MD2],d);
912 results[D_MD2][j]=((double)count)/d*lengths[j];
913 } 1086 }
914 } 1087 }
915#endif 1088#endif
916#ifndef NO_MDC2 1089#ifndef OPENSSL_NO_MDC2
917 if (doit[D_MDC2]) 1090 if (doit[D_MDC2])
918 { 1091 {
919 for (j=0; j<SIZE_NUM; j++) 1092 for (j=0; j<SIZE_NUM; j++)
920 { 1093 {
921 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]); 1094 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
922 Time_F(START,usertime); 1095 Time_F(START);
923 for (count=0,run=1; COND(c[D_MDC2][j]); count++) 1096 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
924 MDC2(buf,(unsigned long)lengths[j],&(mdc2[0])); 1097 EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
925 d=Time_F(STOP,usertime); 1098 d=Time_F(STOP);
926 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1099 print_result(D_MDC2,j,count,d);
927 count,names[D_MDC2],d);
928 results[D_MDC2][j]=((double)count)/d*lengths[j];
929 } 1100 }
930 } 1101 }
931#endif 1102#endif
932 1103
933#ifndef NO_MD4 1104#ifndef OPENSSL_NO_MD4
934 if (doit[D_MD4]) 1105 if (doit[D_MD4])
935 { 1106 {
936 for (j=0; j<SIZE_NUM; j++) 1107 for (j=0; j<SIZE_NUM; j++)
937 { 1108 {
938 print_message(names[D_MD4],c[D_MD4][j],lengths[j]); 1109 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
939 Time_F(START,usertime); 1110 Time_F(START);
940 for (count=0,run=1; COND(c[D_MD4][j]); count++) 1111 for (count=0,run=1; COND(c[D_MD4][j]); count++)
941 MD4(&(buf[0]),(unsigned long)lengths[j],&(md4[0])); 1112 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
942 d=Time_F(STOP,usertime); 1113 d=Time_F(STOP);
943 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1114 print_result(D_MD4,j,count,d);
944 count,names[D_MD4],d);
945 results[D_MD4][j]=((double)count)/d*lengths[j];
946 } 1115 }
947 } 1116 }
948#endif 1117#endif
949 1118
950#ifndef NO_MD5 1119#ifndef OPENSSL_NO_MD5
951 if (doit[D_MD5]) 1120 if (doit[D_MD5])
952 { 1121 {
953 for (j=0; j<SIZE_NUM; j++) 1122 for (j=0; j<SIZE_NUM; j++)
954 { 1123 {
955 print_message(names[D_MD5],c[D_MD5][j],lengths[j]); 1124 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
956 Time_F(START,usertime); 1125 Time_F(START);
957 for (count=0,run=1; COND(c[D_MD5][j]); count++) 1126 for (count=0,run=1; COND(c[D_MD5][j]); count++)
958 MD5(&(buf[0]),(unsigned long)lengths[j],&(md5[0])); 1127 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
959 d=Time_F(STOP,usertime); 1128 d=Time_F(STOP);
960 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1129 print_result(D_MD5,j,count,d);
961 count,names[D_MD5],d);
962 results[D_MD5][j]=((double)count)/d*lengths[j];
963 } 1130 }
964 } 1131 }
965#endif 1132#endif
966 1133
967#if !defined(NO_MD5) && !defined(NO_HMAC) 1134#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
968 if (doit[D_HMAC]) 1135 if (doit[D_HMAC])
969 { 1136 {
970 HMAC_CTX hctx; 1137 HMAC_CTX hctx;
971 HMAC_Init(&hctx,(unsigned char *)"This is a key...", 1138
972 16,EVP_md5()); 1139 HMAC_CTX_init(&hctx);
1140 HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
1141 16,EVP_md5(), NULL);
973 1142
974 for (j=0; j<SIZE_NUM; j++) 1143 for (j=0; j<SIZE_NUM; j++)
975 { 1144 {
976 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]); 1145 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
977 Time_F(START,usertime); 1146 Time_F(START);
978 for (count=0,run=1; COND(c[D_HMAC][j]); count++) 1147 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
979 { 1148 {
980 HMAC_Init(&hctx,NULL,0,NULL); 1149 HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
981 HMAC_Update(&hctx,buf,lengths[j]); 1150 HMAC_Update(&hctx,buf,lengths[j]);
982 HMAC_Final(&hctx,&(hmac[0]),NULL); 1151 HMAC_Final(&hctx,&(hmac[0]),NULL);
983 } 1152 }
984 d=Time_F(STOP,usertime); 1153 d=Time_F(STOP);
985 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1154 print_result(D_HMAC,j,count,d);
986 count,names[D_HMAC],d);
987 results[D_HMAC][j]=((double)count)/d*lengths[j];
988 } 1155 }
1156 HMAC_CTX_cleanup(&hctx);
989 } 1157 }
990#endif 1158#endif
991#ifndef NO_SHA 1159#ifndef OPENSSL_NO_SHA
992 if (doit[D_SHA1]) 1160 if (doit[D_SHA1])
993 { 1161 {
994 for (j=0; j<SIZE_NUM; j++) 1162 for (j=0; j<SIZE_NUM; j++)
995 { 1163 {
996 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]); 1164 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
997 Time_F(START,usertime); 1165 Time_F(START);
998 for (count=0,run=1; COND(c[D_SHA1][j]); count++) 1166 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
999 SHA1(buf,(unsigned long)lengths[j],&(sha[0])); 1167 EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1000 d=Time_F(STOP,usertime); 1168 d=Time_F(STOP);
1001 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1169 print_result(D_SHA1,j,count,d);
1002 count,names[D_SHA1],d);
1003 results[D_SHA1][j]=((double)count)/d*lengths[j];
1004 } 1170 }
1005 } 1171 }
1006#endif 1172#endif
1007#ifndef NO_RIPEMD 1173#ifndef OPENSSL_NO_RIPEMD
1008 if (doit[D_RMD160]) 1174 if (doit[D_RMD160])
1009 { 1175 {
1010 for (j=0; j<SIZE_NUM; j++) 1176 for (j=0; j<SIZE_NUM; j++)
1011 { 1177 {
1012 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]); 1178 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1013 Time_F(START,usertime); 1179 Time_F(START);
1014 for (count=0,run=1; COND(c[D_RMD160][j]); count++) 1180 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1015 RIPEMD160(buf,(unsigned long)lengths[j],&(rmd160[0])); 1181 EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1016 d=Time_F(STOP,usertime); 1182 d=Time_F(STOP);
1017 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1183 print_result(D_RMD160,j,count,d);
1018 count,names[D_RMD160],d);
1019 results[D_RMD160][j]=((double)count)/d*lengths[j];
1020 } 1184 }
1021 } 1185 }
1022#endif 1186#endif
1023#ifndef NO_RC4 1187#ifndef OPENSSL_NO_RC4
1024 if (doit[D_RC4]) 1188 if (doit[D_RC4])
1025 { 1189 {
1026 for (j=0; j<SIZE_NUM; j++) 1190 for (j=0; j<SIZE_NUM; j++)
1027 { 1191 {
1028 print_message(names[D_RC4],c[D_RC4][j],lengths[j]); 1192 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1029 Time_F(START,usertime); 1193 Time_F(START);
1030 for (count=0,run=1; COND(c[D_RC4][j]); count++) 1194 for (count=0,run=1; COND(c[D_RC4][j]); count++)
1031 RC4(&rc4_ks,(unsigned int)lengths[j], 1195 RC4(&rc4_ks,(unsigned int)lengths[j],
1032 buf,buf); 1196 buf,buf);
1033 d=Time_F(STOP,usertime); 1197 d=Time_F(STOP);
1034 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1198 print_result(D_RC4,j,count,d);
1035 count,names[D_RC4],d);
1036 results[D_RC4][j]=((double)count)/d*lengths[j];
1037 } 1199 }
1038 } 1200 }
1039#endif 1201#endif
1040#ifndef NO_DES 1202#ifndef OPENSSL_NO_DES
1041 if (doit[D_CBC_DES]) 1203 if (doit[D_CBC_DES])
1042 { 1204 {
1043 for (j=0; j<SIZE_NUM; j++) 1205 for (j=0; j<SIZE_NUM; j++)
1044 { 1206 {
1045 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]); 1207 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1046 Time_F(START,usertime); 1208 Time_F(START);
1047 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++) 1209 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1048 des_ncbc_encrypt(buf,buf,lengths[j],sch, 1210 DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1049 &iv,DES_ENCRYPT); 1211 &DES_iv,DES_ENCRYPT);
1050 d=Time_F(STOP,usertime); 1212 d=Time_F(STOP);
1051 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1213 print_result(D_CBC_DES,j,count,d);
1052 count,names[D_CBC_DES],d);
1053 results[D_CBC_DES][j]=((double)count)/d*lengths[j];
1054 } 1214 }
1055 } 1215 }
1056 1216
@@ -1059,111 +1219,195 @@ int MAIN(int argc, char **argv)
1059 for (j=0; j<SIZE_NUM; j++) 1219 for (j=0; j<SIZE_NUM; j++)
1060 { 1220 {
1061 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]); 1221 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1062 Time_F(START,usertime); 1222 Time_F(START);
1063 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++) 1223 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1064 des_ede3_cbc_encrypt(buf,buf,lengths[j], 1224 DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1065 sch,sch2,sch3, 1225 &sch,&sch2,&sch3,
1066 &iv,DES_ENCRYPT); 1226 &DES_iv,DES_ENCRYPT);
1067 d=Time_F(STOP,usertime); 1227 d=Time_F(STOP);
1068 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1228 print_result(D_EDE3_DES,j,count,d);
1069 count,names[D_EDE3_DES],d);
1070 results[D_EDE3_DES][j]=((double)count)/d*lengths[j];
1071 } 1229 }
1072 } 1230 }
1073#endif 1231#endif
1074#ifndef NO_IDEA 1232#ifndef OPENSSL_NO_AES
1233 if (doit[D_CBC_128_AES])
1234 {
1235 for (j=0; j<SIZE_NUM; j++)
1236 {
1237 print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
1238 Time_F(START);
1239 for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
1240 AES_cbc_encrypt(buf,buf,
1241 (unsigned long)lengths[j],&aes_ks1,
1242 iv,AES_ENCRYPT);
1243 d=Time_F(STOP);
1244 print_result(D_CBC_128_AES,j,count,d);
1245 }
1246 }
1247 if (doit[D_CBC_192_AES])
1248 {
1249 for (j=0; j<SIZE_NUM; j++)
1250 {
1251 print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
1252 Time_F(START);
1253 for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
1254 AES_cbc_encrypt(buf,buf,
1255 (unsigned long)lengths[j],&aes_ks2,
1256 iv,AES_ENCRYPT);
1257 d=Time_F(STOP);
1258 print_result(D_CBC_192_AES,j,count,d);
1259 }
1260 }
1261 if (doit[D_CBC_256_AES])
1262 {
1263 for (j=0; j<SIZE_NUM; j++)
1264 {
1265 print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
1266 Time_F(START);
1267 for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
1268 AES_cbc_encrypt(buf,buf,
1269 (unsigned long)lengths[j],&aes_ks3,
1270 iv,AES_ENCRYPT);
1271 d=Time_F(STOP);
1272 print_result(D_CBC_256_AES,j,count,d);
1273 }
1274 }
1275
1276#endif
1277#ifndef OPENSSL_NO_IDEA
1075 if (doit[D_CBC_IDEA]) 1278 if (doit[D_CBC_IDEA])
1076 { 1279 {
1077 for (j=0; j<SIZE_NUM; j++) 1280 for (j=0; j<SIZE_NUM; j++)
1078 { 1281 {
1079 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]); 1282 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1080 Time_F(START,usertime); 1283 Time_F(START);
1081 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++) 1284 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1082 idea_cbc_encrypt(buf,buf, 1285 idea_cbc_encrypt(buf,buf,
1083 (unsigned long)lengths[j],&idea_ks, 1286 (unsigned long)lengths[j],&idea_ks,
1084 iv,IDEA_ENCRYPT); 1287 iv,IDEA_ENCRYPT);
1085 d=Time_F(STOP,usertime); 1288 d=Time_F(STOP);
1086 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1289 print_result(D_CBC_IDEA,j,count,d);
1087 count,names[D_CBC_IDEA],d);
1088 results[D_CBC_IDEA][j]=((double)count)/d*lengths[j];
1089 } 1290 }
1090 } 1291 }
1091#endif 1292#endif
1092#ifndef NO_RC2 1293#ifndef OPENSSL_NO_RC2
1093 if (doit[D_CBC_RC2]) 1294 if (doit[D_CBC_RC2])
1094 { 1295 {
1095 for (j=0; j<SIZE_NUM; j++) 1296 for (j=0; j<SIZE_NUM; j++)
1096 { 1297 {
1097 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]); 1298 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1098 Time_F(START,usertime); 1299 Time_F(START);
1099 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++) 1300 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1100 RC2_cbc_encrypt(buf,buf, 1301 RC2_cbc_encrypt(buf,buf,
1101 (unsigned long)lengths[j],&rc2_ks, 1302 (unsigned long)lengths[j],&rc2_ks,
1102 iv,RC2_ENCRYPT); 1303 iv,RC2_ENCRYPT);
1103 d=Time_F(STOP,usertime); 1304 d=Time_F(STOP);
1104 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1305 print_result(D_CBC_RC2,j,count,d);
1105 count,names[D_CBC_RC2],d);
1106 results[D_CBC_RC2][j]=((double)count)/d*lengths[j];
1107 } 1306 }
1108 } 1307 }
1109#endif 1308#endif
1110#ifndef NO_RC5 1309#ifndef OPENSSL_NO_RC5
1111 if (doit[D_CBC_RC5]) 1310 if (doit[D_CBC_RC5])
1112 { 1311 {
1113 for (j=0; j<SIZE_NUM; j++) 1312 for (j=0; j<SIZE_NUM; j++)
1114 { 1313 {
1115 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]); 1314 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1116 Time_F(START,usertime); 1315 Time_F(START);
1117 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++) 1316 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1118 RC5_32_cbc_encrypt(buf,buf, 1317 RC5_32_cbc_encrypt(buf,buf,
1119 (unsigned long)lengths[j],&rc5_ks, 1318 (unsigned long)lengths[j],&rc5_ks,
1120 iv,RC5_ENCRYPT); 1319 iv,RC5_ENCRYPT);
1121 d=Time_F(STOP,usertime); 1320 d=Time_F(STOP);
1122 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1321 print_result(D_CBC_RC5,j,count,d);
1123 count,names[D_CBC_RC5],d);
1124 results[D_CBC_RC5][j]=((double)count)/d*lengths[j];
1125 } 1322 }
1126 } 1323 }
1127#endif 1324#endif
1128#ifndef NO_BF 1325#ifndef OPENSSL_NO_BF
1129 if (doit[D_CBC_BF]) 1326 if (doit[D_CBC_BF])
1130 { 1327 {
1131 for (j=0; j<SIZE_NUM; j++) 1328 for (j=0; j<SIZE_NUM; j++)
1132 { 1329 {
1133 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]); 1330 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1134 Time_F(START,usertime); 1331 Time_F(START);
1135 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++) 1332 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1136 BF_cbc_encrypt(buf,buf, 1333 BF_cbc_encrypt(buf,buf,
1137 (unsigned long)lengths[j],&bf_ks, 1334 (unsigned long)lengths[j],&bf_ks,
1138 iv,BF_ENCRYPT); 1335 iv,BF_ENCRYPT);
1139 d=Time_F(STOP,usertime); 1336 d=Time_F(STOP);
1140 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1337 print_result(D_CBC_BF,j,count,d);
1141 count,names[D_CBC_BF],d);
1142 results[D_CBC_BF][j]=((double)count)/d*lengths[j];
1143 } 1338 }
1144 } 1339 }
1145#endif 1340#endif
1146#ifndef NO_CAST 1341#ifndef OPENSSL_NO_CAST
1147 if (doit[D_CBC_CAST]) 1342 if (doit[D_CBC_CAST])
1148 { 1343 {
1149 for (j=0; j<SIZE_NUM; j++) 1344 for (j=0; j<SIZE_NUM; j++)
1150 { 1345 {
1151 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]); 1346 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1152 Time_F(START,usertime); 1347 Time_F(START);
1153 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++) 1348 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1154 CAST_cbc_encrypt(buf,buf, 1349 CAST_cbc_encrypt(buf,buf,
1155 (unsigned long)lengths[j],&cast_ks, 1350 (unsigned long)lengths[j],&cast_ks,
1156 iv,CAST_ENCRYPT); 1351 iv,CAST_ENCRYPT);
1157 d=Time_F(STOP,usertime); 1352 d=Time_F(STOP);
1158 BIO_printf(bio_err,"%ld %s's in %.2fs\n", 1353 print_result(D_CBC_CAST,j,count,d);
1159 count,names[D_CBC_CAST],d);
1160 results[D_CBC_CAST][j]=((double)count)/d*lengths[j];
1161 } 1354 }
1162 } 1355 }
1163#endif 1356#endif
1164 1357
1358 if (doit[D_EVP])
1359 {
1360 for (j=0; j<SIZE_NUM; j++)
1361 {
1362 if (evp_cipher)
1363 {
1364 EVP_CIPHER_CTX ctx;
1365 int outl;
1366
1367 names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
1368 /* -O3 -fschedule-insns messes up an
1369 * optimization here! names[D_EVP]
1370 * somehow becomes NULL */
1371 print_message(names[D_EVP],save_count,
1372 lengths[j]);
1373
1374 EVP_CIPHER_CTX_init(&ctx);
1375 if(decrypt)
1376 EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1377 else
1378 EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1379
1380 Time_F(START);
1381 if(decrypt)
1382 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1383 EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1384 else
1385 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1386 EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1387 if(decrypt)
1388 EVP_DecryptFinal_ex(&ctx,buf,&outl);
1389 else
1390 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1391 d=Time_F(STOP);
1392 }
1393 if (evp_md)
1394 {
1395 names[D_EVP]=OBJ_nid2ln(evp_md->type);
1396 print_message(names[D_EVP],save_count,
1397 lengths[j]);
1398
1399 Time_F(START);
1400 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1401 EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
1402
1403 d=Time_F(STOP);
1404 }
1405 print_result(D_EVP,j,count,d);
1406 }
1407 }
1408
1165 RAND_pseudo_bytes(buf,36); 1409 RAND_pseudo_bytes(buf,36);
1166#ifndef NO_RSA 1410#ifndef OPENSSL_NO_RSA
1167 for (j=0; j<RSA_NUM; j++) 1411 for (j=0; j<RSA_NUM; j++)
1168 { 1412 {
1169 int ret; 1413 int ret;
@@ -1181,7 +1425,7 @@ int MAIN(int argc, char **argv)
1181 rsa_c[j][0],rsa_bits[j], 1425 rsa_c[j][0],rsa_bits[j],
1182 RSA_SECONDS); 1426 RSA_SECONDS);
1183/* RSA_blinding_on(rsa_key[j],NULL); */ 1427/* RSA_blinding_on(rsa_key[j],NULL); */
1184 Time_F(START,usertime); 1428 Time_F(START);
1185 for (count=0,run=1; COND(rsa_c[j][0]); count++) 1429 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1186 { 1430 {
1187 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, 1431 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
@@ -1195,10 +1439,10 @@ int MAIN(int argc, char **argv)
1195 break; 1439 break;
1196 } 1440 }
1197 } 1441 }
1198 d=Time_F(STOP,usertime); 1442 d=Time_F(STOP);
1199 BIO_printf(bio_err, 1443 BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1200 "%ld %d bit private RSA's in %.2fs\n", 1444 : "%ld %d bit private RSA's in %.2fs\n",
1201 count,rsa_bits[j],d); 1445 count,rsa_bits[j],d);
1202 rsa_results[j][0]=d/(double)count; 1446 rsa_results[j][0]=d/(double)count;
1203 rsa_count=count; 1447 rsa_count=count;
1204 } 1448 }
@@ -1216,7 +1460,7 @@ int MAIN(int argc, char **argv)
1216 pkey_print_message("public","rsa", 1460 pkey_print_message("public","rsa",
1217 rsa_c[j][1],rsa_bits[j], 1461 rsa_c[j][1],rsa_bits[j],
1218 RSA_SECONDS); 1462 RSA_SECONDS);
1219 Time_F(START,usertime); 1463 Time_F(START);
1220 for (count=0,run=1; COND(rsa_c[j][1]); count++) 1464 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1221 { 1465 {
1222 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, 1466 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
@@ -1230,10 +1474,10 @@ int MAIN(int argc, char **argv)
1230 break; 1474 break;
1231 } 1475 }
1232 } 1476 }
1233 d=Time_F(STOP,usertime); 1477 d=Time_F(STOP);
1234 BIO_printf(bio_err, 1478 BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1235 "%ld %d bit public RSA's in %.2fs\n", 1479 : "%ld %d bit public RSA's in %.2fs\n",
1236 count,rsa_bits[j],d); 1480 count,rsa_bits[j],d);
1237 rsa_results[j][1]=d/(double)count; 1481 rsa_results[j][1]=d/(double)count;
1238 } 1482 }
1239#endif 1483#endif
@@ -1248,7 +1492,7 @@ int MAIN(int argc, char **argv)
1248#endif 1492#endif
1249 1493
1250 RAND_pseudo_bytes(buf,20); 1494 RAND_pseudo_bytes(buf,20);
1251#ifndef NO_DSA 1495#ifndef OPENSSL_NO_DSA
1252 if (RAND_status() != 1) 1496 if (RAND_status() != 1)
1253 { 1497 {
1254 RAND_seed(rnd_seed, sizeof rnd_seed); 1498 RAND_seed(rnd_seed, sizeof rnd_seed);
@@ -1260,7 +1504,7 @@ int MAIN(int argc, char **argv)
1260 int ret; 1504 int ret;
1261 1505
1262 if (!dsa_doit[j]) continue; 1506 if (!dsa_doit[j]) continue;
1263 DSA_generate_key(dsa_key[j]); 1507/* DSA_generate_key(dsa_key[j]); */
1264/* DSA_sign_setup(dsa_key[j],NULL); */ 1508/* DSA_sign_setup(dsa_key[j],NULL); */
1265 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2, 1509 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1266 &kk,dsa_key[j]); 1510 &kk,dsa_key[j]);
@@ -1275,7 +1519,7 @@ int MAIN(int argc, char **argv)
1275 pkey_print_message("sign","dsa", 1519 pkey_print_message("sign","dsa",
1276 dsa_c[j][0],dsa_bits[j], 1520 dsa_c[j][0],dsa_bits[j],
1277 DSA_SECONDS); 1521 DSA_SECONDS);
1278 Time_F(START,usertime); 1522 Time_F(START);
1279 for (count=0,run=1; COND(dsa_c[j][0]); count++) 1523 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1280 { 1524 {
1281 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2, 1525 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
@@ -1289,9 +1533,10 @@ int MAIN(int argc, char **argv)
1289 break; 1533 break;
1290 } 1534 }
1291 } 1535 }
1292 d=Time_F(STOP,usertime); 1536 d=Time_F(STOP);
1293 BIO_printf(bio_err,"%ld %d bit DSA signs in %.2fs\n", 1537 BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1294 count,dsa_bits[j],d); 1538 : "%ld %d bit DSA signs in %.2fs\n",
1539 count,dsa_bits[j],d);
1295 dsa_results[j][0]=d/(double)count; 1540 dsa_results[j][0]=d/(double)count;
1296 rsa_count=count; 1541 rsa_count=count;
1297 } 1542 }
@@ -1309,7 +1554,7 @@ int MAIN(int argc, char **argv)
1309 pkey_print_message("verify","dsa", 1554 pkey_print_message("verify","dsa",
1310 dsa_c[j][1],dsa_bits[j], 1555 dsa_c[j][1],dsa_bits[j],
1311 DSA_SECONDS); 1556 DSA_SECONDS);
1312 Time_F(START,usertime); 1557 Time_F(START);
1313 for (count=0,run=1; COND(dsa_c[j][1]); count++) 1558 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1314 { 1559 {
1315 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2, 1560 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
@@ -1323,9 +1568,10 @@ int MAIN(int argc, char **argv)
1323 break; 1568 break;
1324 } 1569 }
1325 } 1570 }
1326 d=Time_F(STOP,usertime); 1571 d=Time_F(STOP);
1327 BIO_printf(bio_err,"%ld %d bit DSA verify in %.2fs\n", 1572 BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1328 count,dsa_bits[j],d); 1573 : "%ld %d bit DSA verify in %.2fs\n",
1574 count,dsa_bits[j],d);
1329 dsa_results[j][1]=d/(double)count; 1575 dsa_results[j][1]=d/(double)count;
1330 } 1576 }
1331 1577
@@ -1338,79 +1584,129 @@ int MAIN(int argc, char **argv)
1338 } 1584 }
1339 if (rnd_fake) RAND_cleanup(); 1585 if (rnd_fake) RAND_cleanup();
1340#endif 1586#endif
1341 1587#ifdef HAVE_FORK
1342 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION)); 1588show_res:
1589#endif
1590 if(!mr)
1591 {
1592 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
1343 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON)); 1593 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
1344 printf("options:"); 1594 printf("options:");
1345 printf("%s ",BN_options()); 1595 printf("%s ",BN_options());
1346#ifndef NO_MD2 1596#ifndef OPENSSL_NO_MD2
1347 printf("%s ",MD2_options()); 1597 printf("%s ",MD2_options());
1598#endif
1599#ifndef OPENSSL_NO_RC4
1600 printf("%s ",RC4_options());
1601#endif
1602#ifndef OPENSSL_NO_DES
1603 printf("%s ",DES_options());
1604#endif
1605#ifndef OPENSSL_NO_AES
1606 printf("%s ",AES_options());
1607#endif
1608#ifndef OPENSSL_NO_IDEA
1609 printf("%s ",idea_options());
1348#endif 1610#endif
1349#ifndef NO_RC4 1611#ifndef OPENSSL_NO_BF
1350 printf("%s ",RC4_options()); 1612 printf("%s ",BF_options());
1351#endif 1613#endif
1352#ifndef NO_DES 1614 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
1353 printf("%s ",des_options()); 1615 printf("available timing options: ");
1616#ifdef TIMES
1617 printf("TIMES ");
1354#endif 1618#endif
1355#ifndef NO_IDEA 1619#ifdef TIMEB
1356 printf("%s ",idea_options()); 1620 printf("TIMEB ");
1357#endif 1621#endif
1358#ifndef NO_BF 1622#ifdef USE_TOD
1359 printf("%s ",BF_options()); 1623 printf("USE_TOD ");
1624#endif
1625#ifdef HZ
1626#define as_string(s) (#s)
1627 printf("HZ=%g", HZ);
1628# ifdef _SC_CLK_TCK
1629 printf(" [sysconf value]");
1630# endif
1360#endif 1631#endif
1361 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS)); 1632 printf("\n");
1633 printf("timing function used: %s%s%s%s%s%s%s\n",
1634 (ftime_used ? "ftime" : ""),
1635 (ftime_used + times_used > 1 ? "," : ""),
1636 (times_used ? "times" : ""),
1637 (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
1638 (gettimeofday_used ? "gettimeofday" : ""),
1639 (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
1640 (getrusage_used ? "getrusage" : ""));
1641 }
1362 1642
1363 if (pr_header) 1643 if (pr_header)
1364 { 1644 {
1365 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n"); 1645 if(mr)
1366 fprintf(stdout,"type "); 1646 fprintf(stdout,"+H");
1647 else
1648 {
1649 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
1650 fprintf(stdout,"type ");
1651 }
1367 for (j=0; j<SIZE_NUM; j++) 1652 for (j=0; j<SIZE_NUM; j++)
1368 fprintf(stdout,"%7d bytes",lengths[j]); 1653 fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
1369 fprintf(stdout,"\n"); 1654 fprintf(stdout,"\n");
1370 } 1655 }
1371 1656
1372 for (k=0; k<ALGOR_NUM; k++) 1657 for (k=0; k<ALGOR_NUM; k++)
1373 { 1658 {
1374 if (!doit[k]) continue; 1659 if (!doit[k]) continue;
1375 fprintf(stdout,"%-13s",names[k]); 1660 if(mr)
1661 fprintf(stdout,"+F:%d:%s",k,names[k]);
1662 else
1663 fprintf(stdout,"%-13s",names[k]);
1376 for (j=0; j<SIZE_NUM; j++) 1664 for (j=0; j<SIZE_NUM; j++)
1377 { 1665 {
1378 if (results[k][j] > 10000) 1666 if (results[k][j] > 10000 && !mr)
1379 fprintf(stdout," %11.2fk",results[k][j]/1e3); 1667 fprintf(stdout," %11.2fk",results[k][j]/1e3);
1380 else 1668 else
1381 fprintf(stdout," %11.2f ",results[k][j]); 1669 fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
1382 } 1670 }
1383 fprintf(stdout,"\n"); 1671 fprintf(stdout,"\n");
1384 } 1672 }
1385#ifndef NO_RSA 1673#ifndef OPENSSL_NO_RSA
1386 j=1; 1674 j=1;
1387 for (k=0; k<RSA_NUM; k++) 1675 for (k=0; k<RSA_NUM; k++)
1388 { 1676 {
1389 if (!rsa_doit[k]) continue; 1677 if (!rsa_doit[k]) continue;
1390 if (j) 1678 if (j && !mr)
1391 { 1679 {
1392 printf("%18ssign verify sign/s verify/s\n"," "); 1680 printf("%18ssign verify sign/s verify/s\n"," ");
1393 j=0; 1681 j=0;
1394 } 1682 }
1395 fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f", 1683 if(mr)
1396 rsa_bits[k],rsa_results[k][0],rsa_results[k][1], 1684 fprintf(stdout,"+F2:%u:%u:%f:%f\n",
1397 1.0/rsa_results[k][0],1.0/rsa_results[k][1]); 1685 k,rsa_bits[k],rsa_results[k][0],
1398 fprintf(stdout,"\n"); 1686 rsa_results[k][1]);
1687 else
1688 fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1689 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
1690 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
1399 } 1691 }
1400#endif 1692#endif
1401#ifndef NO_DSA 1693#ifndef OPENSSL_NO_DSA
1402 j=1; 1694 j=1;
1403 for (k=0; k<DSA_NUM; k++) 1695 for (k=0; k<DSA_NUM; k++)
1404 { 1696 {
1405 if (!dsa_doit[k]) continue; 1697 if (!dsa_doit[k]) continue;
1406 if (j) { 1698 if (j && !mr)
1699 {
1407 printf("%18ssign verify sign/s verify/s\n"," "); 1700 printf("%18ssign verify sign/s verify/s\n"," ");
1408 j=0; 1701 j=0;
1409 } 1702 }
1410 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f", 1703 if(mr)
1411 dsa_bits[k],dsa_results[k][0],dsa_results[k][1], 1704 fprintf(stdout,"+F3:%u:%u:%f:%f\n",
1412 1.0/dsa_results[k][0],1.0/dsa_results[k][1]); 1705 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
1413 fprintf(stdout,"\n"); 1706 else
1707 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1708 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1709 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1414 } 1710 }
1415#endif 1711#endif
1416 mret=0; 1712 mret=0;
@@ -1418,27 +1714,30 @@ end:
1418 ERR_print_errors(bio_err); 1714 ERR_print_errors(bio_err);
1419 if (buf != NULL) OPENSSL_free(buf); 1715 if (buf != NULL) OPENSSL_free(buf);
1420 if (buf2 != NULL) OPENSSL_free(buf2); 1716 if (buf2 != NULL) OPENSSL_free(buf2);
1421#ifndef NO_RSA 1717#ifndef OPENSSL_NO_RSA
1422 for (i=0; i<RSA_NUM; i++) 1718 for (i=0; i<RSA_NUM; i++)
1423 if (rsa_key[i] != NULL) 1719 if (rsa_key[i] != NULL)
1424 RSA_free(rsa_key[i]); 1720 RSA_free(rsa_key[i]);
1425#endif 1721#endif
1426#ifndef NO_DSA 1722#ifndef OPENSSL_NO_DSA
1427 for (i=0; i<DSA_NUM; i++) 1723 for (i=0; i<DSA_NUM; i++)
1428 if (dsa_key[i] != NULL) 1724 if (dsa_key[i] != NULL)
1429 DSA_free(dsa_key[i]); 1725 DSA_free(dsa_key[i]);
1430#endif 1726#endif
1727 apps_shutdown();
1431 EXIT(mret); 1728 EXIT(mret);
1432 } 1729 }
1433 1730
1434static void print_message(char *s, long num, int length) 1731static void print_message(const char *s, long num, int length)
1435 { 1732 {
1436#ifdef SIGALRM 1733#ifdef SIGALRM
1437 BIO_printf(bio_err,"Doing %s for %ds on %d size blocks: ",s,SECONDS,length); 1734 BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
1735 : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
1438 (void)BIO_flush(bio_err); 1736 (void)BIO_flush(bio_err);
1439 alarm(SECONDS); 1737 alarm(SECONDS);
1440#else 1738#else
1441 BIO_printf(bio_err,"Doing %s %ld times on %d size blocks: ",s,num,length); 1739 BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
1740 : "Doing %s %ld times on %d size blocks: ",s,num,length);
1442 (void)BIO_flush(bio_err); 1741 (void)BIO_flush(bio_err);
1443#endif 1742#endif
1444#ifdef LINT 1743#ifdef LINT
@@ -1450,11 +1749,13 @@ static void pkey_print_message(char *str, char *str2, long num, int bits,
1450 int tm) 1749 int tm)
1451 { 1750 {
1452#ifdef SIGALRM 1751#ifdef SIGALRM
1453 BIO_printf(bio_err,"Doing %d bit %s %s's for %ds: ",bits,str,str2,tm); 1752 BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
1753 : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
1454 (void)BIO_flush(bio_err); 1754 (void)BIO_flush(bio_err);
1455 alarm(RSA_SECONDS); 1755 alarm(RSA_SECONDS);
1456#else 1756#else
1457 BIO_printf(bio_err,"Doing %ld %d bit %s %s's: ",num,bits,str,str2); 1757 BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
1758 : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
1458 (void)BIO_flush(bio_err); 1759 (void)BIO_flush(bio_err);
1459#endif 1760#endif
1460#ifdef LINT 1761#ifdef LINT
@@ -1462,3 +1763,175 @@ static void pkey_print_message(char *str, char *str2, long num, int bits,
1462#endif 1763#endif
1463 } 1764 }
1464 1765
1766static void print_result(int alg,int run_no,int count,double time_used)
1767 {
1768 BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
1769 : "%ld %s's in %.2fs\n",count,names[alg],time_used);
1770 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
1771 }
1772
1773static char *sstrsep(char **string, const char *delim)
1774 {
1775 char isdelim[256];
1776 char *token = *string;
1777
1778 if (**string == 0)
1779 return NULL;
1780
1781 memset(isdelim, 0, 256);
1782 isdelim[0] = 1;
1783
1784 while (*delim)
1785 {
1786 isdelim[(unsigned char)(*delim)] = 1;
1787 delim++;
1788 }
1789
1790 while (!isdelim[(unsigned char)(**string)])
1791 {
1792 (*string)++;
1793 }
1794
1795 if (**string)
1796 {
1797 **string = 0;
1798 (*string)++;
1799 }
1800
1801 return token;
1802 }
1803
1804#ifdef HAVE_FORK
1805static int do_multi(int multi)
1806 {
1807 int n;
1808 int fd[2];
1809 int *fds;
1810 static char sep[]=":";
1811
1812 fds=malloc(multi*sizeof *fds);
1813 for(n=0 ; n < multi ; ++n)
1814 {
1815 pipe(fd);
1816 if(fork())
1817 {
1818 close(fd[1]);
1819 fds[n]=fd[0];
1820 }
1821 else
1822 {
1823 close(fd[0]);
1824 close(1);
1825 dup(fd[1]);
1826 close(fd[1]);
1827 mr=1;
1828 usertime=0;
1829 return 0;
1830 }
1831 printf("Forked child %d\n",n);
1832 }
1833
1834 /* for now, assume the pipe is long enough to take all the output */
1835 for(n=0 ; n < multi ; ++n)
1836 {
1837 FILE *f;
1838 char buf[1024];
1839 char *p;
1840
1841 f=fdopen(fds[n],"r");
1842 while(fgets(buf,sizeof buf,f))
1843 {
1844 p=strchr(buf,'\n');
1845 if(p)
1846 *p='\0';
1847 if(buf[0] != '+')
1848 {
1849 fprintf(stderr,"Don't understand line '%s' from child %d\n",
1850 buf,n);
1851 continue;
1852 }
1853 printf("Got: %s from %d\n",buf,n);
1854 if(!strncmp(buf,"+F:",3))
1855 {
1856 int alg;
1857 int j;
1858
1859 p=buf+3;
1860 alg=atoi(sstrsep(&p,sep));
1861 sstrsep(&p,sep);
1862 for(j=0 ; j < SIZE_NUM ; ++j)
1863 results[alg][j]+=atof(sstrsep(&p,sep));
1864 }
1865 else if(!strncmp(buf,"+F2:",4))
1866 {
1867 int k;
1868 double d;
1869
1870 p=buf+4;
1871 k=atoi(sstrsep(&p,sep));
1872 sstrsep(&p,sep);
1873
1874 d=atof(sstrsep(&p,sep));
1875 if(n)
1876 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1877 else
1878 rsa_results[k][0]=d;
1879
1880 d=atof(sstrsep(&p,sep));
1881 if(n)
1882 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1883 else
1884 rsa_results[k][1]=d;
1885 }
1886 else if(!strncmp(buf,"+F2:",4))
1887 {
1888 int k;
1889 double d;
1890
1891 p=buf+4;
1892 k=atoi(sstrsep(&p,sep));
1893 sstrsep(&p,sep);
1894
1895 d=atof(sstrsep(&p,sep));
1896 if(n)
1897 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1898 else
1899 rsa_results[k][0]=d;
1900
1901 d=atof(sstrsep(&p,sep));
1902 if(n)
1903 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1904 else
1905 rsa_results[k][1]=d;
1906 }
1907 else if(!strncmp(buf,"+F3:",4))
1908 {
1909 int k;
1910 double d;
1911
1912 p=buf+4;
1913 k=atoi(sstrsep(&p,sep));
1914 sstrsep(&p,sep);
1915
1916 d=atof(sstrsep(&p,sep));
1917 if(n)
1918 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
1919 else
1920 dsa_results[k][0]=d;
1921
1922 d=atof(sstrsep(&p,sep));
1923 if(n)
1924 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
1925 else
1926 dsa_results[k][1]=d;
1927 }
1928 else if(!strncmp(buf,"+H:",3))
1929 {
1930 }
1931 else
1932 fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);
1933 }
1934 }
1935 return 1;
1936 }
1937#endif
diff --git a/src/lib/libssl/src/apps/spkac.c b/src/lib/libssl/src/apps/spkac.c
index d7e46782f7..049a37963c 100644
--- a/src/lib/libssl/src/apps/spkac.c
+++ b/src/lib/libssl/src/apps/spkac.c
@@ -69,7 +69,6 @@
69#include <openssl/lhash.h> 69#include <openssl/lhash.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/pem.h> 71#include <openssl/pem.h>
72#include <openssl/engine.h>
73 72
74#undef PROG 73#undef PROG
75#define PROG spkac_main 74#define PROG spkac_main
@@ -84,13 +83,13 @@ int MAIN(int argc, char **argv)
84 { 83 {
85 ENGINE *e = NULL; 84 ENGINE *e = NULL;
86 int i,badops=0, ret = 1; 85 int i,badops=0, ret = 1;
87 BIO *in = NULL,*out = NULL, *key = NULL; 86 BIO *in = NULL,*out = NULL;
88 int verify=0,noout=0,pubkey=0; 87 int verify=0,noout=0,pubkey=0;
89 char *infile = NULL,*outfile = NULL,*prog; 88 char *infile = NULL,*outfile = NULL,*prog;
90 char *passargin = NULL, *passin = NULL; 89 char *passargin = NULL, *passin = NULL;
91 char *spkac = "SPKAC", *spksect = "default", *spkstr = NULL; 90 char *spkac = "SPKAC", *spksect = "default", *spkstr = NULL;
92 char *challenge = NULL, *keyfile = NULL; 91 char *challenge = NULL, *keyfile = NULL;
93 LHASH *conf = NULL; 92 CONF *conf = NULL;
94 NETSCAPE_SPKI *spki = NULL; 93 NETSCAPE_SPKI *spki = NULL;
95 EVP_PKEY *pkey = NULL; 94 EVP_PKEY *pkey = NULL;
96 char *engine=NULL; 95 char *engine=NULL;
@@ -99,6 +98,9 @@ int MAIN(int argc, char **argv)
99 98
100 if (!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); 99 if (!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
101 100
101 if (!load_config(bio_err, NULL))
102 goto end;
103
102 prog=argv[0]; 104 prog=argv[0];
103 argc--; 105 argc--;
104 argv++; 106 argv++;
@@ -179,36 +181,13 @@ bad:
179 goto end; 181 goto end;
180 } 182 }
181 183
182 if (engine != NULL) 184 e = setup_engine(bio_err, engine, 0);
183 {
184 if((e = ENGINE_by_id(engine)) == NULL)
185 {
186 BIO_printf(bio_err,"invalid engine \"%s\"\n",
187 engine);
188 goto end;
189 }
190 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
191 {
192 BIO_printf(bio_err,"can't use that engine\n");
193 goto end;
194 }
195 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
196 /* Free our "structural" reference. */
197 ENGINE_free(e);
198 }
199 185
200 if(keyfile) { 186 if(keyfile) {
201 if(strcmp(keyfile, "-")) key = BIO_new_file(keyfile, "r"); 187 pkey = load_key(bio_err,
202 else key = BIO_new_fp(stdin, BIO_NOCLOSE); 188 strcmp(keyfile, "-") ? keyfile : NULL,
203 if(!key) { 189 FORMAT_PEM, passin, e, "private key");
204 BIO_printf(bio_err, "Error opening key file\n");
205 ERR_print_errors(bio_err);
206 goto end;
207 }
208 pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, passin);
209 if(!pkey) { 190 if(!pkey) {
210 BIO_printf(bio_err, "Error reading private key\n");
211 ERR_print_errors(bio_err);
212 goto end; 191 goto end;
213 } 192 }
214 spki = NETSCAPE_SPKI_new(); 193 spki = NETSCAPE_SPKI_new();
@@ -221,7 +200,7 @@ bad:
221 if (outfile) out = BIO_new_file(outfile, "w"); 200 if (outfile) out = BIO_new_file(outfile, "w");
222 else { 201 else {
223 out = BIO_new_fp(stdout, BIO_NOCLOSE); 202 out = BIO_new_fp(stdout, BIO_NOCLOSE);
224#ifdef VMS 203#ifdef OPENSSL_SYS_VMS
225 { 204 {
226 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 205 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
227 out = BIO_push(tmpbio, out); 206 out = BIO_push(tmpbio, out);
@@ -251,15 +230,16 @@ bad:
251 goto end; 230 goto end;
252 } 231 }
253 232
254 conf = CONF_load_bio(NULL, in, NULL); 233 conf = NCONF_new(NULL);
234 i = NCONF_load_bio(conf, in, NULL);
255 235
256 if(!conf) { 236 if(!i) {
257 BIO_printf(bio_err, "Error parsing config file\n"); 237 BIO_printf(bio_err, "Error parsing config file\n");
258 ERR_print_errors(bio_err); 238 ERR_print_errors(bio_err);
259 goto end; 239 goto end;
260 } 240 }
261 241
262 spkstr = CONF_get_string(conf, spksect, spkac); 242 spkstr = NCONF_get_string(conf, spksect, spkac);
263 243
264 if(!spkstr) { 244 if(!spkstr) {
265 BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac); 245 BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac);
@@ -278,7 +258,7 @@ bad:
278 if (outfile) out = BIO_new_file(outfile, "w"); 258 if (outfile) out = BIO_new_file(outfile, "w");
279 else { 259 else {
280 out = BIO_new_fp(stdout, BIO_NOCLOSE); 260 out = BIO_new_fp(stdout, BIO_NOCLOSE);
281#ifdef VMS 261#ifdef OPENSSL_SYS_VMS
282 { 262 {
283 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 263 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
284 out = BIO_push(tmpbio, out); 264 out = BIO_push(tmpbio, out);
@@ -308,12 +288,12 @@ bad:
308 ret = 0; 288 ret = 0;
309 289
310end: 290end:
311 CONF_free(conf); 291 NCONF_free(conf);
312 NETSCAPE_SPKI_free(spki); 292 NETSCAPE_SPKI_free(spki);
313 BIO_free(in); 293 BIO_free(in);
314 BIO_free_all(out); 294 BIO_free_all(out);
315 BIO_free(key);
316 EVP_PKEY_free(pkey); 295 EVP_PKEY_free(pkey);
317 if(passin) OPENSSL_free(passin); 296 if(passin) OPENSSL_free(passin);
297 apps_shutdown();
318 EXIT(ret); 298 EXIT(ret);
319 } 299 }
diff --git a/src/lib/libssl/src/apps/testdsa.h b/src/lib/libssl/src/apps/testdsa.h
index f0bfbb1ffa..9e84e31c93 100644
--- a/src/lib/libssl/src/apps/testdsa.h
+++ b/src/lib/libssl/src/apps/testdsa.h
@@ -3,6 +3,18 @@
3DSA *get_dsa512(void ); 3DSA *get_dsa512(void );
4DSA *get_dsa1024(void ); 4DSA *get_dsa1024(void );
5DSA *get_dsa2048(void ); 5DSA *get_dsa2048(void );
6static unsigned char dsa512_priv[] = {
7 0x65,0xe5,0xc7,0x38,0x60,0x24,0xb5,0x89,0xd4,0x9c,0xeb,0x4c,
8 0x9c,0x1d,0x7a,0x22,0xbd,0xd1,0xc2,0xd2,
9 };
10static unsigned char dsa512_pub[] = {
11 0x00,0x95,0xa7,0x0d,0xec,0x93,0x68,0xba,0x5f,0xf7,0x5f,0x07,
12 0xf2,0x3b,0xad,0x6b,0x01,0xdc,0xbe,0xec,0xde,0x04,0x7a,0x3a,
13 0x27,0xb3,0xec,0x49,0xfd,0x08,0x43,0x3d,0x7e,0xa8,0x2c,0x5e,
14 0x7b,0xbb,0xfc,0xf4,0x6e,0xeb,0x6c,0xb0,0x6e,0xf8,0x02,0x12,
15 0x8c,0x38,0x5d,0x83,0x56,0x7d,0xee,0x53,0x05,0x3e,0x24,0x84,
16 0xbe,0xba,0x0a,0x6b,0xc8,
17 };
6static unsigned char dsa512_p[]={ 18static unsigned char dsa512_p[]={
7 0x9D,0x1B,0x69,0x8E,0x26,0xDB,0xF2,0x2B,0x11,0x70,0x19,0x86, 19 0x9D,0x1B,0x69,0x8E,0x26,0xDB,0xF2,0x2B,0x11,0x70,0x19,0x86,
8 0xF6,0x19,0xC8,0xF8,0x19,0xF2,0x18,0x53,0x94,0x46,0x06,0xD0, 20 0xF6,0x19,0xC8,0xF8,0x19,0xF2,0x18,0x53,0x94,0x46,0x06,0xD0,
@@ -29,14 +41,34 @@ DSA *get_dsa512()
29 DSA *dsa; 41 DSA *dsa;
30 42
31 if ((dsa=DSA_new()) == NULL) return(NULL); 43 if ((dsa=DSA_new()) == NULL) return(NULL);
44 dsa->priv_key=BN_bin2bn(dsa512_priv,sizeof(dsa512_priv),NULL);
45 dsa->pub_key=BN_bin2bn(dsa512_pub,sizeof(dsa512_pub),NULL);
32 dsa->p=BN_bin2bn(dsa512_p,sizeof(dsa512_p),NULL); 46 dsa->p=BN_bin2bn(dsa512_p,sizeof(dsa512_p),NULL);
33 dsa->q=BN_bin2bn(dsa512_q,sizeof(dsa512_q),NULL); 47 dsa->q=BN_bin2bn(dsa512_q,sizeof(dsa512_q),NULL);
34 dsa->g=BN_bin2bn(dsa512_g,sizeof(dsa512_g),NULL); 48 dsa->g=BN_bin2bn(dsa512_g,sizeof(dsa512_g),NULL);
35 if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) 49 if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) ||
50 (dsa->q == NULL) || (dsa->g == NULL))
36 return(NULL); 51 return(NULL);
37 return(dsa); 52 return(dsa);
38 } 53 }
39 54
55static unsigned char dsa1024_priv[]={
56 0x7d,0x21,0xda,0xbb,0x62,0x15,0x47,0x36,0x07,0x67,0x12,0xe8,
57 0x8c,0xaa,0x1c,0xcd,0x38,0x12,0x61,0x18,
58 };
59static unsigned char dsa1024_pub[]={
60 0x3c,0x4e,0x9c,0x2a,0x7f,0x16,0xc1,0x25,0xeb,0xac,0x78,0x63,
61 0x90,0x14,0x8c,0x8b,0xf4,0x68,0x43,0x3c,0x2d,0xee,0x65,0x50,
62 0x7d,0x9c,0x8f,0x8c,0x8a,0x51,0xd6,0x11,0x2b,0x99,0xaf,0x1e,
63 0x90,0x97,0xb5,0xd3,0xa6,0x20,0x25,0xd6,0xfe,0x43,0x02,0xd5,
64 0x91,0x7d,0xa7,0x8c,0xdb,0xc9,0x85,0xa3,0x36,0x48,0xf7,0x68,
65 0xaa,0x60,0xb1,0xf7,0x05,0x68,0x3a,0xa3,0x3f,0xd3,0x19,0x82,
66 0xd8,0x82,0x7a,0x77,0xfb,0xef,0xf4,0x15,0x0a,0xeb,0x06,0x04,
67 0x7f,0x53,0x07,0x0c,0xbc,0xcb,0x2d,0x83,0xdb,0x3e,0xd1,0x28,
68 0xa5,0xa1,0x31,0xe0,0x67,0xfa,0x50,0xde,0x9b,0x07,0x83,0x7e,
69 0x2c,0x0b,0xc3,0x13,0x50,0x61,0xe5,0xad,0xbd,0x36,0xb8,0x97,
70 0x4e,0x40,0x7d,0xe8,0x83,0x0d,0xbc,0x4b
71 };
40static unsigned char dsa1024_p[]={ 72static unsigned char dsa1024_p[]={
41 0xA7,0x3F,0x6E,0x85,0xBF,0x41,0x6A,0x29,0x7D,0xF0,0x9F,0x47, 73 0xA7,0x3F,0x6E,0x85,0xBF,0x41,0x6A,0x29,0x7D,0xF0,0x9F,0x47,
42 0x19,0x30,0x90,0x9A,0x09,0x1D,0xDA,0x6A,0x33,0x1E,0xC5,0x3D, 74 0x19,0x30,0x90,0x9A,0x09,0x1D,0xDA,0x6A,0x33,0x1E,0xC5,0x3D,
@@ -73,14 +105,45 @@ DSA *get_dsa1024()
73 DSA *dsa; 105 DSA *dsa;
74 106
75 if ((dsa=DSA_new()) == NULL) return(NULL); 107 if ((dsa=DSA_new()) == NULL) return(NULL);
108 dsa->priv_key=BN_bin2bn(dsa1024_priv,sizeof(dsa1024_priv),NULL);
109 dsa->pub_key=BN_bin2bn(dsa1024_pub,sizeof(dsa1024_pub),NULL);
76 dsa->p=BN_bin2bn(dsa1024_p,sizeof(dsa1024_p),NULL); 110 dsa->p=BN_bin2bn(dsa1024_p,sizeof(dsa1024_p),NULL);
77 dsa->q=BN_bin2bn(dsa1024_q,sizeof(dsa1024_q),NULL); 111 dsa->q=BN_bin2bn(dsa1024_q,sizeof(dsa1024_q),NULL);
78 dsa->g=BN_bin2bn(dsa1024_g,sizeof(dsa1024_g),NULL); 112 dsa->g=BN_bin2bn(dsa1024_g,sizeof(dsa1024_g),NULL);
79 if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) 113 if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) ||
114 (dsa->q == NULL) || (dsa->g == NULL))
80 return(NULL); 115 return(NULL);
81 return(dsa); 116 return(dsa);
82 } 117 }
83 118
119static unsigned char dsa2048_priv[]={
120 0x32,0x67,0x92,0xf6,0xc4,0xe2,0xe2,0xe8,0xa0,0x8b,0x6b,0x45,
121 0x0c,0x8a,0x76,0xb0,0xee,0xcf,0x91,0xa7,
122 };
123static unsigned char dsa2048_pub[]={
124 0x17,0x8f,0xa8,0x11,0x84,0x92,0xec,0x83,0x47,0xc7,0x6a,0xb0,
125 0x92,0xaf,0x5a,0x20,0x37,0xa3,0x64,0x79,0xd2,0xd0,0x3d,0xcd,
126 0xe0,0x61,0x88,0x88,0x21,0xcc,0x74,0x5d,0xce,0x4c,0x51,0x47,
127 0xf0,0xc5,0x5c,0x4c,0x82,0x7a,0xaf,0x72,0xad,0xb9,0xe0,0x53,
128 0xf2,0x78,0xb7,0xf0,0xb5,0x48,0x7f,0x8a,0x3a,0x18,0xd1,0x9f,
129 0x8b,0x7d,0xa5,0x47,0xb7,0x95,0xab,0x98,0xf8,0x7b,0x74,0x50,
130 0x56,0x8e,0x57,0xf0,0xee,0xf5,0xb7,0xba,0xab,0x85,0x86,0xf9,
131 0x2b,0xef,0x41,0x56,0xa0,0xa4,0x9f,0xb7,0x38,0x00,0x46,0x0a,
132 0xa6,0xf1,0xfc,0x1f,0xd8,0x4e,0x85,0x44,0x92,0x43,0x21,0x5d,
133 0x6e,0xcc,0xc2,0xcb,0x26,0x31,0x0d,0x21,0xc4,0xbd,0x8d,0x24,
134 0xbc,0xd9,0x18,0x19,0xd7,0xdc,0xf1,0xe7,0x93,0x50,0x48,0x03,
135 0x2c,0xae,0x2e,0xe7,0x49,0x88,0x5f,0x93,0x57,0x27,0x99,0x36,
136 0xb4,0x20,0xab,0xfc,0xa7,0x2b,0xf2,0xd9,0x98,0xd7,0xd4,0x34,
137 0x9d,0x96,0x50,0x58,0x9a,0xea,0x54,0xf3,0xee,0xf5,0x63,0x14,
138 0xee,0x85,0x83,0x74,0x76,0xe1,0x52,0x95,0xc3,0xf7,0xeb,0x04,
139 0x04,0x7b,0xa7,0x28,0x1b,0xcc,0xea,0x4a,0x4e,0x84,0xda,0xd8,
140 0x9c,0x79,0xd8,0x9b,0x66,0x89,0x2f,0xcf,0xac,0xd7,0x79,0xf9,
141 0xa9,0xd8,0x45,0x13,0x78,0xb9,0x00,0x14,0xc9,0x7e,0x22,0x51,
142 0x86,0x67,0xb0,0x9f,0x26,0x11,0x23,0xc8,0x38,0xd7,0x70,0x1d,
143 0x15,0x8e,0x4d,0x4f,0x95,0x97,0x40,0xa1,0xc2,0x7e,0x01,0x18,
144 0x72,0xf4,0x10,0xe6,0x8d,0x52,0x16,0x7f,0xf2,0xc9,0xf8,0x33,
145 0x8b,0x33,0xb7,0xce,
146 };
84static unsigned char dsa2048_p[]={ 147static unsigned char dsa2048_p[]={
85 0xA0,0x25,0xFA,0xAD,0xF4,0x8E,0xB9,0xE5,0x99,0xF3,0x5D,0x6F, 148 0xA0,0x25,0xFA,0xAD,0xF4,0x8E,0xB9,0xE5,0x99,0xF3,0x5D,0x6F,
86 0x4F,0x83,0x34,0xE2,0x7E,0xCF,0x6F,0xBF,0x30,0xAF,0x6F,0x81, 149 0x4F,0x83,0x34,0xE2,0x7E,0xCF,0x6F,0xBF,0x30,0xAF,0x6F,0x81,
@@ -139,10 +202,13 @@ DSA *get_dsa2048()
139 DSA *dsa; 202 DSA *dsa;
140 203
141 if ((dsa=DSA_new()) == NULL) return(NULL); 204 if ((dsa=DSA_new()) == NULL) return(NULL);
205 dsa->priv_key=BN_bin2bn(dsa2048_priv,sizeof(dsa2048_priv),NULL);
206 dsa->pub_key=BN_bin2bn(dsa2048_pub,sizeof(dsa2048_pub),NULL);
142 dsa->p=BN_bin2bn(dsa2048_p,sizeof(dsa2048_p),NULL); 207 dsa->p=BN_bin2bn(dsa2048_p,sizeof(dsa2048_p),NULL);
143 dsa->q=BN_bin2bn(dsa2048_q,sizeof(dsa2048_q),NULL); 208 dsa->q=BN_bin2bn(dsa2048_q,sizeof(dsa2048_q),NULL);
144 dsa->g=BN_bin2bn(dsa2048_g,sizeof(dsa2048_g),NULL); 209 dsa->g=BN_bin2bn(dsa2048_g,sizeof(dsa2048_g),NULL);
145 if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) 210 if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) ||
211 (dsa->q == NULL) || (dsa->g == NULL))
146 return(NULL); 212 return(NULL);
147 return(dsa); 213 return(dsa);
148 } 214 }
diff --git a/src/lib/libssl/src/apps/verify.c b/src/lib/libssl/src/apps/verify.c
index f384de6d29..215ef84fc7 100644
--- a/src/lib/libssl/src/apps/verify.c
+++ b/src/lib/libssl/src/apps/verify.c
@@ -65,15 +65,14 @@
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/x509v3.h> 66#include <openssl/x509v3.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68#include <openssl/engine.h>
69 68
70#undef PROG 69#undef PROG
71#define PROG verify_main 70#define PROG verify_main
72 71
73static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx); 72static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx);
74static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose); 73static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e);
75static STACK_OF(X509) *load_untrusted(char *file); 74static STACK_OF(X509) *load_untrusted(char *file);
76static int v_verbose=0, issuer_checks = 0; 75static int v_verbose=0, vflags = 0;
77 76
78int MAIN(int, char **); 77int MAIN(int, char **);
79 78
@@ -101,6 +100,9 @@ int MAIN(int argc, char **argv)
101 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 100 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
102 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 101 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
103 102
103 if (!load_config(bio_err, NULL))
104 goto end;
105
104 argc--; 106 argc--;
105 argv++; 107 argv++;
106 for (;;) 108 for (;;)
@@ -147,8 +149,14 @@ int MAIN(int argc, char **argv)
147 } 149 }
148 else if (strcmp(*argv,"-help") == 0) 150 else if (strcmp(*argv,"-help") == 0)
149 goto end; 151 goto end;
152 else if (strcmp(*argv,"-ignore_critical") == 0)
153 vflags |= X509_V_FLAG_IGNORE_CRITICAL;
150 else if (strcmp(*argv,"-issuer_checks") == 0) 154 else if (strcmp(*argv,"-issuer_checks") == 0)
151 issuer_checks=1; 155 vflags |= X509_V_FLAG_CB_ISSUER_CHECK;
156 else if (strcmp(*argv,"-crl_check") == 0)
157 vflags |= X509_V_FLAG_CRL_CHECK;
158 else if (strcmp(*argv,"-crl_check_all") == 0)
159 vflags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;
152 else if (strcmp(*argv,"-verbose") == 0) 160 else if (strcmp(*argv,"-verbose") == 0)
153 v_verbose=1; 161 v_verbose=1;
154 else if (argv[0][0] == '-') 162 else if (argv[0][0] == '-')
@@ -162,23 +170,7 @@ int MAIN(int argc, char **argv)
162 break; 170 break;
163 } 171 }
164 172
165 if (engine != NULL) 173 e = setup_engine(bio_err, engine, 0);
166 {
167 if((e = ENGINE_by_id(engine)) == NULL)
168 {
169 BIO_printf(bio_err,"invalid engine \"%s\"\n",
170 engine);
171 goto end;
172 }
173 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
174 {
175 BIO_printf(bio_err,"can't use that engine\n");
176 goto end;
177 }
178 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
179 /* Free our "structural" reference. */
180 ENGINE_free(e);
181 }
182 174
183 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file()); 175 lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file());
184 if (lookup == NULL) abort(); 176 if (lookup == NULL) abort();
@@ -220,14 +212,14 @@ int MAIN(int argc, char **argv)
220 } 212 }
221 } 213 }
222 214
223 if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, purpose); 215 if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, purpose, e);
224 else 216 else
225 for (i=0; i<argc; i++) 217 for (i=0; i<argc; i++)
226 check(cert_ctx,argv[i], untrusted, trusted, purpose); 218 check(cert_ctx,argv[i], untrusted, trusted, purpose, e);
227 ret=0; 219 ret=0;
228end: 220end:
229 if (ret == 1) { 221 if (ret == 1) {
230 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-engine e] cert1 cert2 ...\n"); 222 BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check] [-engine e] cert1 cert2 ...\n");
231 BIO_printf(bio_err,"recognized usages:\n"); 223 BIO_printf(bio_err,"recognized usages:\n");
232 for(i = 0; i < X509_PURPOSE_get_count(); i++) { 224 for(i = 0; i < X509_PURPOSE_get_count(); i++) {
233 X509_PURPOSE *ptmp; 225 X509_PURPOSE *ptmp;
@@ -239,42 +231,19 @@ end:
239 if (cert_ctx != NULL) X509_STORE_free(cert_ctx); 231 if (cert_ctx != NULL) X509_STORE_free(cert_ctx);
240 sk_X509_pop_free(untrusted, X509_free); 232 sk_X509_pop_free(untrusted, X509_free);
241 sk_X509_pop_free(trusted, X509_free); 233 sk_X509_pop_free(trusted, X509_free);
234 apps_shutdown();
242 EXIT(ret); 235 EXIT(ret);
243 } 236 }
244 237
245static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose) 238static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e)
246 { 239 {
247 X509 *x=NULL; 240 X509 *x=NULL;
248 BIO *in=NULL;
249 int i=0,ret=0; 241 int i=0,ret=0;
250 X509_STORE_CTX *csc; 242 X509_STORE_CTX *csc;
251 243
252 in=BIO_new(BIO_s_file()); 244 x = load_cert(bio_err, file, FORMAT_PEM, NULL, e, "certificate file");
253 if (in == NULL)
254 {
255 ERR_print_errors(bio_err);
256 goto end;
257 }
258
259 if (file == NULL)
260 BIO_set_fp(in,stdin,BIO_NOCLOSE);
261 else
262 {
263 if (BIO_read_filename(in,file) <= 0)
264 {
265 perror(file);
266 goto end;
267 }
268 }
269
270 x=PEM_read_bio_X509(in,NULL,NULL,NULL);
271 if (x == NULL) 245 if (x == NULL)
272 {
273 fprintf(stdout,"%s: unable to load certificate file\n",
274 (file == NULL)?"stdin":file);
275 ERR_print_errors(bio_err);
276 goto end; 246 goto end;
277 }
278 fprintf(stdout,"%s: ",(file == NULL)?"stdin":file); 247 fprintf(stdout,"%s: ",(file == NULL)?"stdin":file);
279 248
280 csc = X509_STORE_CTX_new(); 249 csc = X509_STORE_CTX_new();
@@ -283,11 +252,14 @@ static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X
283 ERR_print_errors(bio_err); 252 ERR_print_errors(bio_err);
284 goto end; 253 goto end;
285 } 254 }
286 X509_STORE_CTX_init(csc,ctx,x,uchain); 255 X509_STORE_set_flags(ctx, vflags);
256 if(!X509_STORE_CTX_init(csc,ctx,x,uchain))
257 {
258 ERR_print_errors(bio_err);
259 goto end;
260 }
287 if(tchain) X509_STORE_CTX_trusted_stack(csc, tchain); 261 if(tchain) X509_STORE_CTX_trusted_stack(csc, tchain);
288 if(purpose >= 0) X509_STORE_CTX_set_purpose(csc, purpose); 262 if(purpose >= 0) X509_STORE_CTX_set_purpose(csc, purpose);
289 if(issuer_checks)
290 X509_STORE_CTX_set_flags(csc, X509_V_FLAG_CB_ISSUER_CHECK);
291 i=X509_verify_cert(csc); 263 i=X509_verify_cert(csc);
292 X509_STORE_CTX_free(csc); 264 X509_STORE_CTX_free(csc);
293 265
@@ -301,7 +273,6 @@ end:
301 else 273 else
302 ERR_print_errors(bio_err); 274 ERR_print_errors(bio_err);
303 if (x != NULL) X509_free(x); 275 if (x != NULL) X509_free(x);
304 if (in != NULL) BIO_free(in);
305 276
306 return(ret); 277 return(ret);
307 } 278 }
@@ -375,6 +346,9 @@ static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx)
375 if (ctx->error == X509_V_ERR_PATH_LENGTH_EXCEEDED) ok=1; 346 if (ctx->error == X509_V_ERR_PATH_LENGTH_EXCEEDED) ok=1;
376 if (ctx->error == X509_V_ERR_INVALID_PURPOSE) ok=1; 347 if (ctx->error == X509_V_ERR_INVALID_PURPOSE) ok=1;
377 if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1; 348 if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1;
349 if (ctx->error == X509_V_ERR_CRL_HAS_EXPIRED) ok=1;
350 if (ctx->error == X509_V_ERR_CRL_NOT_YET_VALID) ok=1;
351 if (ctx->error == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION) ok=1;
378 } 352 }
379 if (!v_verbose) 353 if (!v_verbose)
380 ERR_clear_error(); 354 ERR_clear_error();
diff --git a/src/lib/libssl/src/apps/version.c b/src/lib/libssl/src/apps/version.c
index f5c9adc254..0cbcb47f88 100644
--- a/src/lib/libssl/src/apps/version.c
+++ b/src/lib/libssl/src/apps/version.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 <stdlib.h> 113#include <stdlib.h>
@@ -62,6 +115,21 @@
62#include "apps.h" 115#include "apps.h"
63#include <openssl/evp.h> 116#include <openssl/evp.h>
64#include <openssl/crypto.h> 117#include <openssl/crypto.h>
118#ifndef OPENSSL_NO_MD2
119# include <openssl/md2.h>
120#endif
121#ifndef OPENSSL_NO_RC4
122# include <openssl/rc4.h>
123#endif
124#ifndef OPENSSL_NO_DES
125# include <openssl/des.h>
126#endif
127#ifndef OPENSSL_NO_IDEA
128# include <openssl/idea.h>
129#endif
130#ifndef OPENSSL_NO_BF
131# include <openssl/blowfish.h>
132#endif
65 133
66#undef PROG 134#undef PROG
67#define PROG version_main 135#define PROG version_main
@@ -71,7 +139,7 @@ int MAIN(int, char **);
71int MAIN(int argc, char **argv) 139int MAIN(int argc, char **argv)
72 { 140 {
73 int i,ret=0; 141 int i,ret=0;
74 int cflags=0,version=0,date=0,options=0,platform=0; 142 int cflags=0,version=0,date=0,options=0,platform=0,dir=0;
75 143
76 apps_startup(); 144 apps_startup();
77 145
@@ -92,8 +160,10 @@ int MAIN(int argc, char **argv)
92 options=1; 160 options=1;
93 else if (strcmp(argv[i],"-p") == 0) 161 else if (strcmp(argv[i],"-p") == 0)
94 platform=1; 162 platform=1;
163 else if (strcmp(argv[i],"-d") == 0)
164 dir=1;
95 else if (strcmp(argv[i],"-a") == 0) 165 else if (strcmp(argv[i],"-a") == 0)
96 date=version=cflags=options=platform=1; 166 date=version=cflags=options=platform=dir=1;
97 else 167 else
98 { 168 {
99 BIO_printf(bio_err,"usage:version -[avbofp]\n"); 169 BIO_printf(bio_err,"usage:version -[avbofp]\n");
@@ -109,24 +179,26 @@ int MAIN(int argc, char **argv)
109 { 179 {
110 printf("options: "); 180 printf("options: ");
111 printf("%s ",BN_options()); 181 printf("%s ",BN_options());
112#ifndef NO_MD2 182#ifndef OPENSSL_NO_MD2
113 printf("%s ",MD2_options()); 183 printf("%s ",MD2_options());
114#endif 184#endif
115#ifndef NO_RC4 185#ifndef OPENSSL_NO_RC4
116 printf("%s ",RC4_options()); 186 printf("%s ",RC4_options());
117#endif 187#endif
118#ifndef NO_DES 188#ifndef OPENSSL_NO_DES
119 printf("%s ",des_options()); 189 printf("%s ",DES_options());
120#endif 190#endif
121#ifndef NO_IDEA 191#ifndef OPENSSL_NO_IDEA
122 printf("%s ",idea_options()); 192 printf("%s ",idea_options());
123#endif 193#endif
124#ifndef NO_BF 194#ifndef OPENSSL_NO_BF
125 printf("%s ",BF_options()); 195 printf("%s ",BF_options());
126#endif 196#endif
127 printf("\n"); 197 printf("\n");
128 } 198 }
129 if (cflags) printf("%s\n",SSLeay_version(SSLEAY_CFLAGS)); 199 if (cflags) printf("%s\n",SSLeay_version(SSLEAY_CFLAGS));
200 if (dir) printf("%s\n",SSLeay_version(SSLEAY_DIR));
130end: 201end:
202 apps_shutdown();
131 EXIT(ret); 203 EXIT(ret);
132 } 204 }
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c
index 95f05e580c..88386d6136 100644
--- a/src/lib/libssl/src/apps/x509.c
+++ b/src/lib/libssl/src/apps/x509.c
@@ -60,7 +60,7 @@
60#include <stdio.h> 60#include <stdio.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include <string.h> 62#include <string.h>
63#ifdef NO_STDIO 63#ifdef OPENSSL_NO_STDIO
64#define APPS_WIN16 64#define APPS_WIN16
65#endif 65#endif
66#include "apps.h" 66#include "apps.h"
@@ -73,7 +73,6 @@
73#include <openssl/x509v3.h> 73#include <openssl/x509v3.h>
74#include <openssl/objects.h> 74#include <openssl/objects.h>
75#include <openssl/pem.h> 75#include <openssl/pem.h>
76#include <openssl/engine.h>
77 76
78#undef PROG 77#undef PROG
79#define PROG x509_main 78#define PROG x509_main
@@ -106,6 +105,7 @@ static char *x509_usage[]={
106" -fingerprint - print the certificate fingerprint\n", 105" -fingerprint - print the certificate fingerprint\n",
107" -alias - output certificate alias\n", 106" -alias - output certificate alias\n",
108" -noout - no certificate output\n", 107" -noout - no certificate output\n",
108" -ocspid - print OCSP hash values for the subject name and public key\n",
109" -trustout - output a \"trusted\" certificate\n", 109" -trustout - output a \"trusted\" certificate\n",
110" -clrtrust - clear all trusted purposes\n", 110" -clrtrust - clear all trusted purposes\n",
111" -clrreject - clear all rejected purposes\n", 111" -clrreject - clear all rejected purposes\n",
@@ -123,6 +123,7 @@ static char *x509_usage[]={
123" missing, it is assumed to be in the CA file.\n", 123" missing, it is assumed to be in the CA file.\n",
124" -CAcreateserial - create serial number file if it does not exist\n", 124" -CAcreateserial - create serial number file if it does not exist\n",
125" -CAserial - serial file\n", 125" -CAserial - serial file\n",
126" -set_serial - serial number to use\n",
126" -text - print the certificate in text form\n", 127" -text - print the certificate in text form\n",
127" -C - print out C code forms\n", 128" -C - print out C code forms\n",
128" -md2/-md5/-sha1/-mdc2 - digest to use\n", 129" -md2/-md5/-sha1/-mdc2 - digest to use\n",
@@ -131,15 +132,17 @@ static char *x509_usage[]={
131" -clrext - delete extensions before signing and input certificate\n", 132" -clrext - delete extensions before signing and input certificate\n",
132" -nameopt arg - various certificate name options\n", 133" -nameopt arg - various certificate name options\n",
133" -engine e - use engine e, possibly a hardware device.\n", 134" -engine e - use engine e, possibly a hardware device.\n",
135" -certopt arg - various certificate text options\n",
134NULL 136NULL
135}; 137};
136 138
137static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx); 139static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx);
138static int sign (X509 *x, EVP_PKEY *pkey,int days,int clrext, const EVP_MD *digest, 140static int sign (X509 *x, EVP_PKEY *pkey,int days,int clrext, const EVP_MD *digest,
139 LHASH *conf, char *section); 141 CONF *conf, char *section);
140static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest, 142static int x509_certify (X509_STORE *ctx,char *CAfile,const EVP_MD *digest,
141 X509 *x,X509 *xca,EVP_PKEY *pkey,char *serial, 143 X509 *x,X509 *xca,EVP_PKEY *pkey,char *serial,
142 int create,int days, int clrext, LHASH *conf, char *section); 144 int create,int days, int clrext, CONF *conf, char *section,
145 ASN1_INTEGER *sno);
143static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt); 146static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
144static int reqfile=0; 147static int reqfile=0;
145 148
@@ -153,6 +156,7 @@ int MAIN(int argc, char **argv)
153 X509 *x=NULL,*xca=NULL; 156 X509 *x=NULL,*xca=NULL;
154 ASN1_OBJECT *objtmp; 157 ASN1_OBJECT *objtmp;
155 EVP_PKEY *Upkey=NULL,*CApkey=NULL; 158 EVP_PKEY *Upkey=NULL,*CApkey=NULL;
159 ASN1_INTEGER *sno = NULL;
156 int i,num,badops=0; 160 int i,num,badops=0;
157 BIO *out=NULL; 161 BIO *out=NULL;
158 BIO *STDout=NULL; 162 BIO *STDout=NULL;
@@ -162,6 +166,7 @@ int MAIN(int argc, char **argv)
162 char *CAkeyfile=NULL,*CAserial=NULL; 166 char *CAkeyfile=NULL,*CAserial=NULL;
163 char *alias=NULL; 167 char *alias=NULL;
164 int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0; 168 int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;
169 int ocspid=0;
165 int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0,email=0; 170 int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0,email=0;
166 int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0; 171 int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0;
167 int C=0; 172 int C=0;
@@ -173,11 +178,11 @@ int MAIN(int argc, char **argv)
173 int fingerprint=0; 178 int fingerprint=0;
174 char buf[256]; 179 char buf[256];
175 const EVP_MD *md_alg,*digest=EVP_md5(); 180 const EVP_MD *md_alg,*digest=EVP_md5();
176 LHASH *extconf = NULL; 181 CONF *extconf = NULL;
177 char *extsect = NULL, *extfile = NULL, *passin = NULL, *passargin = NULL; 182 char *extsect = NULL, *extfile = NULL, *passin = NULL, *passargin = NULL;
178 int need_rand = 0; 183 int need_rand = 0;
179 int checkend=0,checkoffset=0; 184 int checkend=0,checkoffset=0;
180 unsigned long nmflag = 0; 185 unsigned long nmflag = 0, certflag = 0;
181 char *engine=NULL; 186 char *engine=NULL;
182 187
183 reqfile=0; 188 reqfile=0;
@@ -186,8 +191,11 @@ int MAIN(int argc, char **argv)
186 191
187 if (bio_err == NULL) 192 if (bio_err == NULL)
188 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 193 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
194
195 if (!load_config(bio_err, NULL))
196 goto end;
189 STDout=BIO_new_fp(stdout,BIO_NOCLOSE); 197 STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
190#ifdef VMS 198#ifdef OPENSSL_SYS_VMS
191 { 199 {
192 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 200 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
193 STDout = BIO_push(tmpbio, STDout); 201 STDout = BIO_push(tmpbio, STDout);
@@ -298,6 +306,12 @@ int MAIN(int argc, char **argv)
298 if (--argc < 1) goto bad; 306 if (--argc < 1) goto bad;
299 CAserial= *(++argv); 307 CAserial= *(++argv);
300 } 308 }
309 else if (strcmp(*argv,"-set_serial") == 0)
310 {
311 if (--argc < 1) goto bad;
312 if (!(sno = s2i_ASN1_INTEGER(NULL, *(++argv))))
313 goto bad;
314 }
301 else if (strcmp(*argv,"-addtrust") == 0) 315 else if (strcmp(*argv,"-addtrust") == 0)
302 { 316 {
303 if (--argc < 1) goto bad; 317 if (--argc < 1) goto bad;
@@ -330,6 +344,11 @@ int MAIN(int argc, char **argv)
330 alias= *(++argv); 344 alias= *(++argv);
331 trustout = 1; 345 trustout = 1;
332 } 346 }
347 else if (strcmp(*argv,"-certopt") == 0)
348 {
349 if (--argc < 1) goto bad;
350 if (!set_cert_ex(&certflag, *(++argv))) goto bad;
351 }
333 else if (strcmp(*argv,"-nameopt") == 0) 352 else if (strcmp(*argv,"-nameopt") == 0)
334 { 353 {
335 if (--argc < 1) goto bad; 354 if (--argc < 1) goto bad;
@@ -406,6 +425,8 @@ int MAIN(int argc, char **argv)
406 clrext = 1; 425 clrext = 1;
407 } 426 }
408#endif 427#endif
428 else if (strcmp(*argv,"-ocspid") == 0)
429 ocspid= ++num;
409 else if ((md_alg=EVP_get_digestbyname(*argv + 1))) 430 else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
410 { 431 {
411 /* ok */ 432 /* ok */
@@ -425,27 +446,11 @@ int MAIN(int argc, char **argv)
425 { 446 {
426bad: 447bad:
427 for (pp=x509_usage; (*pp != NULL); pp++) 448 for (pp=x509_usage; (*pp != NULL); pp++)
428 BIO_printf(bio_err,*pp); 449 BIO_printf(bio_err,"%s",*pp);
429 goto end; 450 goto end;
430 } 451 }
431 452
432 if (engine != NULL) 453 e = setup_engine(bio_err, engine, 0);
433 {
434 if((e = ENGINE_by_id(engine)) == NULL)
435 {
436 BIO_printf(bio_err,"invalid engine \"%s\"\n",
437 engine);
438 goto end;
439 }
440 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
441 {
442 BIO_printf(bio_err,"can't use that engine\n");
443 goto end;
444 }
445 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
446 /* Free our "structural" reference. */
447 ENGINE_free(e);
448 }
449 454
450 if (need_rand) 455 if (need_rand)
451 app_RAND_load_file(NULL, bio_err, 0); 456 app_RAND_load_file(NULL, bio_err, 0);
@@ -476,7 +481,8 @@ bad:
476 { 481 {
477 long errorline; 482 long errorline;
478 X509V3_CTX ctx2; 483 X509V3_CTX ctx2;
479 if (!(extconf=CONF_load(NULL,extfile,&errorline))) 484 extconf = NCONF_new(NULL);
485 if (!NCONF_load(extconf, extfile,&errorline))
480 { 486 {
481 if (errorline <= 0) 487 if (errorline <= 0)
482 BIO_printf(bio_err, 488 BIO_printf(bio_err,
@@ -488,11 +494,18 @@ bad:
488 ,errorline,extfile); 494 ,errorline,extfile);
489 goto end; 495 goto end;
490 } 496 }
491 if (!extsect && !(extsect = CONF_get_string(extconf, "default", 497 if (!extsect)
492 "extensions"))) extsect = "default"; 498 {
499 extsect = NCONF_get_string(extconf, "default", "extensions");
500 if (!extsect)
501 {
502 ERR_clear_error();
503 extsect = "default";
504 }
505 }
493 X509V3_set_ctx_test(&ctx2); 506 X509V3_set_ctx_test(&ctx2);
494 X509V3_set_conf_lhash(&ctx2, extconf); 507 X509V3_set_nconf(&ctx2, extconf);
495 if (!X509V3_EXT_add_conf(extconf, &ctx2, extsect, NULL)) 508 if (!X509V3_EXT_add_nconf(extconf, &ctx2, extsect, NULL))
496 { 509 {
497 BIO_printf(bio_err, 510 BIO_printf(bio_err,
498 "Error Loading extension section %s\n", 511 "Error Loading extension section %s\n",
@@ -576,7 +589,12 @@ bad:
576 if ((x=X509_new()) == NULL) goto end; 589 if ((x=X509_new()) == NULL) goto end;
577 ci=x->cert_info; 590 ci=x->cert_info;
578 591
579 if (!ASN1_INTEGER_set(X509_get_serialNumber(x),0)) goto end; 592 if (sno)
593 {
594 if (!X509_set_serialNumber(x, sno))
595 goto end;
596 }
597 else if (!ASN1_INTEGER_set(X509_get_serialNumber(x),0)) goto end;
580 if (!X509_set_issuer_name(x,req->req_info->subject)) goto end; 598 if (!X509_set_issuer_name(x,req->req_info->subject)) goto end;
581 if (!X509_set_subject_name(x,req->req_info->subject)) goto end; 599 if (!X509_set_subject_name(x,req->req_info->subject)) goto end;
582 600
@@ -588,12 +606,12 @@ bad:
588 EVP_PKEY_free(pkey); 606 EVP_PKEY_free(pkey);
589 } 607 }
590 else 608 else
591 x=load_cert(bio_err,infile,informat); 609 x=load_cert(bio_err,infile,informat,NULL,e,"Certificate");
592 610
593 if (x == NULL) goto end; 611 if (x == NULL) goto end;
594 if (CA_flag) 612 if (CA_flag)
595 { 613 {
596 xca=load_cert(bio_err,CAfile,CAformat); 614 xca=load_cert(bio_err,CAfile,CAformat,NULL,e,"CA Certificate");
597 if (xca == NULL) goto end; 615 if (xca == NULL) goto end;
598 } 616 }
599 617
@@ -611,7 +629,7 @@ bad:
611 if (outfile == NULL) 629 if (outfile == NULL)
612 { 630 {
613 BIO_set_fp(out,stdout,BIO_NOCLOSE); 631 BIO_set_fp(out,stdout,BIO_NOCLOSE);
614#ifdef VMS 632#ifdef OPENSSL_SYS_VMS
615 { 633 {
616 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 634 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
617 out = BIO_push(tmpbio, out); 635 out = BIO_push(tmpbio, out);
@@ -715,12 +733,12 @@ bad:
715 goto end; 733 goto end;
716 } 734 }
717 BIO_printf(STDout,"Modulus="); 735 BIO_printf(STDout,"Modulus=");
718#ifndef NO_RSA 736#ifndef OPENSSL_NO_RSA
719 if (pkey->type == EVP_PKEY_RSA) 737 if (pkey->type == EVP_PKEY_RSA)
720 BN_print(STDout,pkey->pkey.rsa->n); 738 BN_print(STDout,pkey->pkey.rsa->n);
721 else 739 else
722#endif 740#endif
723#ifndef NO_DSA 741#ifndef OPENSSL_NO_DSA
724 if (pkey->type == EVP_PKEY_DSA) 742 if (pkey->type == EVP_PKEY_DSA)
725 BN_print(STDout,pkey->pkey.dsa->pub_key); 743 BN_print(STDout,pkey->pkey.dsa->pub_key);
726 else 744 else
@@ -801,7 +819,7 @@ bad:
801 } 819 }
802 else if (text == i) 820 else if (text == i)
803 { 821 {
804 X509_print(out,x); 822 X509_print_ex(out,x,nmflag, certflag);
805 } 823 }
806 else if (startdate == i) 824 else if (startdate == i)
807 { 825 {
@@ -843,10 +861,11 @@ bad:
843 if (Upkey == NULL) 861 if (Upkey == NULL)
844 { 862 {
845 Upkey=load_key(bio_err, 863 Upkey=load_key(bio_err,
846 keyfile,keyformat, passin); 864 keyfile,keyformat, passin, e,
865 "Private key");
847 if (Upkey == NULL) goto end; 866 if (Upkey == NULL) goto end;
848 } 867 }
849#ifndef NO_DSA 868#ifndef OPENSSL_NO_DSA
850 if (Upkey->type == EVP_PKEY_DSA) 869 if (Upkey->type == EVP_PKEY_DSA)
851 digest=EVP_dss1(); 870 digest=EVP_dss1();
852#endif 871#endif
@@ -861,10 +880,11 @@ bad:
861 if (CAkeyfile != NULL) 880 if (CAkeyfile != NULL)
862 { 881 {
863 CApkey=load_key(bio_err, 882 CApkey=load_key(bio_err,
864 CAkeyfile,CAkeyformat, passin); 883 CAkeyfile,CAkeyformat, passin,
884 e, "CA Private Key");
865 if (CApkey == NULL) goto end; 885 if (CApkey == NULL) goto end;
866 } 886 }
867#ifndef NO_DSA 887#ifndef OPENSSL_NO_DSA
868 if (CApkey->type == EVP_PKEY_DSA) 888 if (CApkey->type == EVP_PKEY_DSA)
869 digest=EVP_dss1(); 889 digest=EVP_dss1();
870#endif 890#endif
@@ -872,7 +892,7 @@ bad:
872 assert(need_rand); 892 assert(need_rand);
873 if (!x509_certify(ctx,CAfile,digest,x,xca, 893 if (!x509_certify(ctx,CAfile,digest,x,xca,
874 CApkey, CAserial,CA_createserial,days, clrext, 894 CApkey, CAserial,CA_createserial,days, clrext,
875 extconf, extsect)) 895 extconf, extsect, sno))
876 goto end; 896 goto end;
877 } 897 }
878 else if (x509req == i) 898 else if (x509req == i)
@@ -888,16 +908,15 @@ bad:
888 else 908 else
889 { 909 {
890 pk=load_key(bio_err, 910 pk=load_key(bio_err,
891 keyfile,FORMAT_PEM, passin); 911 keyfile,FORMAT_PEM, passin, e,
912 "request key");
892 if (pk == NULL) goto end; 913 if (pk == NULL) goto end;
893 } 914 }
894 915
895 BIO_printf(bio_err,"Generating certificate request\n"); 916 BIO_printf(bio_err,"Generating certificate request\n");
896 917
897#ifndef NO_DSA
898 if (pk->type == EVP_PKEY_DSA) 918 if (pk->type == EVP_PKEY_DSA)
899 digest=EVP_dss1(); 919 digest=EVP_dss1();
900#endif
901 920
902 rq=X509_to_X509_REQ(x,pk,digest); 921 rq=X509_to_X509_REQ(x,pk,digest);
903 EVP_PKEY_free(pk); 922 EVP_PKEY_free(pk);
@@ -913,6 +932,10 @@ bad:
913 } 932 }
914 noout=1; 933 noout=1;
915 } 934 }
935 else if (ocspid == i)
936 {
937 X509_ocspid_print(out, x);
938 }
916 } 939 }
917 } 940 }
918 941
@@ -975,7 +998,7 @@ end:
975 if (need_rand) 998 if (need_rand)
976 app_RAND_write_file(NULL, bio_err); 999 app_RAND_write_file(NULL, bio_err);
977 OBJ_cleanup(); 1000 OBJ_cleanup();
978 CONF_free(extconf); 1001 NCONF_free(extconf);
979 BIO_free_all(out); 1002 BIO_free_all(out);
980 BIO_free_all(STDout); 1003 BIO_free_all(STDout);
981 X509_STORE_free(ctx); 1004 X509_STORE_free(ctx);
@@ -985,32 +1008,23 @@ end:
985 EVP_PKEY_free(Upkey); 1008 EVP_PKEY_free(Upkey);
986 EVP_PKEY_free(CApkey); 1009 EVP_PKEY_free(CApkey);
987 X509_REQ_free(rq); 1010 X509_REQ_free(rq);
1011 ASN1_INTEGER_free(sno);
988 sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free); 1012 sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
989 sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); 1013 sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
990 if (passin) OPENSSL_free(passin); 1014 if (passin) OPENSSL_free(passin);
1015 apps_shutdown();
991 EXIT(ret); 1016 EXIT(ret);
992 } 1017 }
993 1018
994static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, 1019static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create)
995 X509 *x, X509 *xca, EVP_PKEY *pkey, char *serialfile, int create,
996 int days, int clrext, LHASH *conf, char *section)
997 { 1020 {
998 int ret=0; 1021 char *buf = NULL, *p;
999 BIO *io=NULL;
1000 MS_STATIC char buf2[1024]; 1022 MS_STATIC char buf2[1024];
1001 char *buf=NULL,*p; 1023 ASN1_INTEGER *bs = NULL, *bs2 = NULL;
1002 BIGNUM *serial=NULL; 1024 BIO *io = NULL;
1003 ASN1_INTEGER *bs=NULL,bs2; 1025 BIGNUM *serial = NULL;
1004 X509_STORE_CTX xsc;
1005 EVP_PKEY *upkey;
1006 1026
1007 upkey = X509_get_pubkey(xca); 1027 buf=OPENSSL_malloc( ((serialfile == NULL)
1008 EVP_PKEY_copy_parameters(upkey,pkey);
1009 EVP_PKEY_free(upkey);
1010
1011 X509_STORE_CTX_init(&xsc,ctx,x,NULL);
1012 buf=OPENSSL_malloc(EVP_PKEY_size(pkey)*2+
1013 ((serialfile == NULL)
1014 ?(strlen(CAfile)+strlen(POSTFIX)+1) 1028 ?(strlen(CAfile)+strlen(POSTFIX)+1)
1015 :(strlen(serialfile)))+1); 1029 :(strlen(serialfile)))+1);
1016 if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; } 1030 if (buf == NULL) { BIO_printf(bio_err,"out of mem\n"); goto end; }
@@ -1076,20 +1090,55 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
1076 1090
1077 if (!BN_add_word(serial,1)) 1091 if (!BN_add_word(serial,1))
1078 { BIO_printf(bio_err,"add_word failure\n"); goto end; } 1092 { BIO_printf(bio_err,"add_word failure\n"); goto end; }
1079 bs2.data=(unsigned char *)buf2; 1093 if (!(bs2 = BN_to_ASN1_INTEGER(serial, NULL)))
1080 bs2.length=BN_bn2bin(serial,bs2.data); 1094 { BIO_printf(bio_err,"error converting bn 2 asn1_integer\n"); goto end; }
1081
1082 if (BIO_write_filename(io,buf) <= 0) 1095 if (BIO_write_filename(io,buf) <= 0)
1083 { 1096 {
1084 BIO_printf(bio_err,"error attempting to write serial number file\n"); 1097 BIO_printf(bio_err,"error attempting to write serial number file\n");
1085 perror(buf); 1098 perror(buf);
1086 goto end; 1099 goto end;
1087 } 1100 }
1088 i2a_ASN1_INTEGER(io,&bs2); 1101 i2a_ASN1_INTEGER(io,bs2);
1089 BIO_puts(io,"\n"); 1102 BIO_puts(io,"\n");
1103
1090 BIO_free(io); 1104 BIO_free(io);
1105 if (buf) OPENSSL_free(buf);
1106 ASN1_INTEGER_free(bs2);
1107 BN_free(serial);
1091 io=NULL; 1108 io=NULL;
1092 1109 return bs;
1110
1111 end:
1112 if (buf) OPENSSL_free(buf);
1113 BIO_free(io);
1114 ASN1_INTEGER_free(bs);
1115 BN_free(serial);
1116 return NULL;
1117
1118 }
1119
1120static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
1121 X509 *x, X509 *xca, EVP_PKEY *pkey, char *serialfile, int create,
1122 int days, int clrext, CONF *conf, char *section, ASN1_INTEGER *sno)
1123 {
1124 int ret=0;
1125 ASN1_INTEGER *bs=NULL;
1126 X509_STORE_CTX xsc;
1127 EVP_PKEY *upkey;
1128
1129 upkey = X509_get_pubkey(xca);
1130 EVP_PKEY_copy_parameters(upkey,pkey);
1131 EVP_PKEY_free(upkey);
1132
1133 if(!X509_STORE_CTX_init(&xsc,ctx,x,NULL))
1134 {
1135 BIO_printf(bio_err,"Error initialising X509 store\n");
1136 goto end;
1137 }
1138 if (sno) bs = sno;
1139 else if (!(bs = load_serial(CAfile, serialfile, create)))
1140 goto end;
1141
1093 if (!X509_STORE_add_cert(ctx,x)) goto end; 1142 if (!X509_STORE_add_cert(ctx,x)) goto end;
1094 1143
1095 /* NOTE: this certificate can/should be self signed, unless it was 1144 /* NOTE: this certificate can/should be self signed, unless it was
@@ -1124,8 +1173,8 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
1124 X509V3_CTX ctx2; 1173 X509V3_CTX ctx2;
1125 X509_set_version(x,2); /* version 3 certificate */ 1174 X509_set_version(x,2); /* version 3 certificate */
1126 X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0); 1175 X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);
1127 X509V3_set_conf_lhash(&ctx2, conf); 1176 X509V3_set_nconf(&ctx2, conf);
1128 if (!X509V3_EXT_add_conf(conf, &ctx2, section, x)) goto end; 1177 if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end;
1129 } 1178 }
1130 1179
1131 if (!X509_sign(x,pkey,digest)) goto end; 1180 if (!X509_sign(x,pkey,digest)) goto end;
@@ -1134,10 +1183,7 @@ end:
1134 X509_STORE_CTX_cleanup(&xsc); 1183 X509_STORE_CTX_cleanup(&xsc);
1135 if (!ret) 1184 if (!ret)
1136 ERR_print_errors(bio_err); 1185 ERR_print_errors(bio_err);
1137 if (buf != NULL) OPENSSL_free(buf); 1186 if (!sno) ASN1_INTEGER_free(bs);
1138 if (bs != NULL) ASN1_INTEGER_free(bs);
1139 if (io != NULL) BIO_free(io);
1140 if (serial != NULL) BN_free(serial);
1141 return ret; 1187 return ret;
1142 } 1188 }
1143 1189
@@ -1174,7 +1220,7 @@ static int MS_CALLBACK callb(int ok, X509_STORE_CTX *ctx)
1174 1220
1175/* self sign */ 1221/* self sign */
1176static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest, 1222static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,
1177 LHASH *conf, char *section) 1223 CONF *conf, char *section)
1178 { 1224 {
1179 1225
1180 EVP_PKEY *pktmp; 1226 EVP_PKEY *pktmp;
@@ -1204,8 +1250,8 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *dig
1204 X509V3_CTX ctx; 1250 X509V3_CTX ctx;
1205 X509_set_version(x,2); /* version 3 certificate */ 1251 X509_set_version(x,2); /* version 3 certificate */
1206 X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0); 1252 X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
1207 X509V3_set_conf_lhash(&ctx, conf); 1253 X509V3_set_nconf(&ctx, conf);
1208 if (!X509V3_EXT_add_conf(conf, &ctx, section, x)) goto err; 1254 if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;
1209 } 1255 }
1210 if (!X509_sign(x,pkey,digest)) goto err; 1256 if (!X509_sign(x,pkey,digest)) goto err;
1211 return 1; 1257 return 1;
@@ -1230,6 +1276,3 @@ static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt)
1230 } 1276 }
1231 return 1; 1277 return 1;
1232} 1278}
1233
1234
1235
diff --git a/src/lib/libssl/src/bugs/stream.c b/src/lib/libssl/src/bugs/stream.c
index d2967c837d..c3b5e867d2 100644
--- a/src/lib/libssl/src/bugs/stream.c
+++ b/src/lib/libssl/src/bugs/stream.c
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/rc4.h> 60#include <openssl/rc4.h>
61#ifdef NO_DES 61#ifdef OPENSSL_NO_DES
62#include <des.h> 62#include <des.h>
63#else 63#else
64#include <openssl/des.h> 64#include <openssl/des.h>
diff --git a/src/lib/libssl/src/certs/RegTP-4R.pem b/src/lib/libssl/src/certs/RegTP-4R.pem
new file mode 100644
index 0000000000..6f2c6abccd
--- /dev/null
+++ b/src/lib/libssl/src/certs/RegTP-4R.pem
@@ -0,0 +1,19 @@
1issuer= CN=4R-CA 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
2notBefore=Jan 21 16:04:53 1999 GMT
3notAfter=Jan 21 16:04:53 2004 GMT
4subject= CN=4R-CA 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
5-----BEGIN CERTIFICATE-----
6MIICZzCCAdOgAwIBAgIEOwVn1DAKBgYrJAMDAQIFADBvMQswCQYDVQQGEwJERTE9
7MDsGA1UEChQ0UmVndWxpZXJ1bmdzYmVoyG9yZGUgZsh1ciBUZWxla29tbXVuaWth
8dGlvbiB1bmQgUG9zdDEhMAwGBwKCBgEKBxQTATEwEQYDVQQDFAo0Ui1DQSAxOlBO
9MCIYDzE5OTkwMTIxMTYwNDUzWhgPMjAwNDAxMjExNjA0NTNaMG8xCzAJBgNVBAYT
10AkRFMT0wOwYDVQQKFDRSZWd1bGllcnVuZ3NiZWjIb3JkZSBmyHVyIFRlbGVrb21t
11dW5pa2F0aW9uIHVuZCBQb3N0MSEwDAYHAoIGAQoHFBMBMTARBgNVBAMUCjRSLUNB
12IDE6UE4wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGAjzHbq2asUlqeWbXTQHso
13aVF6YIPVH3c/B2cbuy9HJ/lnE6x0asOzM2DGDqi47xkdAxPc0LZ0fxO87rkmz7xs
14jJObnVrMXpyUSDSp5Y0wqKJdsFdr6mGFOQZteIti8AJnr8xMkwnWVyuOlEXsFe1h
155gxwQXrOcPinE6qu1t/3PmECBMAAAAGjEjAQMA4GA1UdDwEB/wQEAwIBBjAKBgYr
16JAMDAQIFAAOBgQA+RdocBmA2VV9E5aKPBcp01tdZAvvW9Tve3docArVKR/4/yvSX
17Z+wvzzk+uu4qBp49HN3nqPYMrzbTmjBFu4ce5fkZ7dHF0W1sSBL0rox5z36Aq2re
18JjfEOEmSnNe0+opuh4FSVOssXblXTE8lEQU0FhhItgDx2ADnWZibaxLG4w==
19-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/RegTP-5R.pem b/src/lib/libssl/src/certs/RegTP-5R.pem
new file mode 100644
index 0000000000..9eb79aa17c
--- /dev/null
+++ b/src/lib/libssl/src/certs/RegTP-5R.pem
@@ -0,0 +1,19 @@
1issuer= CN=5R-CA 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
2notBefore=Mar 22 08:55:51 2000 GMT
3notAfter=Mar 22 08:55:51 2005 GMT
4subject= CN=5R-CA 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
5-----BEGIN CERTIFICATE-----
6MIICaDCCAdSgAwIBAgIDDIOqMAoGBiskAwMBAgUAMG8xCzAJBgNVBAYTAkRFMT0w
7OwYDVQQKFDRSZWd1bGllcnVuZ3NiZWjIb3JkZSBmyHVyIFRlbGVrb21tdW5pa2F0
8aW9uIHVuZCBQb3N0MSEwDAYHAoIGAQoHFBMBMTARBgNVBAMUCjVSLUNBIDE6UE4w
9IhgPMjAwMDAzMjIwODU1NTFaGA8yMDA1MDMyMjA4NTU1MVowbzELMAkGA1UEBhMC
10REUxPTA7BgNVBAoUNFJlZ3VsaWVydW5nc2JlaMhvcmRlIGbIdXIgVGVsZWtvbW11
11bmlrYXRpb24gdW5kIFBvc3QxITAMBgcCggYBCgcUEwExMBEGA1UEAxQKNVItQ0Eg
12MTpQTjCBoTANBgkqhkiG9w0BAQEFAAOBjwAwgYsCgYEAih5BUycfBpqKhU8RDsaS
13vV5AtzWeXQRColL9CH3t0DKnhjKAlJ8iccFtJNv+d3bh8bb9sh0maRSo647xP7hs
14HTjKgTE4zM5BYNfXvST79OtcMgAzrnDiGjQIIWv8xbfV1MqxxdtZJygrwzRMb9jG
15CAGoJEymoyzAMNG7tSdBWnUCBQDAAAABoxIwEDAOBgNVHQ8BAf8EBAMCAQYwCgYG
16KyQDAwECBQADgYEAOaK8ihVSBUcL2IdVBxZYYUKwMz5m7H3zqhN8W9w+iafWudH6
17b+aahkbENEwzg3C3v5g8nze7v7ssacQze657LHjP+e7ksUDIgcS4R1pU2eN16bjS
18P/qGPF3rhrIEHoK5nJULkjkZYTtNiOvmQ/+G70TXDi3Os/TwLlWRvu+7YLM=
19-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/RegTP-6R.pem b/src/lib/libssl/src/certs/RegTP-6R.pem
new file mode 100644
index 0000000000..4d79c74e5a
--- /dev/null
+++ b/src/lib/libssl/src/certs/RegTP-6R.pem
@@ -0,0 +1,19 @@
1issuer= CN=6R-Ca 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
2notBefore=Feb 1 09:52:17 2001 GMT
3notAfter=Jun 1 09:52:17 2005 GMT
4subject= CN=6R-Ca 1:PN+0.2.262.1.10.7.20=#130131,O=Regulierungsbeh\C3\88orde f\C3\88ur Telekommunikation und Post,C=DE
5-----BEGIN CERTIFICATE-----
6MIICaDCCAdSgAwIBAgIDMtGNMAoGBiskAwMBAgUAMG8xCzAJBgNVBAYTAkRFMT0w
7OwYDVQQKFDRSZWd1bGllcnVuZ3NiZWjIb3JkZSBmyHVyIFRlbGVrb21tdW5pa2F0
8aW9uIHVuZCBQb3N0MSEwDAYHAoIGAQoHFBMBMTARBgNVBAMUCjZSLUNhIDE6UE4w
9IhgPMjAwMTAyMDEwOTUyMTdaGA8yMDA1MDYwMTA5NTIxN1owbzELMAkGA1UEBhMC
10REUxPTA7BgNVBAoUNFJlZ3VsaWVydW5nc2JlaMhvcmRlIGbIdXIgVGVsZWtvbW11
11bmlrYXRpb24gdW5kIFBvc3QxITAMBgcCggYBCgcUEwExMBEGA1UEAxQKNlItQ2Eg
12MTpQTjCBoTANBgkqhkiG9w0BAQEFAAOBjwAwgYsCgYEAg6KrFSTNXKqe+2GKGeW2
13wTmbVeflNkp5H/YxA9K1zmEn5XjKm0S0jH4Wfms6ipPlURVaFwTfnB1s++AnJAWf
14mayaE9BP/pdIY6WtZGgW6aZc32VDMCMKPWyBNyagsJVDmzlakIA5cXBVa7Xqqd3P
15ew8i2feMnQXcqHfDv02CW88CBQDAAAABoxIwEDAOBgNVHQ8BAf8EBAMCAQYwCgYG
16KyQDAwECBQADgYEAOkqkUwdaTCt8wcJLA2zLuOwL5ADHMWLhv6gr5zEF+VckA6qe
17IVLVf8e7fYlRmzQd+5OJcGglCQJLGT+ZplI3Mjnrd4plkoTNKV4iOzBcvJD7K4tn
18XPvs9wCFcC7QU7PLvc1FDsAlr7e4wyefZRDL+wbqNfI7QZTSF1ubLd9AzeQ=
19-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/expired/rsa-ssca.pem b/src/lib/libssl/src/certs/expired/rsa-ssca.pem
new file mode 100644
index 0000000000..c9403212d1
--- /dev/null
+++ b/src/lib/libssl/src/certs/expired/rsa-ssca.pem
@@ -0,0 +1,19 @@
1subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
2issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
3notBefore=941109235417Z
4notAfter =991231235417Z
5-----BEGIN X509 CERTIFICATE-----
6
7MIICKTCCAZYCBQJBAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw
8HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl
9IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDkyMzU0MTda
10Fw05OTEyMzEyMzU0MTdaMF8xCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0
11YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJlIFNlcnZlciBDZXJ0aWZp
12Y2F0aW9uIEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCSznrB
13roM+WqqJg1esJQF2DK2ujiw3zus1eGRUA+WEQFHJv48I4oqCCNIWhjdV6bEhAq12
14aIGaBaJLyUslZiJWbIgHj/eBWW2EB2VwE3F2Ppt3TONQiVaYSLkdpykaEy5KEVmc
15HhXVSVQsczppgrGXOZxtcGdI5d0t1sgeewIDAQABMA0GCSqGSIb3DQEBAgUAA34A
16iNHReSHO4ovo+MF9NFM/YYPZtgs4F7boviGNjwC4i1N+RGceIr2XJ+CchcxK9oU7
17suK+ktPlDemvXA4MRpX/oRxePug2WHpzpgr4IhFrwwk4fia7c+8AvQKk8xQNMD9h
18cHsg/jKjn7P0Z1LctO6EjJY2IN6BCINxIYoPnqk=
19-----END X509 CERTIFICATE-----
diff --git a/src/lib/libssl/src/config b/src/lib/libssl/src/config
index d22836f80f..a7a40e04db 100644
--- a/src/lib/libssl/src/config
+++ b/src/lib/libssl/src/config
@@ -20,6 +20,31 @@
20# Be as similar to the output of config.guess/config.sub 20# Be as similar to the output of config.guess/config.sub
21# as possible. 21# as possible.
22 22
23PREFIX=""
24SUFFIX=""
25TEST="false"
26
27# pick up any command line args to config
28for i
29do
30case "$i" in
31-d*) PREFIX="debug-";;
32-t*) TEST="true";;
33-h*) TEST="true"; cat <<EOF
34Usage: config [options]
35 -d Add a debug- prefix to machine choice.
36 -t Test mode, do not run the Configure perl script.
37 -h This help.
38
39Any other text will be passed to the Configure perl script.
40See INSTALL for instructions.
41
42EOF
43;;
44*) options=$options" $i" ;;
45esac
46done
47
23# First get uname entries that we use below 48# First get uname entries that we use below
24 49
25MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown" 50MACHINE=`(uname -m) 2>/dev/null` || MACHINE="unknown"
@@ -68,6 +93,11 @@ if [ "x$XREL" != "x" ]; then
68 4.2) 93 4.2)
69 echo "whatever-whatever-unixware1"; exit 0 94 echo "whatever-whatever-unixware1"; exit 0
70 ;; 95 ;;
96 OpenUNIX)
97 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x8" ]; then
98 echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
99 fi
100 ;;
71 5) 101 5)
72 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then 102 if [ "`echo x$VERSION | sed -e 's/\..*//'`" = "x7" ]; then
73 echo "${MACHINE}-sco-unixware7"; exit 0 103 echo "${MACHINE}-sco-unixware7"; exit 0
@@ -110,10 +140,7 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
110 HP-UX:*) 140 HP-UX:*)
111 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'` 141 HPUXVER=`echo ${RELEASE}|sed -e 's/[^.]*.[0B]*//'`
112 case "$HPUXVER" in 142 case "$HPUXVER" in
113 11.*) 143 1[0-9].*) # HPUX 10 and 11 targets are unified
114 echo "${MACHINE}-hp-hpux11"; exit 0
115 ;;
116 10.*)
117 echo "${MACHINE}-hp-hpux10"; exit 0 144 echo "${MACHINE}-hp-hpux10"; exit 0
118 ;; 145 ;;
119 *) 146 *)
@@ -142,6 +169,10 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
142 echo "${MACHINE}-whatever-linux1"; exit 0 169 echo "${MACHINE}-whatever-linux1"; exit 0
143 ;; 170 ;;
144 171
172 GNU*)
173 echo "hurd-x86"; exit 0;
174 ;;
175
145 LynxOS:*) 176 LynxOS:*)
146 echo "${MACHINE}-lynx-lynxos"; exit 0 177 echo "${MACHINE}-lynx-lynxos"; exit 0
147 ;; 178 ;;
@@ -195,15 +226,33 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
195 echo "${MACHINE}-whatever-openbsd"; exit 0 226 echo "${MACHINE}-whatever-openbsd"; exit 0
196 ;; 227 ;;
197 228
229 OpenUNIX:*)
230 echo "${MACHINE}-unknown-OpenUNIX${VERSION}"; exit 0
231 ;;
232
198 OSF1:*:*:*alpha*) 233 OSF1:*:*:*alpha*)
199 echo "${MACHINE}-dec-osf"; exit 0 234 OSFMAJOR=`echo ${RELEASE}| sed -e 's/^V\([0-9]*\)\..*$/\1/'`
235 case "$OSFMAJOR" in
236 4|5)
237 echo "${MACHINE}-dec-tru64"; exit 0
238 ;;
239 1|2|3)
240 echo "${MACHINE}-dec-osf"; exit 0
241 ;;
242 *)
243 echo "${MACHINE}-dec-osf"; exit 0
244 ;;
245 esac
200 ;; 246 ;;
201 247
202 QNX:*) 248 QNX:*)
203 case "$VERSION" in 249 case "$RELEASE" in
204 4*) 250 4*)
205 echo "${MACHINE}-whatever-qnx4" 251 echo "${MACHINE}-whatever-qnx4"
206 ;; 252 ;;
253 6*)
254 echo "${MACHINE}-whatever-qnx6"
255 ;;
207 *) 256 *)
208 echo "${MACHINE}-whatever-qnx" 257 echo "${MACHINE}-whatever-qnx"
209 ;; 258 ;;
@@ -219,6 +268,18 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
219 echo "ppc-apple-rhapsody"; exit 0 268 echo "ppc-apple-rhapsody"; exit 0
220 ;; 269 ;;
221 270
271 Darwin:*)
272 case "$MACHINE" in
273 Power*)
274 echo "ppc-apple-darwin${VERSION}"
275 ;;
276 *)
277 echo "i386-apple-darwin${VERSION}"
278 ;;
279 esac
280 exit 0
281 ;;
282
222 SunOS:5.*) 283 SunOS:5.*)
223 echo "${MACHINE}-whatever-solaris2"; exit 0 284 echo "${MACHINE}-whatever-solaris2"; exit 0
224 ;; 285 ;;
@@ -271,6 +332,25 @@ case "${SYSTEM}:${RELEASE}:${VERSION}:${MACHINE}" in
271 echo "mips-sony-newsos4"; exit 0; 332 echo "mips-sony-newsos4"; exit 0;
272 ;; 333 ;;
273 334
335 CYGWIN*)
336 case "$RELEASE" in
337 [bB]*|1.0|1.[12].*)
338 echo "${MACHINE}-whatever-cygwin_pre1.3"
339 ;;
340 *)
341 echo "${MACHINE}-whatever-cygwin"
342 ;;
343 esac
344 exit 0
345 ;;
346
347 *"CRAY T3E")
348 echo "t3e-cray-unicosmk"; exit 0;
349 ;;
350
351 *CRAY*)
352 echo "j90-cray-unicos"; exit 0;
353 ;;
274esac 354esac
275 355
276# 356#
@@ -308,31 +388,6 @@ exit 0
308# this is where the translation occurs into SSLeay terms 388# this is where the translation occurs into SSLeay terms
309# --------------------------------------------------------------------------- 389# ---------------------------------------------------------------------------
310 390
311PREFIX=""
312SUFFIX=""
313TEST="false"
314
315# pick up any command line args to config
316for i
317do
318case "$i" in
319-d*) PREFIX="debug-";;
320-t*) TEST="true";;
321-h*) TEST="true"; cat <<EOF
322Usage: config [options]
323 -d Add a debug- prefix to machine choice.
324 -t Test mode, do not run the Configure perl script.
325 -h This help.
326
327Any other text will be passed to the Configure perl script.
328See INSTALL for instructions.
329
330EOF
331;;
332*) options=$options" $i" ;;
333esac
334done
335
336# figure out if gcc is available and if so we use it otherwise 391# figure out if gcc is available and if so we use it otherwise
337# we fallback to whatever cc does on the system 392# we fallback to whatever cc does on the system
338GCCVER=`(gcc --version) 2>/dev/null` 393GCCVER=`(gcc --version) 2>/dev/null`
@@ -345,8 +400,18 @@ if [ "$GCCVER" != "" ]; then
345else 400else
346 CC=cc 401 CC=cc
347fi 402fi
403GCCVER=${GCCVER:-0}
348 404
349if [ "$SYSTEM" = "SunOS" ]; then 405if [ "$SYSTEM" = "SunOS" ]; then
406 if [ $GCCVER -ge 30 ]; then
407 # 64-bit ABI isn't officially supported in gcc 3.0, but it appears
408 # to be working, at the very least 'make test' passes...
409 if gcc -v -E -x c /dev/null 2>&1 | grep __arch64__ > /dev/null; then
410 GCC_ARCH="-m64"
411 else
412 GCC_ARCH="-m32"
413 fi
414 fi
350 # check for WorkShop C, expected output is "cc: blah-blah C x.x" 415 # check for WorkShop C, expected output is "cc: blah-blah C x.x"
351 CCVER=`(cc -V 2>&1) 2>/dev/null | \ 416 CCVER=`(cc -V 2>&1) 2>/dev/null | \
352 egrep -e '^cc: .* C [0-9]\.[0-9]' | \ 417 egrep -e '^cc: .* C [0-9]\.[0-9]' | \
@@ -377,7 +442,6 @@ if [ "${SYSTEM}-${MACHINE}" = "Linux-alpha" ]; then
377 fi 442 fi
378fi 443fi
379 444
380GCCVER=${GCCVER:-0}
381CCVER=${CCVER:-0} 445CCVER=${CCVER:-0}
382 446
383# read the output of the embedded GuessOS 447# read the output of the embedded GuessOS
@@ -410,8 +474,10 @@ case "$GUESSOS" in
410 mips4-sgi-irix64) 474 mips4-sgi-irix64)
411 echo "WARNING! If you wish to build 64-bit library, then you have to" 475 echo "WARNING! If you wish to build 64-bit library, then you have to"
412 echo " invoke './Configure irix64-mips4-$CC' *manually*." 476 echo " invoke './Configure irix64-mips4-$CC' *manually*."
413 echo " Type return if you want to continue, Ctrl-C to abort." 477 if [ "$TEST" = "false" ]; then
414 read waste < /dev/tty 478 echo " You have about 5 seconds to press Ctrl-C to abort."
479 (stty -icanon min 0 time 50; read waste) < /dev/tty
480 fi
415 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'` 481 CPU=`(hinv -t cpu) 2>/dev/null | sed 's/^CPU:[^R]*R\([0-9]*\).*/\1/'`
416 CPU=${CPU:-0} 482 CPU=${CPU:-0}
417 if [ $CPU -ge 5000 ]; then 483 if [ $CPU -ge 5000 ]; then
@@ -435,10 +501,27 @@ case "$GUESSOS" in
435 esac 501 esac
436 fi 502 fi
437 ;; 503 ;;
438 mips-*-linux?) OUT="linux-mips" ;; 504 mips-*-linux?)
505 cat >dummy.c <<EOF
506#include <stdio.h> /* for printf() prototype */
507 int main (argc, argv) int argc; char *argv[]; {
508#ifdef __MIPSEB__
509 printf ("linux-%s\n", argv[1]);
510#endif
511#ifdef __MIPSEL__
512 printf ("linux-%sel\n", argv[1]);
513#endif
514 return 0;
515}
516EOF
517 ${CC} -o dummy dummy.c && OUT=`./dummy ${MACHINE}`
518 rm dummy dummy.c
519 ;;
439 ppc-*-linux2) OUT="linux-ppc" ;; 520 ppc-*-linux2) OUT="linux-ppc" ;;
440 m68k-*-linux*) OUT="linux-m68k" ;; 521 m68k-*-linux*) OUT="linux-m68k" ;;
441 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;; 522 ppc-apple-rhapsody) OUT="rhapsody-ppc-cc" ;;
523 ppc-apple-darwin*) OUT="darwin-ppc-cc" ;;
524 i386-apple-darwin*) OUT="darwin-i386-cc" ;;
442 sparc64-*-linux2) 525 sparc64-*-linux2)
443 #Before we can uncomment following lines we have to wait at least 526 #Before we can uncomment following lines we have to wait at least
444 #till 64-bit glibc for SPARC is operational:-( 527 #till 64-bit glibc for SPARC is operational:-(
@@ -455,19 +538,76 @@ case "$GUESSOS" in
455 sun4d) OUT="linux-sparcv8" ;; 538 sun4d) OUT="linux-sparcv8" ;;
456 *) OUT="linux-sparcv7" ;; 539 *) OUT="linux-sparcv7" ;;
457 esac ;; 540 esac ;;
541 parisc-*-linux2)
542 CPUARCH=`awk '/cpu family/{print substr($5,1,3)}' /proc/cpuinfo`
543 CPUSCHEDULE=`awk '/^cpu.[ ]: PA/{print substr($3,3)}' /proc/cpuinfo`
544
545 # ??TODO ?? Model transformations
546 # 0. CPU Architecture for the 1.1 processor has letter suffixes. We strip that off
547 # assuming no further arch. identification will ever be used by GCC.
548 # 1. I'm most concerned about whether is a 7300LC is closer to a 7100 versus a 7100LC.
549 # 2. The variant 64-bit processors cause concern should GCC support explicit schedulers
550 # for these chips in the future.
551 # PA7300LC -> 7100LC (1.1)
552 # PA8200 -> 8000 (2.0)
553 # PA8500 -> 8000 (2.0)
554 # PA8600 -> 8000 (2.0)
555
556 CPUSCHEDULE=`echo $CPUSCHEDULE|sed -e 's/7300LC/7100LC/' -e 's/8?00/8000/'`
557 # Finish Model transformations
558
559 options="$options -mschedule=$CPUSCHEDULE -march=$CPUARCH"
560 OUT="linux-parisc" ;;
458 arm*-*-linux2) OUT="linux-elf-arm" ;; 561 arm*-*-linux2) OUT="linux-elf-arm" ;;
459 s390-*-linux2) OUT="linux-s390" ;; 562 s390-*-linux2) OUT="linux-s390" ;;
460 *-*-linux2) OUT="linux-elf" ;; 563 s390x-*-linux?) OUT="linux-s390x" ;;
564 *-*-linux2) OUT="linux-elf"
565 if [ "$GCCVER" -gt 28 ]; then
566 if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
567 OUT="linux-pentium"
568 fi
569 if grep '^model.*Pentium Pro' /proc/cpuinfo >/dev/null ; then
570 OUT="linux-ppro"
571 fi
572 if grep '^model.*K6' /proc/cpuinfo >/dev/null ; then
573 OUT="linux-k6"
574 fi
575 fi ;;
461 *-*-linux1) OUT="linux-aout" ;; 576 *-*-linux1) OUT="linux-aout" ;;
462 sun4u*-*-solaris2) 577 sun4u*-*-solaris2)
578 OUT="solaris-sparcv9-$CC"
463 ISA64=`(isalist) 2>/dev/null | grep sparcv9` 579 ISA64=`(isalist) 2>/dev/null | grep sparcv9`
464 if [ "$ISA64" != "" -a "$CC" = "cc" -a $CCVER -ge 50 ]; then 580 if [ "$ISA64" != "" ]; then
581 if [ "$CC" = "cc" -a $CCVER -ge 50 ]; then
465 echo "WARNING! If you wish to build 64-bit library, then you have to" 582 echo "WARNING! If you wish to build 64-bit library, then you have to"
466 echo " invoke './Configure solaris64-sparcv9-cc' *manually*." 583 echo " invoke './Configure solaris64-sparcv9-cc' *manually*."
467 echo " Type return if you want to continue, Ctrl-C to abort." 584 if [ "$TEST" = "false" ]; then
468 read waste < /dev/tty 585 echo " You have about 5 seconds to press Ctrl-C to abort."
586 (stty -icanon min 0 time 50; read waste) < /dev/tty
587 fi
588 elif [ "$CC" = "gcc" -a "$GCC_ARCH" = "-m64" ]; then
589 # $GCC_ARCH denotes default ABI chosen by compiler driver
590 # (first one found on the $PATH). I assume that user
591 # expects certain consistency with the rest of his builds
592 # and therefore switch over to 64-bit. <appro>
593 OUT="solaris64-sparcv9-gcc"
594 echo "WARNING! If you wish to build 32-bit library, then you have to"
595 echo " invoke './Configure solaris-sparcv9-gcc' *manually*."
596 if [ "$TEST" = "false" ]; then
597 echo " You have about 5 seconds to press Ctrl-C to abort."
598 (stty -icanon min 0 time 50; read waste) < /dev/tty
599 fi
600 elif [ "$GCC_ARCH" = "-m32" ]; then
601 echo "NOTICE! If you *know* that your GNU C supports 64-bit/V9 ABI"
602 echo " and wish to build 64-bit library, then you have to"
603 echo " invoke './Configure solaris64-sparcv9-gcc' *manually*."
604 if [ "$TEST" = "false" ]; then
605 echo " You have about 5 seconds to press Ctrl-C to abort."
606 (stty -icanon min 0 time 50; read waste) < /dev/tty
607 fi
608 fi
469 fi 609 fi
470 OUT="solaris-sparcv9-$CC" ;; 610 ;;
471 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;; 611 sun4m-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
472 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;; 612 sun4d-*-solaris2) OUT="solaris-sparcv8-$CC" ;;
473 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;; 613 sun4*-*-solaris2) OUT="solaris-sparcv7-$CC" ;;
@@ -485,7 +625,15 @@ case "$GUESSOS" in
485 vax*-*-openbsd) OUT="OpenBSD-vax" ;; 625 vax*-*-openbsd) OUT="OpenBSD-vax" ;;
486 *-*-openbsd) OUT="OpenBSD" ;; 626 *-*-openbsd) OUT="OpenBSD" ;;
487 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;; 627 *86*-*-bsdi4) OUT="bsdi-elf-gcc" ;;
488 *-*-osf) OUT="alpha-cc" ;; 628 *-*-osf) OUT="alphaold-cc" ;;
629 *-*-tru64) OUT="alpha-cc" ;;
630 *-*-OpenUNIX*)
631 if [ "$CC" = "gcc" ]; then
632 OUT="OpenUNIX-8-gcc"
633 else
634 OUT="OpenUNIX-8"
635 fi
636 ;;
489 *-*-unixware7) OUT="unixware-7" ;; 637 *-*-unixware7) OUT="unixware-7" ;;
490 *-*-UnixWare7) OUT="unixware-7" ;; 638 *-*-UnixWare7) OUT="unixware-7" ;;
491 *-*-Unixware7) OUT="unixware-7" ;; 639 *-*-Unixware7) OUT="unixware-7" ;;
@@ -498,13 +646,49 @@ case "$GUESSOS" in
498 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;; 646 BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
499 RM*-siemens-sysv4) OUT="ReliantUNIX" ;; 647 RM*-siemens-sysv4) OUT="ReliantUNIX" ;;
500 *-siemens-sysv4) OUT="SINIX" ;; 648 *-siemens-sysv4) OUT="SINIX" ;;
501 *-hpux1*) OUT="hpux-parisc-$CC" 649 *-hpux1*)
502 options="$options -D_REENTRANT" ;; 650 OUT="hpux-parisc-$CC"
651 KERNEL_BITS=`(getconf KERNEL_BITS) 2>/dev/null`
652 KERNEL_BITS=${KERNEL_BITS:-32}
653 CPU_VERSION=`(getconf CPU_VERSION) 2>/dev/null`
654 CPU_VERSION=${CPU_VERSION:-0}
655 # See <sys/unistd.h> for further info on CPU_VERSION.
656 if [ $CPU_VERSION -ge 768 ]; then # IA-64 CPU
657 echo "NOTICE! 64-bit is the only ABI currently operational on HP-UXi."
658 echo " Post request to openssl-dev@openssl.org for 32-bit support."
659 if [ "$TEST" = "false" ]; then
660 (stty -icanon min 0 time 50; read waste) < /dev/tty
661 fi
662 OUT="hpux64-ia64-cc"
663 elif [ $CPU_VERSION -ge 532 ]; then # PA-RISC 2.x CPU
664 if [ "$CC" = "cc" ]; then
665 OUT="hpux-parisc2-cc" # can't we have hpux-parisc2-gcc?
666 fi
667 if [ $KERNEL_BITS -eq 64 -a "$CC" = "cc" ]; then
668 echo "WARNING! If you wish to build 64-bit library then you have to"
669 echo " invoke './Configure hpux64-parisc2-cc' *manually*."
670 if [ "$TEST" = "false" ]; then
671 echo " You have about 5 seconds to press Ctrl-C to abort."
672 (stty -icanon min 0 time 50; read waste) < /dev/tty
673 fi
674 fi
675 elif [ $CPU_VERSION -ge 528 ]; then # PA-RISC 1.1+ CPU
676 :
677 elif [ $CPU_VERSION -ge 523 ]; then # PA-RISC 1.0 CPU
678 :
679 else # Motorola(?) CPU
680 OUT="hpux-$CC"
681 fi
682 options="$options -D_REENTRANT" ;;
503 *-hpux) OUT="hpux-parisc-$CC" ;; 683 *-hpux) OUT="hpux-parisc-$CC" ;;
504 # these are all covered by the catchall below 684 # these are all covered by the catchall below
505 # *-aix) OUT="aix-$CC" ;; 685 # *-aix) OUT="aix-$CC" ;;
506 # *-dgux) OUT="dgux" ;; 686 # *-dgux) OUT="dgux" ;;
507 mips-sony-newsos4) OUT="newsos4-gcc" ;; 687 mips-sony-newsos4) OUT="newsos4-gcc" ;;
688 *-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
689 *-*-cygwin) OUT="Cygwin" ;;
690 t3e-cray-unicosmk) OUT="cray-t3e" ;;
691 j90-cray-unicos) OUT="cray-j90" ;;
508 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; 692 *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;;
509esac 693esac
510 694
@@ -539,7 +723,7 @@ case "$GUESSOS" in
539 i386-*) options="$options 386" ;; 723 i386-*) options="$options 386" ;;
540esac 724esac
541 725
542for i in bf cast des dh dsa hmac md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha 726for i in bf cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 rijndael ripemd rsa sha
543do 727do
544 if [ ! -d crypto/$i ] 728 if [ ! -d crypto/$i ]
545 then 729 then
@@ -547,6 +731,27 @@ do
547 fi 731 fi
548done 732done
549 733
734# Discover Kerberos 5 (since it's still a prototype, we don't
735# do any guesses yet, that's why this section is commented away.
736#if [ -d /usr/kerberos ]; then
737# krb5_dir=/usr/kerberos
738# if [ \( -f $krb5_dir/lib/libgssapi_krb5.a -o -f $krb5_dir/lib/libgssapi_krb5.so* \)\
739# -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
740# -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
741# -a \( -f $krb5_dir/lib/libk5crypto.a -o -f $krb5_dir/lib/libk5crypto.so* \)\
742# -a \( -f $krb5_dir/include/krb5.h \) ]; then
743# options="$options --with-krb5-flavor=MIT"
744# fi
745#elif [ -d /usr/heimdal ]; then
746# krb5_dir=/usr/heimdal
747# if [ \( -f $krb5_dir/lib/libgssapi.a -o -f $krb5_dir/lib/libgssapi.so* \)\
748# -a \( -f $krb5_dir/lib/libkrb5.a -o -f $krb5_dir/lib/libkrb5.so* \)\
749# -a \( -f $krb5_dir/lib/libcom_err.a -o -f $krb5_dir/lib/libcom_err.so* \)\
750# -a \( -f $krb5_dir/include/krb5.h \) ]; then
751# options="$options --with-krb5-flavor=Heimdal"
752# fi
753#fi
754
550if [ -z "$OUT" ]; then 755if [ -z "$OUT" ]; then
551 OUT="$CC" 756 OUT="$CC"
552fi 757fi
diff --git a/src/lib/libssl/src/crypto/Makefile.ssl b/src/lib/libssl/src/crypto/Makefile.ssl
index 6759b2e4d0..9d1a180571 100644
--- a/src/lib/libssl/src/crypto/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/Makefile.ssl b/src/lib/libssl/src/crypto/aes/Makefile.ssl
new file mode 100644
index 0000000000..c189ce0824
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/README b/src/lib/libssl/src/crypto/aes/README
new file mode 100644
index 0000000000..0f9620a80e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes.h b/src/lib/libssl/src/crypto/aes/aes.h
new file mode 100644
index 0000000000..e8da921ec5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_cbc.c b/src/lib/libssl/src/crypto/aes/aes_cbc.c
new file mode 100644
index 0000000000..3dfd7aba2a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_cfb.c b/src/lib/libssl/src/crypto/aes/aes_cfb.c
new file mode 100644
index 0000000000..9b2917298a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_core.c b/src/lib/libssl/src/crypto/aes/aes_core.c
new file mode 100644
index 0000000000..937988dd8c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ctr.c b/src/lib/libssl/src/crypto/aes/aes_ctr.c
new file mode 100644
index 0000000000..8e800481de
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ecb.c b/src/lib/libssl/src/crypto/aes/aes_ecb.c
new file mode 100644
index 0000000000..1cb2e07d3d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_locl.h b/src/lib/libssl/src/crypto/aes/aes_locl.h
new file mode 100644
index 0000000000..541d1d6e84
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_misc.c b/src/lib/libssl/src/crypto/aes/aes_misc.c
new file mode 100644
index 0000000000..090def25d5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/aes/aes_ofb.c b/src/lib/libssl/src/crypto/aes/aes_ofb.c
new file mode 100644
index 0000000000..e33bdaea28
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/Makefile.ssl b/src/lib/libssl/src/crypto/asn1/Makefile.ssl
index dace5be2bc..b423419ba3 100644
--- a/src/lib/libssl/src/crypto/asn1/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_bitstr.c b/src/lib/libssl/src/crypto/asn1/a_bitstr.c
index 7013a407ad..c36817c1ee 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bitstr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_bool.c b/src/lib/libssl/src/crypto/asn1/a_bool.c
index 18fa61840b..24333ea4d5 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bool.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_bytes.c b/src/lib/libssl/src/crypto/asn1/a_bytes.c
index 3a0c0c7835..bb88660f58 100644
--- a/src/lib/libssl/src/crypto/asn1/a_bytes.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_d2i_fp.c b/src/lib/libssl/src/crypto/asn1/a_d2i_fp.c
index a49d1cb289..a80fbe9ff7 100644
--- a/src/lib/libssl/src/crypto/asn1/a_d2i_fp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_digest.c b/src/lib/libssl/src/crypto/asn1/a_digest.c
index 8257b8639e..4931e222a0 100644
--- a/src/lib/libssl/src/crypto/asn1/a_digest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_dup.c b/src/lib/libssl/src/crypto/asn1/a_dup.c
index c3bda58a5d..58a017884c 100644
--- a/src/lib/libssl/src/crypto/asn1/a_dup.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_enum.c b/src/lib/libssl/src/crypto/asn1/a_enum.c
index 1428d1df7a..8a315fa371 100644
--- a/src/lib/libssl/src/crypto/asn1/a_enum.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_gentm.c b/src/lib/libssl/src/crypto/asn1/a_gentm.c
index 314479a03d..cd09f68b38 100644
--- a/src/lib/libssl/src/crypto/asn1/a_gentm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_i2d_fp.c b/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c
index aee29a7790..f4f1b73ebe 100644
--- a/src/lib/libssl/src/crypto/asn1/a_i2d_fp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_int.c b/src/lib/libssl/src/crypto/asn1/a_int.c
index 6f0413f885..496704b9a5 100644
--- a/src/lib/libssl/src/crypto/asn1/a_int.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_object.c b/src/lib/libssl/src/crypto/asn1/a_object.c
index 20caa2d3bd..71ce7c3896 100644
--- a/src/lib/libssl/src/crypto/asn1/a_object.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_octet.c b/src/lib/libssl/src/crypto/asn1/a_octet.c
index 2586f4327d..9690bae0f1 100644
--- a/src/lib/libssl/src/crypto/asn1/a_octet.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_print.c b/src/lib/libssl/src/crypto/asn1/a_print.c
index b7bd2bd18a..8035513f04 100644
--- a/src/lib/libssl/src/crypto/asn1/a_print.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_set.c b/src/lib/libssl/src/crypto/asn1/a_set.c
index caf5a1419c..19bb60fca8 100644
--- a/src/lib/libssl/src/crypto/asn1/a_set.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_sign.c b/src/lib/libssl/src/crypto/asn1/a_sign.c
index 4c651706d2..de53b44144 100644
--- a/src/lib/libssl/src/crypto/asn1/a_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_strex.c b/src/lib/libssl/src/crypto/asn1/a_strex.c
index 569b811998..128aa7e772 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strex.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_strnid.c b/src/lib/libssl/src/crypto/asn1/a_strnid.c
index 732e68fe46..04789d1c63 100644
--- a/src/lib/libssl/src/crypto/asn1/a_strnid.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_time.c b/src/lib/libssl/src/crypto/asn1/a_time.c
index 8c0ddee4ac..27ddd30899 100644
--- a/src/lib/libssl/src/crypto/asn1/a_time.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_type.c b/src/lib/libssl/src/crypto/asn1/a_type.c
index e72a6b29e0..96e111cf23 100644
--- a/src/lib/libssl/src/crypto/asn1/a_type.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_utctm.c b/src/lib/libssl/src/crypto/asn1/a_utctm.c
index d381c9e0d1..ed2d827db2 100644
--- a/src/lib/libssl/src/crypto/asn1/a_utctm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_utf8.c b/src/lib/libssl/src/crypto/asn1/a_utf8.c
index 854278f136..508e11e527 100644
--- a/src/lib/libssl/src/crypto/asn1/a_utf8.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/a_verify.c b/src/lib/libssl/src/crypto/asn1/a_verify.c
index 2a11927e5c..bf41de5146 100644
--- a/src/lib/libssl/src/crypto/asn1/a_verify.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1.h b/src/lib/libssl/src/crypto/asn1/asn1.h
index 6f956b1963..0d1713f8dd 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1_err.c b/src/lib/libssl/src/crypto/asn1/asn1_err.c
index cecd555c88..c4c3d2a91d 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1_lib.c b/src/lib/libssl/src/crypto/asn1/asn1_lib.c
index a8b651e54e..830ff2af3c 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1_mac.h b/src/lib/libssl/src/crypto/asn1/asn1_mac.h
index af0e664b2d..a48649ceeb 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1_mac.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn1t.h b/src/lib/libssl/src/crypto/asn1/asn1t.h
new file mode 100644
index 0000000000..ed372f8554
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn_moid.c b/src/lib/libssl/src/crypto/asn1/asn_moid.c
new file mode 100644
index 0000000000..be20db4bad
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/asn_pack.c b/src/lib/libssl/src/crypto/asn1/asn_pack.c
index bdf5f130b3..e6051db2dc 100644
--- a/src/lib/libssl/src/crypto/asn1/asn_pack.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/d2i_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_pr.c
index c92b8325d8..2e7d96af90 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_pr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/d2i_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_pu.c
index e0d203cef7..71f2eb361b 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_pu.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/f_int.c b/src/lib/libssl/src/crypto/asn1/f_int.c
index 6b090f6740..48cc3bfb90 100644
--- a/src/lib/libssl/src/crypto/asn1/f_int.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/i2d_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_pr.c
index 71d6910204..1e951ae01d 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_pr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/i2d_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_pu.c
index 8f73d37d03..013d19bbf4 100644
--- a/src/lib/libssl/src/crypto/asn1/i2d_pu.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/n_pkey.c b/src/lib/libssl/src/crypto/asn1/n_pkey.c
index 9840193538..49f80fffd2 100644
--- a/src/lib/libssl/src/crypto/asn1/n_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/nsseq.c b/src/lib/libssl/src/crypto/asn1/nsseq.c
index 6e7f09ba23..50e2d4d07a 100644
--- a/src/lib/libssl/src/crypto/asn1/nsseq.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/p5_pbe.c b/src/lib/libssl/src/crypto/asn1/p5_pbe.c
index b7ed538eb2..891150638e 100644
--- a/src/lib/libssl/src/crypto/asn1/p5_pbe.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/p5_pbev2.c b/src/lib/libssl/src/crypto/asn1/p5_pbev2.c
index 6a7b578c0e..43dfe09479 100644
--- a/src/lib/libssl/src/crypto/asn1/p5_pbev2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/p8_pkey.c b/src/lib/libssl/src/crypto/asn1/p8_pkey.c
index fa6cbfb6f8..b634d5bc85 100644
--- a/src/lib/libssl/src/crypto/asn1/p8_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_crl.c b/src/lib/libssl/src/crypto/asn1/t_crl.c
index d78e4a8f88..60db305756 100644
--- a/src/lib/libssl/src/crypto/asn1/t_crl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_pkey.c b/src/lib/libssl/src/crypto/asn1/t_pkey.c
index ae18da96e3..8060115202 100644
--- a/src/lib/libssl/src/crypto/asn1/t_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_req.c b/src/lib/libssl/src/crypto/asn1/t_req.c
index ea1af092db..848c29a2dd 100644
--- a/src/lib/libssl/src/crypto/asn1/t_req.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_spki.c b/src/lib/libssl/src/crypto/asn1/t_spki.c
index d708434fca..5abfbc815e 100644
--- a/src/lib/libssl/src/crypto/asn1/t_spki.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_x509.c b/src/lib/libssl/src/crypto/asn1/t_x509.c
index 89ae73a6de..5de4833ed0 100644
--- a/src/lib/libssl/src/crypto/asn1/t_x509.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/t_x509a.c b/src/lib/libssl/src/crypto/asn1/t_x509a.c
index f06af5b576..7d4a6e6084 100644
--- a/src/lib/libssl/src/crypto/asn1/t_x509a.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_dec.c b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
new file mode 100644
index 0000000000..0fc1f421e2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_enc.c b/src/lib/libssl/src/crypto/asn1/tasn_enc.c
new file mode 100644
index 0000000000..f6c8ddef0a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_fre.c b/src/lib/libssl/src/crypto/asn1/tasn_fre.c
new file mode 100644
index 0000000000..c7610776f2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c
new file mode 100644
index 0000000000..e33861f864
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_prn.c b/src/lib/libssl/src/crypto/asn1/tasn_prn.c
new file mode 100644
index 0000000000..fab67ae5ac
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_typ.c b/src/lib/libssl/src/crypto/asn1/tasn_typ.c
new file mode 100644
index 0000000000..804d2eeba2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/tasn_utl.c b/src/lib/libssl/src/crypto/asn1/tasn_utl.c
new file mode 100644
index 0000000000..8996ce8c13
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_algor.c b/src/lib/libssl/src/crypto/asn1/x_algor.c
index 853a8dfeef..00b9ea54a1 100644
--- a/src/lib/libssl/src/crypto/asn1/x_algor.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_attrib.c b/src/lib/libssl/src/crypto/asn1/x_attrib.c
index 14e5ea27aa..1e3713f18f 100644
--- a/src/lib/libssl/src/crypto/asn1/x_attrib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_bignum.c b/src/lib/libssl/src/crypto/asn1/x_bignum.c
new file mode 100644
index 0000000000..848c7a0877
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_crl.c b/src/lib/libssl/src/crypto/asn1/x_crl.c
index 51518cdf35..11fce96825 100644
--- a/src/lib/libssl/src/crypto/asn1/x_crl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_exten.c b/src/lib/libssl/src/crypto/asn1/x_exten.c
index fbfd963b40..702421b6c8 100644
--- a/src/lib/libssl/src/crypto/asn1/x_exten.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_info.c b/src/lib/libssl/src/crypto/asn1/x_info.c
index 5e62fc2f6f..d44f6cdb01 100644
--- a/src/lib/libssl/src/crypto/asn1/x_info.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_long.c b/src/lib/libssl/src/crypto/asn1/x_long.c
new file mode 100644
index 0000000000..c5f25956cb
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_name.c b/src/lib/libssl/src/crypto/asn1/x_name.c
index 1885d699ef..caece0f158 100644
--- a/src/lib/libssl/src/crypto/asn1/x_name.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_pubkey.c b/src/lib/libssl/src/crypto/asn1/x_pubkey.c
index 4397a404b5..55630294b6 100644
--- a/src/lib/libssl/src/crypto/asn1/x_pubkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_req.c b/src/lib/libssl/src/crypto/asn1/x_req.c
index 6dddd4f653..b3f18ebc12 100644
--- a/src/lib/libssl/src/crypto/asn1/x_req.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_sig.c b/src/lib/libssl/src/crypto/asn1/x_sig.c
index d79f147647..42efa86c1c 100644
--- a/src/lib/libssl/src/crypto/asn1/x_sig.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_spki.c b/src/lib/libssl/src/crypto/asn1/x_spki.c
index 4f01888f7d..2aece077c5 100644
--- a/src/lib/libssl/src/crypto/asn1/x_spki.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_val.c b/src/lib/libssl/src/crypto/asn1/x_val.c
index 0f8f020b57..dc17c67758 100644
--- a/src/lib/libssl/src/crypto/asn1/x_val.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_x509.c b/src/lib/libssl/src/crypto/asn1/x_x509.c
index 61ba856b17..b50167ce43 100644
--- a/src/lib/libssl/src/crypto/asn1/x_x509.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/asn1/x_x509a.c b/src/lib/libssl/src/crypto/asn1/x_x509a.c
index ebcce87bf2..f244768b7e 100644
--- a/src/lib/libssl/src/crypto/asn1/x_x509a.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/Makefile.ssl b/src/lib/libssl/src/crypto/bf/Makefile.ssl
index 9205ee7901..b045f54686 100644
--- a/src/lib/libssl/src/crypto/bf/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/bf_opts.c b/src/lib/libssl/src/crypto/bf/bf_opts.c
index bbe32b28c9..171dada2ca 100644
--- a/src/lib/libssl/src/crypto/bf/bf_opts.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/bf_skey.c b/src/lib/libssl/src/crypto/bf/bf_skey.c
index 4d6a232fe0..3673cdee6e 100644
--- a/src/lib/libssl/src/crypto/bf/bf_skey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/bfspeed.c b/src/lib/libssl/src/crypto/bf/bfspeed.c
index ecc9dff4e4..f346af64f3 100644
--- a/src/lib/libssl/src/crypto/bf/bfspeed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/bftest.c b/src/lib/libssl/src/crypto/bf/bftest.c
index cf67cadefd..09895f2542 100644
--- a/src/lib/libssl/src/crypto/bf/bftest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bf/blowfish.h b/src/lib/libssl/src/crypto/bf/blowfish.h
index 78acfd63b4..cd49e85ab2 100644
--- a/src/lib/libssl/src/crypto/bf/blowfish.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/Makefile.ssl b/src/lib/libssl/src/crypto/bio/Makefile.ssl
index 567d3fb870..de5631a105 100644
--- a/src/lib/libssl/src/crypto/bio/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c
index 91a049406e..b7e268f092 100644
--- a/src/lib/libssl/src/crypto/bio/b_print.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index 62cc3f1a0c..dcaef68ea7 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bf_buff.c b/src/lib/libssl/src/crypto/bio/bf_buff.c
index c90238bae1..6ccda06596 100644
--- a/src/lib/libssl/src/crypto/bio/bf_buff.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bf_lbuf.c b/src/lib/libssl/src/crypto/bio/bf_lbuf.c
index 7bcf8ed941..ec0f7eb0b7 100644
--- a/src/lib/libssl/src/crypto/bio/bf_lbuf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bf_nbio.c b/src/lib/libssl/src/crypto/bio/bf_nbio.c
index 413ef5c4c5..c193e9debf 100644
--- a/src/lib/libssl/src/crypto/bio/bf_nbio.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bf_null.c b/src/lib/libssl/src/crypto/bio/bf_null.c
index 2678a1a85d..c1bf39a904 100644
--- a/src/lib/libssl/src/crypto/bio/bf_null.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio.h b/src/lib/libssl/src/crypto/bio/bio.h
index 97003b503c..b122c7069d 100644
--- a/src/lib/libssl/src/crypto/bio/bio.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio_cb.c b/src/lib/libssl/src/crypto/bio/bio_cb.c
index 37c7c22666..0ffa4d2136 100644
--- a/src/lib/libssl/src/crypto/bio/bio_cb.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio_err.c b/src/lib/libssl/src/crypto/bio/bio_err.c
index bb815fb1e6..99ca3cd0da 100644
--- a/src/lib/libssl/src/crypto/bio/bio_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bio_lib.c b/src/lib/libssl/src/crypto/bio/bio_lib.c
index 381afc9b8e..50df2238fa 100644
--- a/src/lib/libssl/src/crypto/bio/bio_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_acpt.c b/src/lib/libssl/src/crypto/bio/bss_acpt.c
index 4da5822062..8ea1db158b 100644
--- a/src/lib/libssl/src/crypto/bio/bss_acpt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_bio.c b/src/lib/libssl/src/crypto/bio/bss_bio.c
index 78c6ab4fdd..a5da473031 100644
--- a/src/lib/libssl/src/crypto/bio/bss_bio.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_conn.c b/src/lib/libssl/src/crypto/bio/bss_conn.c
index a6b77a2cb9..f91ae4c8c6 100644
--- a/src/lib/libssl/src/crypto/bio/bss_conn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_fd.c b/src/lib/libssl/src/crypto/bio/bss_fd.c
index 686c4909a2..5e3e187de6 100644
--- a/src/lib/libssl/src/crypto/bio/bss_fd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c
index 1f770b390f..8b3ff278d9 100644
--- a/src/lib/libssl/src/crypto/bio/bss_file.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_log.c b/src/lib/libssl/src/crypto/bio/bss_log.c
index 1edf16a76f..a39d95297c 100644
--- a/src/lib/libssl/src/crypto/bio/bss_log.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bio/bss_sock.c b/src/lib/libssl/src/crypto/bio/bss_sock.c
index 50c6744c06..fdabd16d7e 100644
--- a/src/lib/libssl/src/crypto/bio/bss_sock.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/Makefile.ssl b/src/lib/libssl/src/crypto/bn/Makefile.ssl
index 526d7adb5c..eb6f0eeebd 100644
--- a/src/lib/libssl/src/crypto/bn/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/README b/src/lib/libssl/src/crypto/bn/asm/README
index a0fe58a677..b0f3a68a06 100644
--- a/src/lib/libssl/src/crypto/bn/asm/README
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/bn-586.pl b/src/lib/libssl/src/crypto/bn/asm/bn-586.pl
index 5191bed273..33f6125920 100644
--- a/src/lib/libssl/src/crypto/bn/asm/bn-586.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/ia64.S b/src/lib/libssl/src/crypto/bn/asm/ia64.S
new file mode 100644
index 0000000000..ae56066310
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/asm/vms.mar b/src/lib/libssl/src/crypto/bn/asm/vms.mar
index ac9d57d7b0..465f2774b6 100644
--- a/src/lib/libssl/src/crypto/bn/asm/vms.mar
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h
index b232c2ceae..d25b49c9d8 100644
--- a/src/lib/libssl/src/crypto/bn/bn.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_add.c b/src/lib/libssl/src/crypto/bn/bn_add.c
index 5d24691233..6cba07e9f6 100644
--- a/src/lib/libssl/src/crypto/bn/bn_add.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_asm.c b/src/lib/libssl/src/crypto/bn/bn_asm.c
index 44e52a40db..be8aa3ffc5 100644
--- a/src/lib/libssl/src/crypto/bn/bn_asm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_ctx.c b/src/lib/libssl/src/crypto/bn/bn_ctx.c
index b1a8d7571e..7daf19eb84 100644
--- a/src/lib/libssl/src/crypto/bn/bn_ctx.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_div.c b/src/lib/libssl/src/crypto/bn/bn_div.c
index c328b5b411..ac1a09615a 100644
--- a/src/lib/libssl/src/crypto/bn/bn_div.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_err.c b/src/lib/libssl/src/crypto/bn/bn_err.c
index adc6a214fc..fb84ee96d8 100644
--- a/src/lib/libssl/src/crypto/bn/bn_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_exp.c b/src/lib/libssl/src/crypto/bn/bn_exp.c
index d2c91628ac..afdfd580fb 100644
--- a/src/lib/libssl/src/crypto/bn/bn_exp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_exp2.c b/src/lib/libssl/src/crypto/bn/bn_exp2.c
index 29029f4c72..73ccd58a83 100644
--- a/src/lib/libssl/src/crypto/bn/bn_exp2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_gcd.c b/src/lib/libssl/src/crypto/bn/bn_gcd.c
index 398207196b..7649f63fd2 100644
--- a/src/lib/libssl/src/crypto/bn/bn_gcd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_kron.c b/src/lib/libssl/src/crypto/bn/bn_kron.c
new file mode 100644
index 0000000000..49f75594ae
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_lcl.h b/src/lib/libssl/src/crypto/bn/bn_lcl.h
index 9c959921b4..8a4dba375a 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lcl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c
index 7767d65170..a016cb7f53 100644
--- a/src/lib/libssl/src/crypto/bn/bn_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_mod.c b/src/lib/libssl/src/crypto/bn/bn_mod.c
new file mode 100644
index 0000000000..5cf82480d7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_mont.c b/src/lib/libssl/src/crypto/bn/bn_mont.c
index 8cf1febacc..82942a4759 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mont.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_mpi.c b/src/lib/libssl/src/crypto/bn/bn_mpi.c
index 80e1dca6b7..05fa9d1e9a 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mpi.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_mul.c b/src/lib/libssl/src/crypto/bn/bn_mul.c
index 3e8d8b9567..41ea925b8d 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mul.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_prime.c b/src/lib/libssl/src/crypto/bn/bn_prime.c
index a5f01b92eb..918b9237c6 100644
--- a/src/lib/libssl/src/crypto/bn/bn_prime.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_print.c b/src/lib/libssl/src/crypto/bn/bn_print.c
index 532e66bcc3..5f46b1826c 100644
--- a/src/lib/libssl/src/crypto/bn/bn_print.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_rand.c b/src/lib/libssl/src/crypto/bn/bn_rand.c
index acd0619921..9e08ccd22e 100644
--- a/src/lib/libssl/src/crypto/bn/bn_rand.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_recp.c b/src/lib/libssl/src/crypto/bn/bn_recp.c
index d019941d6b..ef5fdd4708 100644
--- a/src/lib/libssl/src/crypto/bn/bn_recp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_shift.c b/src/lib/libssl/src/crypto/bn/bn_shift.c
index c2608f9f4a..70f785ea18 100644
--- a/src/lib/libssl/src/crypto/bn/bn_shift.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_sqr.c b/src/lib/libssl/src/crypto/bn/bn_sqr.c
index 75f4f38392..c1d0cca438 100644
--- a/src/lib/libssl/src/crypto/bn/bn_sqr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bn_sqrt.c b/src/lib/libssl/src/crypto/bn/bn_sqrt.c
new file mode 100644
index 0000000000..e2a1105dc8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bnspeed.c b/src/lib/libssl/src/crypto/bn/bnspeed.c
index 20fc7e08ff..b554ac8cf8 100644
--- a/src/lib/libssl/src/crypto/bn/bnspeed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/bntest.c b/src/lib/libssl/src/crypto/bn/bntest.c
index af0c2629e8..443cf420e5 100644
--- a/src/lib/libssl/src/crypto/bn/bntest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/expspeed.c b/src/lib/libssl/src/crypto/bn/expspeed.c
index 2044ab9bff..07a1bcf51c 100644
--- a/src/lib/libssl/src/crypto/bn/expspeed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/exptest.c b/src/lib/libssl/src/crypto/bn/exptest.c
index 3e86f2ea0e..5ca570d1a8 100644
--- a/src/lib/libssl/src/crypto/bn/exptest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/bn/vms-helper.c b/src/lib/libssl/src/crypto/bn/vms-helper.c
index 0fa79c4edb..4b63149bf3 100644
--- a/src/lib/libssl/src/crypto/bn/vms-helper.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/Makefile.ssl b/src/lib/libssl/src/crypto/buffer/Makefile.ssl
index a64681fd22..b8b6439503 100644
--- a/src/lib/libssl/src/crypto/buffer/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/buf_err.c b/src/lib/libssl/src/crypto/buffer/buf_err.c
index 2f971a5f38..5eee653e14 100644
--- a/src/lib/libssl/src/crypto/buffer/buf_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/buffer.c b/src/lib/libssl/src/crypto/buffer/buffer.c
index b76ff3ad7a..9299baba9e 100644
--- a/src/lib/libssl/src/crypto/buffer/buffer.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/buffer/buffer.h b/src/lib/libssl/src/crypto/buffer/buffer.h
index bff26bf391..11e2d0359a 100644
--- a/src/lib/libssl/src/crypto/buffer/buffer.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/Makefile.ssl b/src/lib/libssl/src/crypto/cast/Makefile.ssl
index 1f8b898f7c..a2bf56276b 100644
--- a/src/lib/libssl/src/crypto/cast/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/cast.h b/src/lib/libssl/src/crypto/cast/cast.h
index e24e133099..b28e4e4f3b 100644
--- a/src/lib/libssl/src/crypto/cast/cast.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/cast_lcl.h b/src/lib/libssl/src/crypto/cast/cast_lcl.h
index 5fab8a43f6..37f41cc6a4 100644
--- a/src/lib/libssl/src/crypto/cast/cast_lcl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/cast_spd.c b/src/lib/libssl/src/crypto/cast/cast_spd.c
index 0af915cf20..76abf50d98 100644
--- a/src/lib/libssl/src/crypto/cast/cast_spd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/castopts.c b/src/lib/libssl/src/crypto/cast/castopts.c
index c783796610..1b858d153b 100644
--- a/src/lib/libssl/src/crypto/cast/castopts.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cast/casttest.c b/src/lib/libssl/src/crypto/cast/casttest.c
index ab2aeac606..099e790886 100644
--- a/src/lib/libssl/src/crypto/cast/casttest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/Makefile.ssl b/src/lib/libssl/src/crypto/comp/Makefile.ssl
index b696ac75fe..5dadb65cd4 100644
--- a/src/lib/libssl/src/crypto/comp/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/c_rle.c b/src/lib/libssl/src/crypto/comp/c_rle.c
index 1a819e3737..efd366fa22 100644
--- a/src/lib/libssl/src/crypto/comp/c_rle.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/c_zlib.c b/src/lib/libssl/src/crypto/comp/c_zlib.c
index 6684ab4841..cd2f8a491b 100644
--- a/src/lib/libssl/src/crypto/comp/c_zlib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/comp.h b/src/lib/libssl/src/crypto/comp/comp.h
index 0922609542..ab48b78ae9 100644
--- a/src/lib/libssl/src/crypto/comp/comp.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/comp/comp_err.c b/src/lib/libssl/src/crypto/comp/comp_err.c
index c10282a73c..1652b8c2c4 100644
--- a/src/lib/libssl/src/crypto/comp/comp_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/Makefile.ssl b/src/lib/libssl/src/crypto/conf/Makefile.ssl
index 9df4fca877..795eec1a01 100644
--- a/src/lib/libssl/src/crypto/conf/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/README b/src/lib/libssl/src/crypto/conf/README
new file mode 100644
index 0000000000..ca58d0240f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/cnf_save.c b/src/lib/libssl/src/crypto/conf/cnf_save.c
index e907cc2242..1439487526 100644
--- a/src/lib/libssl/src/crypto/conf/cnf_save.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf.c b/src/lib/libssl/src/crypto/conf/conf.c
new file mode 100644
index 0000000000..3031fa3b44
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf.h b/src/lib/libssl/src/crypto/conf/conf.h
index cd40a0db21..3c03fb19c0 100644
--- a/src/lib/libssl/src/crypto/conf/conf.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_api.c b/src/lib/libssl/src/crypto/conf/conf_api.c
index d05a778ff6..0032baa711 100644
--- a/src/lib/libssl/src/crypto/conf/conf_api.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_api.h b/src/lib/libssl/src/crypto/conf/conf_api.h
index a5cc17b233..87a954aff6 100644
--- a/src/lib/libssl/src/crypto/conf/conf_api.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_def.c b/src/lib/libssl/src/crypto/conf/conf_def.c
index 773df32c68..31f2766246 100644
--- a/src/lib/libssl/src/crypto/conf/conf_def.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_def.h b/src/lib/libssl/src/crypto/conf/conf_def.h
index 3244d9a331..92a7d8ad77 100644
--- a/src/lib/libssl/src/crypto/conf/conf_def.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_err.c b/src/lib/libssl/src/crypto/conf/conf_err.c
index 8c2bc6f1c4..ee07bfe9d9 100644
--- a/src/lib/libssl/src/crypto/conf/conf_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_lib.c b/src/lib/libssl/src/crypto/conf/conf_lib.c
index 11ec639732..7998f34c7b 100644
--- a/src/lib/libssl/src/crypto/conf/conf_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_mall.c b/src/lib/libssl/src/crypto/conf/conf_mall.c
new file mode 100644
index 0000000000..d702af689b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_mod.c b/src/lib/libssl/src/crypto/conf/conf_mod.c
new file mode 100644
index 0000000000..f92babc2e2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/conf_sap.c b/src/lib/libssl/src/crypto/conf/conf_sap.c
new file mode 100644
index 0000000000..97fb174303
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/conf/keysets.pl b/src/lib/libssl/src/crypto/conf/keysets.pl
index 56669e76ac..50ed67fa52 100644
--- a/src/lib/libssl/src/crypto/conf/keysets.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cpt_err.c b/src/lib/libssl/src/crypto/cpt_err.c
index 7018b74ca0..1b4a1cb4d4 100644
--- a/src/lib/libssl/src/crypto/cpt_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cryptlib.c b/src/lib/libssl/src/crypto/cryptlib.c
index a7a9262133..612b3b93b4 100644
--- a/src/lib/libssl/src/crypto/cryptlib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cryptlib.h b/src/lib/libssl/src/crypto/cryptlib.h
index 5eff5d3141..a0489e57fc 100644
--- a/src/lib/libssl/src/crypto/cryptlib.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/crypto-lib.com b/src/lib/libssl/src/crypto/crypto-lib.com
index 482a136177..ca0247be00 100644
--- a/src/lib/libssl/src/crypto/crypto-lib.com
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/crypto.h b/src/lib/libssl/src/crypto/crypto.h
index 9257673279..fc6ff860af 100644
--- a/src/lib/libssl/src/crypto/crypto.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/cversion.c b/src/lib/libssl/src/crypto/cversion.c
index affdfca98f..f7a1b7a4f0 100644
--- a/src/lib/libssl/src/crypto/cversion.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/Makefile.ssl b/src/lib/libssl/src/crypto/des/Makefile.ssl
index cc5379feb2..04a73a9326 100644
--- a/src/lib/libssl/src/crypto/des/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/asm/crypt586.pl b/src/lib/libssl/src/crypto/des/asm/crypt586.pl
index 197c413ea6..3d41d82f69 100644
--- a/src/lib/libssl/src/crypto/des/asm/crypt586.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/asm/des-586.pl b/src/lib/libssl/src/crypto/des/asm/des-586.pl
index c890766bc9..0d08e8a3a9 100644
--- a/src/lib/libssl/src/crypto/des/asm/des-586.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/asm/des686.pl b/src/lib/libssl/src/crypto/des/asm/des686.pl
index 84c3e85438..d3ad5d5edd 100644
--- a/src/lib/libssl/src/crypto/des/asm/des686.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/asm/desboth.pl b/src/lib/libssl/src/crypto/des/asm/desboth.pl
index d5106414db..eec00886e4 100644
--- a/src/lib/libssl/src/crypto/des/asm/desboth.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cbc3_enc.c b/src/lib/libssl/src/crypto/des/cbc3_enc.c
index 527e74f3de..b5db4e14f7 100644
--- a/src/lib/libssl/src/crypto/des/cbc3_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cbc_cksm.c b/src/lib/libssl/src/crypto/des/cbc_cksm.c
index b857df0985..6c5305b99d 100644
--- a/src/lib/libssl/src/crypto/des/cbc_cksm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cfb64ede.c b/src/lib/libssl/src/crypto/des/cfb64ede.c
index 5362a551bf..60c1aa08db 100644
--- a/src/lib/libssl/src/crypto/des/cfb64ede.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cfb64enc.c b/src/lib/libssl/src/crypto/des/cfb64enc.c
index 105530dfa3..5ec8683e40 100644
--- a/src/lib/libssl/src/crypto/des/cfb64enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/cfb_enc.c b/src/lib/libssl/src/crypto/des/cfb_enc.c
index ec4fd4ea67..17bf77ca9e 100644
--- a/src/lib/libssl/src/crypto/des/cfb_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des-lib.com b/src/lib/libssl/src/crypto/des/des-lib.com
index 2aea7a0dea..fc2c35a1ce 100644
--- a/src/lib/libssl/src/crypto/des/des-lib.com
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des.c b/src/lib/libssl/src/crypto/des/des.c
index 215d7413c0..d8c846b23d 100644
--- a/src/lib/libssl/src/crypto/des/des.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des.h b/src/lib/libssl/src/crypto/des/des.h
index 6b8a7ee11b..dfe5ff64e4 100644
--- a/src/lib/libssl/src/crypto/des/des.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_enc.c b/src/lib/libssl/src/crypto/des/des_enc.c
index 0bd9fa39bc..1c37ab96d3 100644
--- a/src/lib/libssl/src/crypto/des/des_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_locl.h b/src/lib/libssl/src/crypto/des/des_locl.h
index 1ace8f5930..70e833be3f 100644
--- a/src/lib/libssl/src/crypto/des/des_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_old.c b/src/lib/libssl/src/crypto/des/des_old.c
new file mode 100644
index 0000000000..7e4cd7180d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_old.h b/src/lib/libssl/src/crypto/des/des_old.h
new file mode 100644
index 0000000000..3778f93c15
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_old2.c b/src/lib/libssl/src/crypto/des/des_old2.c
new file mode 100644
index 0000000000..c8fa3ee135
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_opts.c b/src/lib/libssl/src/crypto/des/des_opts.c
index 138ee1c6b4..79278b920e 100644
--- a/src/lib/libssl/src/crypto/des/des_opts.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/des_ver.h b/src/lib/libssl/src/crypto/des/des_ver.h
index de3c02f110..0fa94d5368 100644
--- a/src/lib/libssl/src/crypto/des/des_ver.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/destest.c b/src/lib/libssl/src/crypto/des/destest.c
index df0d615d6b..58e8c35dcb 100644
--- a/src/lib/libssl/src/crypto/des/destest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ecb3_enc.c b/src/lib/libssl/src/crypto/des/ecb3_enc.c
index fb28b97e1a..c3437bc606 100644
--- a/src/lib/libssl/src/crypto/des/ecb3_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ecb_enc.c b/src/lib/libssl/src/crypto/des/ecb_enc.c
index d481327ef3..4650f2fa0f 100644
--- a/src/lib/libssl/src/crypto/des/ecb_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ede_cbcm_enc.c b/src/lib/libssl/src/crypto/des/ede_cbcm_enc.c
index b98f7e17af..fa45aa272b 100644
--- a/src/lib/libssl/src/crypto/des/ede_cbcm_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/enc_read.c b/src/lib/libssl/src/crypto/des/enc_read.c
index af2d9177d2..c70fb686b8 100644
--- a/src/lib/libssl/src/crypto/des/enc_read.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/enc_writ.c b/src/lib/libssl/src/crypto/des/enc_writ.c
index cc2b50fb50..af5b8c2349 100644
--- a/src/lib/libssl/src/crypto/des/enc_writ.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/fcrypt.c b/src/lib/libssl/src/crypto/des/fcrypt.c
index 9b21f81cc2..d3d27de9f7 100644
--- a/src/lib/libssl/src/crypto/des/fcrypt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/fcrypt_b.c b/src/lib/libssl/src/crypto/des/fcrypt_b.c
index 22c87f5983..1390138787 100644
--- a/src/lib/libssl/src/crypto/des/fcrypt_b.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ncbc_enc.c b/src/lib/libssl/src/crypto/des/ncbc_enc.c
index b8db07b199..fda23d522f 100644
--- a/src/lib/libssl/src/crypto/des/ncbc_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ofb64ede.c b/src/lib/libssl/src/crypto/des/ofb64ede.c
index 6eafe908da..26bbf9a6a7 100644
--- a/src/lib/libssl/src/crypto/des/ofb64ede.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ofb64enc.c b/src/lib/libssl/src/crypto/des/ofb64enc.c
index 1a1d1f1ac4..8ca3d49dea 100644
--- a/src/lib/libssl/src/crypto/des/ofb64enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/ofb_enc.c b/src/lib/libssl/src/crypto/des/ofb_enc.c
index 70493e632c..e887a3c6f4 100644
--- a/src/lib/libssl/src/crypto/des/ofb_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/pcbc_enc.c b/src/lib/libssl/src/crypto/des/pcbc_enc.c
index 5b987f074d..17a40f9520 100644
--- a/src/lib/libssl/src/crypto/des/pcbc_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/qud_cksm.c b/src/lib/libssl/src/crypto/des/qud_cksm.c
index 9fff989edb..dac201227e 100644
--- a/src/lib/libssl/src/crypto/des/qud_cksm.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/rand_key.c b/src/lib/libssl/src/crypto/des/rand_key.c
index ee1a6c274e..2398165568 100644
--- a/src/lib/libssl/src/crypto/des/rand_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/read2pwd.c b/src/lib/libssl/src/crypto/des/read2pwd.c
index a8ceaf088a..b4720c3a98 100644
--- a/src/lib/libssl/src/crypto/des/read2pwd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/read_pwd.c b/src/lib/libssl/src/crypto/des/read_pwd.c
index c27ec336e7..ae9aef620b 100644
--- a/src/lib/libssl/src/crypto/des/read_pwd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/rpc_enc.c b/src/lib/libssl/src/crypto/des/rpc_enc.c
index 32d96d5cae..d937d08da5 100644
--- a/src/lib/libssl/src/crypto/des/rpc_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/rpw.c b/src/lib/libssl/src/crypto/des/rpw.c
index 0b6b1519b0..8a9473c4f9 100644
--- a/src/lib/libssl/src/crypto/des/rpw.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/set_key.c b/src/lib/libssl/src/crypto/des/set_key.c
index 09afd4fc03..683916e71b 100644
--- a/src/lib/libssl/src/crypto/des/set_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/speed.c b/src/lib/libssl/src/crypto/des/speed.c
index 1223edf290..48fc1d49fc 100644
--- a/src/lib/libssl/src/crypto/des/speed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/spr.h b/src/lib/libssl/src/crypto/des/spr.h
index b8fbdcf8d3..b91936a5a5 100644
--- a/src/lib/libssl/src/crypto/des/spr.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/str2key.c b/src/lib/libssl/src/crypto/des/str2key.c
index c6abb87201..36c3f81d99 100644
--- a/src/lib/libssl/src/crypto/des/str2key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/des/xcbc_enc.c b/src/lib/libssl/src/crypto/des/xcbc_enc.c
index ccfede13ac..47246eb466 100644
--- a/src/lib/libssl/src/crypto/des/xcbc_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/Makefile.ssl b/src/lib/libssl/src/crypto/dh/Makefile.ssl
index bf4b47ca9a..209e2bf39c 100644
--- a/src/lib/libssl/src/crypto/dh/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh.h b/src/lib/libssl/src/crypto/dh/dh.h
index 7a8d9f88c2..d51dc130f4 100644
--- a/src/lib/libssl/src/crypto/dh/dh.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_asn1.c b/src/lib/libssl/src/crypto/dh/dh_asn1.c
new file mode 100644
index 0000000000..769b5b68c5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_check.c b/src/lib/libssl/src/crypto/dh/dh_check.c
index 7e5cfd8bfc..f0373f7d68 100644
--- a/src/lib/libssl/src/crypto/dh/dh_check.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_err.c b/src/lib/libssl/src/crypto/dh/dh_err.c
index ff2d1684c2..d837950aec 100644
--- a/src/lib/libssl/src/crypto/dh/dh_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_gen.c b/src/lib/libssl/src/crypto/dh/dh_gen.c
index 7a6a38fbb4..06f78b35ab 100644
--- a/src/lib/libssl/src/crypto/dh/dh_gen.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_key.c b/src/lib/libssl/src/crypto/dh/dh_key.c
index 22b087b778..1a0efca2c4 100644
--- a/src/lib/libssl/src/crypto/dh/dh_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dh_lib.c b/src/lib/libssl/src/crypto/dh/dh_lib.c
index 96f118c153..ba5fd41057 100644
--- a/src/lib/libssl/src/crypto/dh/dh_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dh/dhtest.c b/src/lib/libssl/src/crypto/dh/dhtest.c
index f0151253d7..34894ced73 100644
--- a/src/lib/libssl/src/crypto/dh/dhtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/Makefile.ssl b/src/lib/libssl/src/crypto/dsa/Makefile.ssl
index d88f596364..32ecf6ee01 100644
--- a/src/lib/libssl/src/crypto/dsa/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa.h b/src/lib/libssl/src/crypto/dsa/dsa.h
index 12b60a8faa..9b3baadf2c 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_asn1.c b/src/lib/libssl/src/crypto/dsa/dsa_asn1.c
index a76c8f7c7e..23fce555aa 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_asn1.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_err.c b/src/lib/libssl/src/crypto/dsa/dsa_err.c
index 736aeef7c4..79aa4ff526 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_gen.c b/src/lib/libssl/src/crypto/dsa/dsa_gen.c
index 2294a362d9..dc9c249310 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_gen.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_key.c b/src/lib/libssl/src/crypto/dsa/dsa_key.c
index a68d236e05..bf718c1c6d 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_lib.c b/src/lib/libssl/src/crypto/dsa/dsa_lib.c
index 15f667a203..da2cdfa3d6 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_ossl.c b/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
index 34c6e9a141..07addc94d9 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_ossl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_sign.c b/src/lib/libssl/src/crypto/dsa/dsa_sign.c
index dfe27bae47..e9469ca62f 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsa_vrf.c b/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
index 2e891ae491..066c6b5b28 100644
--- a/src/lib/libssl/src/crypto/dsa/dsa_vrf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dsa/dsatest.c b/src/lib/libssl/src/crypto/dsa/dsatest.c
index 309a7cda89..12da64f9f4 100644
--- a/src/lib/libssl/src/crypto/dsa/dsatest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/Makefile.ssl b/src/lib/libssl/src/crypto/dso/Makefile.ssl
index 48b36c8330..cca9376bdb 100644
--- a/src/lib/libssl/src/crypto/dso/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/README b/src/lib/libssl/src/crypto/dso/README
index 6ba03c5631..d0bc9a89fb 100644
--- a/src/lib/libssl/src/crypto/dso/README
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso.h b/src/lib/libssl/src/crypto/dso/dso.h
index bed7c464a6..aa721f7feb 100644
--- a/src/lib/libssl/src/crypto/dso/dso.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_dl.c b/src/lib/libssl/src/crypto/dso/dso_dl.c
index 455bd66ecf..195717e993 100644
--- a/src/lib/libssl/src/crypto/dso/dso_dl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_dlfcn.c b/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
index e709c721cc..1a19164d3b 100644
--- a/src/lib/libssl/src/crypto/dso/dso_dlfcn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_err.c b/src/lib/libssl/src/crypto/dso/dso_err.c
index a3d7321c9b..cf452de1aa 100644
--- a/src/lib/libssl/src/crypto/dso/dso_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_lib.c b/src/lib/libssl/src/crypto/dso/dso_lib.c
index acd166697e..556069b9b8 100644
--- a/src/lib/libssl/src/crypto/dso/dso_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_vms.c b/src/lib/libssl/src/crypto/dso/dso_vms.c
index ab48b63eb7..1674619d17 100644
--- a/src/lib/libssl/src/crypto/dso/dso_vms.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/dso/dso_win32.c b/src/lib/libssl/src/crypto/dso/dso_win32.c
index 7f1d904806..af8586d754 100644
--- a/src/lib/libssl/src/crypto/dso/dso_win32.c
+++ b/src/lib/libssl/src/crypto/dso/dso_win32.c
@@ -61,7 +61,7 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/dso.h> 62#include <openssl/dso.h>
63 63
64#ifndef 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/libssl/src/crypto/ebcdic.c b/src/lib/libssl/src/crypto/ebcdic.c
index 91a7a8bcb4..bc968ea807 100644
--- a/src/lib/libssl/src/crypto/ebcdic.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/Makefile.ssl b/src/lib/libssl/src/crypto/ec/Makefile.ssl
new file mode 100644
index 0000000000..7a21b7195f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec.h b/src/lib/libssl/src/crypto/ec/ec.h
new file mode 100644
index 0000000000..a52d4edf14
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_cvt.c b/src/lib/libssl/src/crypto/ec/ec_cvt.c
new file mode 100644
index 0000000000..45b0ec33a0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_err.c b/src/lib/libssl/src/crypto/ec/ec_err.c
new file mode 100644
index 0000000000..394cdc021f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_lcl.h b/src/lib/libssl/src/crypto/ec/ec_lcl.h
new file mode 100644
index 0000000000..cc4cf27755
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_lib.c b/src/lib/libssl/src/crypto/ec/ec_lib.c
new file mode 100644
index 0000000000..e0d78d67fb
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_mult.c b/src/lib/libssl/src/crypto/ec/ec_mult.c
new file mode 100644
index 0000000000..603ba31b81
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_mont.c b/src/lib/libssl/src/crypto/ec/ecp_mont.c
new file mode 100644
index 0000000000..7b30d4c38a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_nist.c b/src/lib/libssl/src/crypto/ec/ecp_nist.c
new file mode 100644
index 0000000000..ed07748675
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_recp.c b/src/lib/libssl/src/crypto/ec/ecp_recp.c
new file mode 100644
index 0000000000..fec843b5c8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_smpl.c b/src/lib/libssl/src/crypto/ec/ecp_smpl.c
new file mode 100644
index 0000000000..4666a052bf
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ectest.c b/src/lib/libssl/src/crypto/ec/ectest.c
new file mode 100644
index 0000000000..243cd83fb5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/Makefile.ssl b/src/lib/libssl/src/crypto/engine/Makefile.ssl
index d49b7c8159..eeea47fbf5 100644
--- a/src/lib/libssl/src/crypto/engine/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/README b/src/lib/libssl/src/crypto/engine/README
index 96595e6f35..6b69b70f57 100644
--- a/src/lib/libssl/src/crypto/engine/README
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_all.c b/src/lib/libssl/src/crypto/engine/eng_all.c
new file mode 100644
index 0000000000..a35b3db9e8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_cnf.c b/src/lib/libssl/src/crypto/engine/eng_cnf.c
new file mode 100644
index 0000000000..8c0ae8a1ad
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_ctrl.c b/src/lib/libssl/src/crypto/engine/eng_ctrl.c
new file mode 100644
index 0000000000..ad3858395b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_dyn.c b/src/lib/libssl/src/crypto/engine/eng_dyn.c
new file mode 100644
index 0000000000..4fefcc0cae
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_err.c b/src/lib/libssl/src/crypto/engine/eng_err.c
new file mode 100644
index 0000000000..f6c5630395
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_fat.c b/src/lib/libssl/src/crypto/engine/eng_fat.c
new file mode 100644
index 0000000000..af918b1499
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_init.c b/src/lib/libssl/src/crypto/engine/eng_init.c
new file mode 100644
index 0000000000..cc9396e863
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_int.h b/src/lib/libssl/src/crypto/engine/eng_int.h
new file mode 100644
index 0000000000..38335f99cd
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_lib.c b/src/lib/libssl/src/crypto/engine/eng_lib.c
new file mode 100644
index 0000000000..a66d0f08af
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_list.c b/src/lib/libssl/src/crypto/engine/eng_list.c
new file mode 100644
index 0000000000..ce48d2255a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_openssl.c b/src/lib/libssl/src/crypto/engine/eng_openssl.c
new file mode 100644
index 0000000000..e9d976f46b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_pkey.c b/src/lib/libssl/src/crypto/engine/eng_pkey.c
new file mode 100644
index 0000000000..8c69171511
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/eng_table.c b/src/lib/libssl/src/crypto/engine/eng_table.c
new file mode 100644
index 0000000000..c69a84a8bf
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/engine.h b/src/lib/libssl/src/crypto/engine/engine.h
index 2983f47034..97f5de9e12 100644
--- a/src/lib/libssl/src/crypto/engine/engine.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/enginetest.c b/src/lib/libssl/src/crypto/engine/enginetest.c
index a5a3c47fcb..87fa8c57b7 100644
--- a/src/lib/libssl/src/crypto/engine/enginetest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw.ec b/src/lib/libssl/src/crypto/engine/hw.ec
new file mode 100644
index 0000000000..5481a43918
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_4758_cca.c b/src/lib/libssl/src/crypto/engine/hw_4758_cca.c
new file mode 100644
index 0000000000..959d8f1a61
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_4758_cca_err.c b/src/lib/libssl/src/crypto/engine/hw_4758_cca_err.c
new file mode 100644
index 0000000000..7ea5c63707
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_4758_cca_err.h b/src/lib/libssl/src/crypto/engine/hw_4758_cca_err.h
new file mode 100644
index 0000000000..2fc563ab11
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_aep.c b/src/lib/libssl/src/crypto/engine/hw_aep.c
new file mode 100644
index 0000000000..cf4507cff1
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_aep_err.c b/src/lib/libssl/src/crypto/engine/hw_aep_err.c
new file mode 100644
index 0000000000..092f532946
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_aep_err.h b/src/lib/libssl/src/crypto/engine/hw_aep_err.h
new file mode 100644
index 0000000000..8fe4cf921f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_atalla.c b/src/lib/libssl/src/crypto/engine/hw_atalla.c
index 3bb992a193..696cfcf156 100644
--- a/src/lib/libssl/src/crypto/engine/hw_atalla.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_atalla_err.c b/src/lib/libssl/src/crypto/engine/hw_atalla_err.c
new file mode 100644
index 0000000000..1df9c4570c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_atalla_err.h b/src/lib/libssl/src/crypto/engine/hw_atalla_err.h
new file mode 100644
index 0000000000..cdac052d8c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_cryptodev.c b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c
new file mode 100644
index 0000000000..7c3728f395
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_cswift.c b/src/lib/libssl/src/crypto/engine/hw_cswift.c
index 77608b8983..d8b380550f 100644
--- a/src/lib/libssl/src/crypto/engine/hw_cswift.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_cswift_err.c b/src/lib/libssl/src/crypto/engine/hw_cswift_err.c
new file mode 100644
index 0000000000..684f53bf27
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_cswift_err.h b/src/lib/libssl/src/crypto/engine/hw_cswift_err.h
new file mode 100644
index 0000000000..7120c3216f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher.c b/src/lib/libssl/src/crypto/engine/hw_ncipher.c
index 41f5900676..4762a54e3d 100644
--- a/src/lib/libssl/src/crypto/engine/hw_ncipher.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher_err.c b/src/lib/libssl/src/crypto/engine/hw_ncipher_err.c
new file mode 100644
index 0000000000..24024cfc6f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ncipher_err.h b/src/lib/libssl/src/crypto/engine/hw_ncipher_err.h
new file mode 100644
index 0000000000..4d65b1d470
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_nuron.c b/src/lib/libssl/src/crypto/engine/hw_nuron.c
new file mode 100644
index 0000000000..2672012154
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_nuron_err.c b/src/lib/libssl/src/crypto/engine/hw_nuron_err.c
new file mode 100644
index 0000000000..df9d7bde76
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_nuron_err.h b/src/lib/libssl/src/crypto/engine/hw_nuron_err.h
new file mode 100644
index 0000000000..a56bfdf303
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_openbsd_dev_crypto.c b/src/lib/libssl/src/crypto/engine/hw_openbsd_dev_crypto.c
new file mode 100644
index 0000000000..f946389b8a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_sureware_err.c b/src/lib/libssl/src/crypto/engine/hw_sureware_err.c
new file mode 100644
index 0000000000..69955dadbb
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_sureware_err.h b/src/lib/libssl/src/crypto/engine/hw_sureware_err.h
new file mode 100644
index 0000000000..bc52af5e05
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ubsec.c b/src/lib/libssl/src/crypto/engine/hw_ubsec.c
new file mode 100644
index 0000000000..743c06043c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ubsec_err.c b/src/lib/libssl/src/crypto/engine/hw_ubsec_err.c
new file mode 100644
index 0000000000..d707331fc2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/hw_ubsec_err.h b/src/lib/libssl/src/crypto/engine/hw_ubsec_err.h
new file mode 100644
index 0000000000..023d3be771
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_cipher.c b/src/lib/libssl/src/crypto/engine/tb_cipher.c
new file mode 100644
index 0000000000..c5a50fc910
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_dh.c b/src/lib/libssl/src/crypto/engine/tb_dh.c
new file mode 100644
index 0000000000..c9347235ea
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_digest.c b/src/lib/libssl/src/crypto/engine/tb_digest.c
new file mode 100644
index 0000000000..2c4dd6f796
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_dsa.c b/src/lib/libssl/src/crypto/engine/tb_dsa.c
new file mode 100644
index 0000000000..e9209476b8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_rand.c b/src/lib/libssl/src/crypto/engine/tb_rand.c
new file mode 100644
index 0000000000..0b1d031f1e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/tb_rsa.c b/src/lib/libssl/src/crypto/engine/tb_rsa.c
new file mode 100644
index 0000000000..f84fea3968
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/vendor_defns/aep.h b/src/lib/libssl/src/crypto/engine/vendor_defns/aep.h
new file mode 100644
index 0000000000..2b2792d2d6
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/vendor_defns/atalla.h b/src/lib/libssl/src/crypto/engine/vendor_defns/atalla.h
index 8111649c54..149970d441 100644
--- a/src/lib/libssl/src/crypto/engine/vendor_defns/atalla.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/vendor_defns/cswift.h b/src/lib/libssl/src/crypto/engine/vendor_defns/cswift.h
index 0af14a1a92..60079326bb 100644
--- a/src/lib/libssl/src/crypto/engine/vendor_defns/cswift.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/engine/vendor_defns/hw_4758_cca.h b/src/lib/libssl/src/crypto/engine/vendor_defns/hw_4758_cca.h
new file mode 100644
index 0000000000..296636e81a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/Makefile.ssl b/src/lib/libssl/src/crypto/err/Makefile.ssl
index 58218d1cea..4e69b9fbab 100644
--- a/src/lib/libssl/src/crypto/err/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c
index 839f4ab81a..04773d65a6 100644
--- a/src/lib/libssl/src/crypto/err/err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err.h b/src/lib/libssl/src/crypto/err/err.h
index 7388a4a937..cc9bb649ea 100644
--- a/src/lib/libssl/src/crypto/err/err.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err_all.c b/src/lib/libssl/src/crypto/err/err_all.c
index b8315d8272..90029fd159 100644
--- a/src/lib/libssl/src/crypto/err/err_all.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/err_prn.c b/src/lib/libssl/src/crypto/err/err_prn.c
index 6f60b016c3..c156663f0e 100644
--- a/src/lib/libssl/src/crypto/err/err_prn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/err/openssl.ec b/src/lib/libssl/src/crypto/err/openssl.ec
index 861d680e07..29a69dfdd4 100644
--- a/src/lib/libssl/src/crypto/err/openssl.ec
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/Makefile.ssl b/src/lib/libssl/src/crypto/evp/Makefile.ssl
index 624168031d..4abe93dafe 100644
--- a/src/lib/libssl/src/crypto/evp/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_b64.c b/src/lib/libssl/src/crypto/evp/bio_b64.c
index af6fa2ae8f..f12eac1b55 100644
--- a/src/lib/libssl/src/crypto/evp/bio_b64.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_enc.c b/src/lib/libssl/src/crypto/evp/bio_enc.c
index 831c71a2b5..05f4249458 100644
--- a/src/lib/libssl/src/crypto/evp/bio_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_md.c b/src/lib/libssl/src/crypto/evp/bio_md.c
index 2373c247d8..c632dfb202 100644
--- a/src/lib/libssl/src/crypto/evp/bio_md.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/bio_ok.c b/src/lib/libssl/src/crypto/evp/bio_ok.c
index e617ce1d43..3cbc6e7848 100644
--- a/src/lib/libssl/src/crypto/evp/bio_ok.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/c_all.c b/src/lib/libssl/src/crypto/evp/c_all.c
index 1e185830a3..3d390dfbf1 100644
--- a/src/lib/libssl/src/crypto/evp/c_all.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/c_allc.c b/src/lib/libssl/src/crypto/evp/c_allc.c
index f24d3756c9..37e6ab83a5 100644
--- a/src/lib/libssl/src/crypto/evp/c_allc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/c_alld.c b/src/lib/libssl/src/crypto/evp/c_alld.c
index bbf059eb85..be91cdb037 100644
--- a/src/lib/libssl/src/crypto/evp/c_alld.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/digest.c b/src/lib/libssl/src/crypto/evp/digest.c
index c560733568..a969ac69ed 100644
--- a/src/lib/libssl/src/crypto/evp/digest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_aes.c b/src/lib/libssl/src/crypto/evp/e_aes.c
new file mode 100644
index 0000000000..9d03a9602f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_bf.c b/src/lib/libssl/src/crypto/evp/e_bf.c
index 53559b0b65..e74337567b 100644
--- a/src/lib/libssl/src/crypto/evp/e_bf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_cast.c b/src/lib/libssl/src/crypto/evp/e_cast.c
index e5af7fb4ed..3400fef187 100644
--- a/src/lib/libssl/src/crypto/evp/e_cast.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_des.c b/src/lib/libssl/src/crypto/evp/e_des.c
index f4e998b81c..105266a4b3 100644
--- a/src/lib/libssl/src/crypto/evp/e_des.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_des3.c b/src/lib/libssl/src/crypto/evp/e_des3.c
index a9aba4ae70..077860e7b6 100644
--- a/src/lib/libssl/src/crypto/evp/e_des3.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_idea.c b/src/lib/libssl/src/crypto/evp/e_idea.c
index 8d3c88deb7..ed838d3e62 100644
--- a/src/lib/libssl/src/crypto/evp/e_idea.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_null.c b/src/lib/libssl/src/crypto/evp/e_null.c
index e0702cf818..2420d7e5af 100644
--- a/src/lib/libssl/src/crypto/evp/e_null.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_rc2.c b/src/lib/libssl/src/crypto/evp/e_rc2.c
index 3955c3ef84..4685198e2e 100644
--- a/src/lib/libssl/src/crypto/evp/e_rc2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_rc4.c b/src/lib/libssl/src/crypto/evp/e_rc4.c
index 1c1e3b3857..4064cc5fa0 100644
--- a/src/lib/libssl/src/crypto/evp/e_rc4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_rc5.c b/src/lib/libssl/src/crypto/evp/e_rc5.c
index 5885f1826b..3c7713b181 100644
--- a/src/lib/libssl/src/crypto/evp/e_rc5.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/e_xcbc_d.c b/src/lib/libssl/src/crypto/evp/e_xcbc_d.c
index e5b15acc7d..a6f849e93d 100644
--- a/src/lib/libssl/src/crypto/evp/e_xcbc_d.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/encode.c b/src/lib/libssl/src/crypto/evp/encode.c
index 6ff9c1783c..12c6379df1 100644
--- a/src/lib/libssl/src/crypto/evp/encode.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp.h b/src/lib/libssl/src/crypto/evp/evp.h
index fd43127092..915fe62341 100644
--- a/src/lib/libssl/src/crypto/evp/evp.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_acnf.c b/src/lib/libssl/src/crypto/evp/evp_acnf.c
new file mode 100644
index 0000000000..a68b979bdb
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_enc.c b/src/lib/libssl/src/crypto/evp/evp_enc.c
index e2687f9879..d28a7d266e 100644
--- a/src/lib/libssl/src/crypto/evp/evp_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_err.c b/src/lib/libssl/src/crypto/evp/evp_err.c
index a01412a07c..3a23d21c21 100644
--- a/src/lib/libssl/src/crypto/evp/evp_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_key.c b/src/lib/libssl/src/crypto/evp/evp_key.c
index e7434ef9b2..4271393069 100644
--- a/src/lib/libssl/src/crypto/evp/evp_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_locl.h b/src/lib/libssl/src/crypto/evp/evp_locl.h
index ce49d5b7d8..7b088b4848 100644
--- a/src/lib/libssl/src/crypto/evp/evp_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_pbe.c b/src/lib/libssl/src/crypto/evp/evp_pbe.c
index 224a422b12..06afb9d152 100644
--- a/src/lib/libssl/src/crypto/evp/evp_pbe.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_pkey.c b/src/lib/libssl/src/crypto/evp/evp_pkey.c
index 8df2874f3c..34b5b1d21c 100644
--- a/src/lib/libssl/src/crypto/evp/evp_pkey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evp_test.c b/src/lib/libssl/src/crypto/evp/evp_test.c
new file mode 100644
index 0000000000..3607fe7776
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/evptests.txt b/src/lib/libssl/src/crypto/evp/evptests.txt
new file mode 100644
index 0000000000..6c1529db37
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_dss.c b/src/lib/libssl/src/crypto/evp/m_dss.c
index 8ea826868e..beb8d7fc5c 100644
--- a/src/lib/libssl/src/crypto/evp/m_dss.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_dss1.c b/src/lib/libssl/src/crypto/evp/m_dss1.c
index 9d8d1ce23e..f5668ebda0 100644
--- a/src/lib/libssl/src/crypto/evp/m_dss1.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_md2.c b/src/lib/libssl/src/crypto/evp/m_md2.c
index 3281e91809..50914c83b3 100644
--- a/src/lib/libssl/src/crypto/evp/m_md2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_md4.c b/src/lib/libssl/src/crypto/evp/m_md4.c
index 6a24ceb86d..e19b663754 100644
--- a/src/lib/libssl/src/crypto/evp/m_md4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_md5.c b/src/lib/libssl/src/crypto/evp/m_md5.c
index 9fc9530127..b00a03e048 100644
--- a/src/lib/libssl/src/crypto/evp/m_md5.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_mdc2.c b/src/lib/libssl/src/crypto/evp/m_mdc2.c
index 2c7f1ae515..9f6467c931 100644
--- a/src/lib/libssl/src/crypto/evp/m_mdc2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_null.c b/src/lib/libssl/src/crypto/evp/m_null.c
index e2dadf3dab..f6f0a1d2c0 100644
--- a/src/lib/libssl/src/crypto/evp/m_null.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_ripemd.c b/src/lib/libssl/src/crypto/evp/m_ripemd.c
index 3d781a4e8d..64725528dc 100644
--- a/src/lib/libssl/src/crypto/evp/m_ripemd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_sha.c b/src/lib/libssl/src/crypto/evp/m_sha.c
index 6d35b71b85..10697c7ed3 100644
--- a/src/lib/libssl/src/crypto/evp/m_sha.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/m_sha1.c b/src/lib/libssl/src/crypto/evp/m_sha1.c
index 57a1ab0cce..d6be3502f0 100644
--- a/src/lib/libssl/src/crypto/evp/m_sha1.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/names.c b/src/lib/libssl/src/crypto/evp/names.c
index 620f43feaa..eb9f4329cd 100644
--- a/src/lib/libssl/src/crypto/evp/names.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/openbsd_hw.c b/src/lib/libssl/src/crypto/evp/openbsd_hw.c
new file mode 100644
index 0000000000..3831a5731e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p5_crpt.c b/src/lib/libssl/src/crypto/evp/p5_crpt.c
index 6bfa2c5acb..113c60fedb 100644
--- a/src/lib/libssl/src/crypto/evp/p5_crpt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p5_crpt2.c b/src/lib/libssl/src/crypto/evp/p5_crpt2.c
index 717fad68ca..7881860b53 100644
--- a/src/lib/libssl/src/crypto/evp/p5_crpt2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_dec.c b/src/lib/libssl/src/crypto/evp/p_dec.c
index 57b5daa453..8af620400e 100644
--- a/src/lib/libssl/src/crypto/evp/p_dec.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_enc.c b/src/lib/libssl/src/crypto/evp/p_enc.c
index 4cf6acaf5d..656883b996 100644
--- a/src/lib/libssl/src/crypto/evp/p_enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_lib.c b/src/lib/libssl/src/crypto/evp/p_lib.c
index 62398ed74d..215b94292a 100644
--- a/src/lib/libssl/src/crypto/evp/p_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_open.c b/src/lib/libssl/src/crypto/evp/p_open.c
index 2760c00fec..6976f2a867 100644
--- a/src/lib/libssl/src/crypto/evp/p_open.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_seal.c b/src/lib/libssl/src/crypto/evp/p_seal.c
index 2fd1d7e0c2..5570ca3745 100644
--- a/src/lib/libssl/src/crypto/evp/p_seal.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_sign.c b/src/lib/libssl/src/crypto/evp/p_sign.c
index 1fa32ac17e..e4ae5906f5 100644
--- a/src/lib/libssl/src/crypto/evp/p_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/evp/p_verify.c b/src/lib/libssl/src/crypto/evp/p_verify.c
index dcb54f3abb..d854d743a5 100644
--- a/src/lib/libssl/src/crypto/evp/p_verify.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ex_data.c b/src/lib/libssl/src/crypto/ex_data.c
index 739e543d78..5b2e345c27 100644
--- a/src/lib/libssl/src/crypto/ex_data.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/Makefile.ssl b/src/lib/libssl/src/crypto/hmac/Makefile.ssl
index 326339a90d..899d67c43b 100644
--- a/src/lib/libssl/src/crypto/hmac/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/hmac.c b/src/lib/libssl/src/crypto/hmac/hmac.c
index e1ec79e093..026dbe8f66 100644
--- a/src/lib/libssl/src/crypto/hmac/hmac.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/hmac.h b/src/lib/libssl/src/crypto/hmac/hmac.h
index 328bad2608..0364a1fcbd 100644
--- a/src/lib/libssl/src/crypto/hmac/hmac.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/hmac/hmactest.c b/src/lib/libssl/src/crypto/hmac/hmactest.c
index 4b56b8ee13..96d3beb8e6 100644
--- a/src/lib/libssl/src/crypto/hmac/hmactest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/idea/Makefile.ssl b/src/lib/libssl/src/crypto/idea/Makefile.ssl
index 30302e0b9f..217e6e0136 100644
--- a/src/lib/libssl/src/crypto/idea/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/idea/idea.h b/src/lib/libssl/src/crypto/idea/idea.h
index f14adf8398..67132414ee 100644
--- a/src/lib/libssl/src/crypto/idea/idea.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/install.com b/src/lib/libssl/src/crypto/install.com
index ea97665471..b3d155e964 100644
--- a/src/lib/libssl/src/crypto/install.com
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/krb5/Makefile.ssl b/src/lib/libssl/src/crypto/krb5/Makefile.ssl
new file mode 100644
index 0000000000..6dd4449e1e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/krb5/krb5_asn.c b/src/lib/libssl/src/crypto/krb5/krb5_asn.c
new file mode 100644
index 0000000000..1fb741d2a0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/krb5/krb5_asn.h b/src/lib/libssl/src/crypto/krb5/krb5_asn.h
new file mode 100644
index 0000000000..3329477b07
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/lhash/Makefile.ssl b/src/lib/libssl/src/crypto/lhash/Makefile.ssl
index 79849d7d6e..1eef09f3fa 100644
--- a/src/lib/libssl/src/crypto/lhash/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/lhash/lh_stats.c b/src/lib/libssl/src/crypto/lhash/lh_stats.c
index ee0600060e..39ea2885f4 100644
--- a/src/lib/libssl/src/crypto/lhash/lh_stats.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/lhash/lh_test.c b/src/lib/libssl/src/crypto/lhash/lh_test.c
index 6008781e57..85700c859b 100644
--- a/src/lib/libssl/src/crypto/lhash/lh_test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/lhash/lhash.c b/src/lib/libssl/src/crypto/lhash/lhash.c
index 7da14620a4..0a16fcf27d 100644
--- a/src/lib/libssl/src/crypto/lhash/lhash.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/lhash/lhash.h b/src/lib/libssl/src/crypto/lhash/lhash.h
index b8ff021906..dee8207333 100644
--- a/src/lib/libssl/src/crypto/lhash/lhash.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/Makefile.ssl b/src/lib/libssl/src/crypto/md2/Makefile.ssl
index 269628d739..05a77ae4a5 100644
--- a/src/lib/libssl/src/crypto/md2/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/md2.h b/src/lib/libssl/src/crypto/md2/md2.h
index a00bd162b3..ad9241455c 100644
--- a/src/lib/libssl/src/crypto/md2/md2.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/md2_dgst.c b/src/lib/libssl/src/crypto/md2/md2_dgst.c
index 608baefa8f..e25dd00e02 100644
--- a/src/lib/libssl/src/crypto/md2/md2_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md2/md2test.c b/src/lib/libssl/src/crypto/md2/md2test.c
index e3f4fb4c34..7d3664faf5 100644
--- a/src/lib/libssl/src/crypto/md2/md2test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md32_common.h b/src/lib/libssl/src/crypto/md32_common.h
index 1a404a458d..353d2b96ad 100644
--- a/src/lib/libssl/src/crypto/md32_common.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/Makefile.ssl b/src/lib/libssl/src/crypto/md4/Makefile.ssl
index 646607274e..58c2b20a78 100644
--- a/src/lib/libssl/src/crypto/md4/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4.h b/src/lib/libssl/src/crypto/md4/md4.h
index c794e186db..7a7b23682f 100644
--- a/src/lib/libssl/src/crypto/md4/md4.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4_dgst.c b/src/lib/libssl/src/crypto/md4/md4_dgst.c
index 81488ae2e2..6446f5f5e7 100644
--- a/src/lib/libssl/src/crypto/md4/md4_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4_locl.h b/src/lib/libssl/src/crypto/md4/md4_locl.h
index 0a2b39018d..a8d31d7a73 100644
--- a/src/lib/libssl/src/crypto/md4/md4_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md4/md4test.c b/src/lib/libssl/src/crypto/md4/md4test.c
index 97e6e21efd..e0fdc42282 100644
--- a/src/lib/libssl/src/crypto/md4/md4test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/Makefile.ssl b/src/lib/libssl/src/crypto/md5/Makefile.ssl
index 784215579b..f9a1190efb 100644
--- a/src/lib/libssl/src/crypto/md5/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/asm/md5-sparcv9.S b/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S
index ca4257f134..a599ed5660 100644
--- a/src/lib/libssl/src/crypto/md5/asm/md5-sparcv9.S
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5.h b/src/lib/libssl/src/crypto/md5/md5.h
index d10bc8397f..52cb753e6a 100644
--- a/src/lib/libssl/src/crypto/md5/md5.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5_dgst.c b/src/lib/libssl/src/crypto/md5/md5_dgst.c
index 23d196b8d4..c38a3f021e 100644
--- a/src/lib/libssl/src/crypto/md5/md5_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5_locl.h b/src/lib/libssl/src/crypto/md5/md5_locl.h
index c912484122..34c5257306 100644
--- a/src/lib/libssl/src/crypto/md5/md5_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/md5/md5test.c b/src/lib/libssl/src/crypto/md5/md5test.c
index 6bd8656302..862b89658a 100644
--- a/src/lib/libssl/src/crypto/md5/md5test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/mdc2/Makefile.ssl b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
index a9b06b02bd..941d96c9e9 100644
--- a/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/mdc2/mdc2.h b/src/lib/libssl/src/crypto/mdc2/mdc2.h
index 5da8da72f5..793a8a0f13 100644
--- a/src/lib/libssl/src/crypto/mdc2/mdc2.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/mem.c b/src/lib/libssl/src/crypto/mem.c
index 3b5b2bbc68..effec714e8 100644
--- a/src/lib/libssl/src/crypto/mem.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/mem_dbg.c b/src/lib/libssl/src/crypto/mem_dbg.c
index ef19d8f844..1c4e04f51f 100644
--- a/src/lib/libssl/src/crypto/mem_dbg.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/o_time.c b/src/lib/libssl/src/crypto/o_time.c
new file mode 100644
index 0000000000..1bc0297b36
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/o_time.h b/src/lib/libssl/src/crypto/o_time.h
new file mode 100644
index 0000000000..e66044626d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/Makefile.ssl b/src/lib/libssl/src/crypto/objects/Makefile.ssl
index 6746ad21e7..7962a089db 100644
--- a/src/lib/libssl/src/crypto/objects/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/o_names.c b/src/lib/libssl/src/crypto/objects/o_names.c
index dca988230e..2b80243256 100644
--- a/src/lib/libssl/src/crypto/objects/o_names.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_dat.c b/src/lib/libssl/src/crypto/objects/obj_dat.c
index 4b1bb9583a..8779ba7d1d 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_dat.h b/src/lib/libssl/src/crypto/objects/obj_dat.h
new file mode 100644
index 0000000000..39cfcda783
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_dat.pl b/src/lib/libssl/src/crypto/objects/obj_dat.pl
index 11066df680..5dfb84ea00 100644
--- a/src/lib/libssl/src/crypto/objects/obj_dat.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_err.c b/src/lib/libssl/src/crypto/objects/obj_err.c
index 7aec0ed47a..80ab6855af 100644
--- a/src/lib/libssl/src/crypto/objects/obj_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_lib.c b/src/lib/libssl/src/crypto/objects/obj_lib.c
index 0c71639eba..b0b0f2ff24 100644
--- a/src/lib/libssl/src/crypto/objects/obj_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_mac.h b/src/lib/libssl/src/crypto/objects/obj_mac.h
index 401b1e5a1b..6d77fcba3f 100644
--- a/src/lib/libssl/src/crypto/objects/obj_mac.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/obj_mac.num b/src/lib/libssl/src/crypto/objects/obj_mac.num
index d73a51370f..02b39062fe 100644
--- a/src/lib/libssl/src/crypto/objects/obj_mac.num
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/objects.h b/src/lib/libssl/src/crypto/objects/objects.h
index c099e2e84e..de10532813 100644
--- a/src/lib/libssl/src/crypto/objects/objects.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/objects.pl b/src/lib/libssl/src/crypto/objects/objects.pl
index c956bbb841..76c06cc8f9 100644
--- a/src/lib/libssl/src/crypto/objects/objects.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/objects/objects.txt b/src/lib/libssl/src/crypto/objects/objects.txt
index 3d443cf884..65d0b15629 100644
--- a/src/lib/libssl/src/crypto/objects/objects.txt
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/Makefile.ssl b/src/lib/libssl/src/crypto/ocsp/Makefile.ssl
new file mode 100644
index 0000000000..b69abdc1c7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp.h b/src/lib/libssl/src/crypto/ocsp/ocsp.h
new file mode 100644
index 0000000000..fab3c03182
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_asn.c b/src/lib/libssl/src/crypto/ocsp/ocsp_asn.c
new file mode 100644
index 0000000000..8c148cda6a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_cl.c b/src/lib/libssl/src/crypto/ocsp/ocsp_cl.c
new file mode 100644
index 0000000000..9b3e6dd8ca
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_err.c b/src/lib/libssl/src/crypto/ocsp/ocsp_err.c
new file mode 100644
index 0000000000..4c4d8306f8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_ext.c b/src/lib/libssl/src/crypto/ocsp/ocsp_ext.c
new file mode 100644
index 0000000000..d6c8899f58
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_ht.c b/src/lib/libssl/src/crypto/ocsp/ocsp_ht.c
new file mode 100644
index 0000000000..b78cd37092
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_lib.c b/src/lib/libssl/src/crypto/ocsp/ocsp_lib.c
new file mode 100644
index 0000000000..3875af165c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_prn.c b/src/lib/libssl/src/crypto/ocsp/ocsp_prn.c
new file mode 100644
index 0000000000..4b7bc28769
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_srv.c b/src/lib/libssl/src/crypto/ocsp/ocsp_srv.c
new file mode 100644
index 0000000000..fffa134e75
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ocsp/ocsp_vfy.c b/src/lib/libssl/src/crypto/ocsp/ocsp_vfy.c
new file mode 100644
index 0000000000..1f5fda7ca3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/opensslconf.h.in b/src/lib/libssl/src/crypto/opensslconf.h.in
index 1b85ae5989..9082a16c46 100644
--- a/src/lib/libssl/src/crypto/opensslconf.h.in
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/opensslv.h b/src/lib/libssl/src/crypto/opensslv.h
index 4b25018e49..f45afe09f3 100644
--- a/src/lib/libssl/src/crypto/opensslv.h
+++ b/src/lib/libssl/src/crypto/opensslv.h
@@ -25,8 +25,8 @@
25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
26 * major minor fix final patch/beta) 26 * major minor fix final patch/beta)
27 */ 27 */
28#define OPENSSL_VERSION_NUMBER 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/libssl/src/crypto/ossl_typ.h b/src/lib/libssl/src/crypto/ossl_typ.h
new file mode 100644
index 0000000000..6bd42aee4d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/Makefile.ssl b/src/lib/libssl/src/crypto/pem/Makefile.ssl
index 31db6b65a1..2153723509 100644
--- a/src/lib/libssl/src/crypto/pem/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem.h b/src/lib/libssl/src/crypto/pem/pem.h
index 6d3c446577..3785fca77d 100644
--- a/src/lib/libssl/src/crypto/pem/pem.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_all.c b/src/lib/libssl/src/crypto/pem/pem_all.c
index dc9c35b4b4..e72b7134ce 100644
--- a/src/lib/libssl/src/crypto/pem/pem_all.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_err.c b/src/lib/libssl/src/crypto/pem/pem_err.c
index 8b1789b11c..3b39b84d66 100644
--- a/src/lib/libssl/src/crypto/pem/pem_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_info.c b/src/lib/libssl/src/crypto/pem/pem_info.c
index f1694f1125..9a6dffb45c 100644
--- a/src/lib/libssl/src/crypto/pem/pem_info.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_lib.c b/src/lib/libssl/src/crypto/pem/pem_lib.c
index a17c3ed57f..18b751a91a 100644
--- a/src/lib/libssl/src/crypto/pem/pem_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_oth.c b/src/lib/libssl/src/crypto/pem/pem_oth.c
new file mode 100644
index 0000000000..8d9064ea7c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_pk8.c b/src/lib/libssl/src/crypto/pem/pem_pk8.c
new file mode 100644
index 0000000000..f44182ffb5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_pkey.c b/src/lib/libssl/src/crypto/pem/pem_pkey.c
new file mode 100644
index 0000000000..270892d72b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_seal.c b/src/lib/libssl/src/crypto/pem/pem_seal.c
index 2a6c513348..ae463a301d 100644
--- a/src/lib/libssl/src/crypto/pem/pem_seal.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_sign.c b/src/lib/libssl/src/crypto/pem/pem_sign.c
index 42d598dd78..c3b9808cb2 100644
--- a/src/lib/libssl/src/crypto/pem/pem_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_x509.c b/src/lib/libssl/src/crypto/pem/pem_x509.c
new file mode 100644
index 0000000000..19f88d8d3a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pem/pem_xaux.c b/src/lib/libssl/src/crypto/pem/pem_xaux.c
new file mode 100644
index 0000000000..2f579b5421
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
index 10a7af8bff..9ceabf0705 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl
index d745c53621..d62f7eb7dd 100644
--- a/src/lib/libssl/src/crypto/pkcs12/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_add.c b/src/lib/libssl/src/crypto/pkcs12/p12_add.c
index b563656895..1909f28506 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_add.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_asn.c b/src/lib/libssl/src/crypto/pkcs12/p12_asn.c
new file mode 100644
index 0000000000..c327bdba03
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_attr.c b/src/lib/libssl/src/crypto/pkcs12/p12_attr.c
index a16a97d03d..026cf3826a 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_attr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_crpt.c b/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
index 7b96584f07..97be6a5fb5 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_crpt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_crt.c b/src/lib/libssl/src/crypto/pkcs12/p12_crt.c
index a8f7b48882..4c36c643ce 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_crt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_decr.c b/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
index 8cd7e2f414..394af368f4 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_decr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_init.c b/src/lib/libssl/src/crypto/pkcs12/p12_init.c
index d5d4884c82..eb837a78cf 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_init.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_key.c b/src/lib/libssl/src/crypto/pkcs12/p12_key.c
index a4fd5b98ec..0d39ebde8c 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_key.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_kiss.c b/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c
index 5d67f19b45..885087ad00 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_kiss.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_mutl.c b/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c
index 13d866da51..0fb67f74b8 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_mutl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_npas.c b/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
index 84e31a7f21..a549433eeb 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_npas.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_p8d.c b/src/lib/libssl/src/crypto/pkcs12/p12_p8d.c
new file mode 100644
index 0000000000..3c6f377933
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_p8e.c b/src/lib/libssl/src/crypto/pkcs12/p12_p8e.c
new file mode 100644
index 0000000000..3d47956652
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/p12_utl.c b/src/lib/libssl/src/crypto/pkcs12/p12_utl.c
index 2f1d1e534f..243ec76be9 100644
--- a/src/lib/libssl/src/crypto/pkcs12/p12_utl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/pk12err.c b/src/lib/libssl/src/crypto/pkcs12/pk12err.c
index 12db54f49e..10ab80502c 100644
--- a/src/lib/libssl/src/crypto/pkcs12/pk12err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs12/pkcs12.h b/src/lib/libssl/src/crypto/pkcs12/pkcs12.h
index e529154f26..1786b6d4f3 100644
--- a/src/lib/libssl/src/crypto/pkcs12/pkcs12.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
index 37b72f0890..3f0c3452e5 100644
--- a/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/bio_ber.c b/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
index 5447e69818..42331f7ab0 100644
--- a/src/lib/libssl/src/crypto/pkcs7/bio_ber.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/enc.c b/src/lib/libssl/src/crypto/pkcs7/enc.c
index 2b56c2eff3..7417f8a4e0 100644
--- a/src/lib/libssl/src/crypto/pkcs7/enc.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/example.c b/src/lib/libssl/src/crypto/pkcs7/example.c
index f6656be28e..c993947cc3 100644
--- a/src/lib/libssl/src/crypto/pkcs7/example.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_asn1.c b/src/lib/libssl/src/crypto/pkcs7/pk7_asn1.c
new file mode 100644
index 0000000000..46f0fc9375
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_attr.c b/src/lib/libssl/src/crypto/pkcs7/pk7_attr.c
index 6ae264cbf9..5ff5a88b5c 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_attr.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_doit.c b/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
index bf43d030ad..4a4ff340ce 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_doit.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_lib.c b/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c
index 45973fe850..c00ed6833a 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pk7_smime.c b/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
index 3d3214f5ee..f0d071e282 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pk7_smime.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pkcs7.h b/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
index 1b817e605d..5819700a85 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pkcs7.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/pkcs7err.c b/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c
index 8ded8913db..5e51527a40 100644
--- a/src/lib/libssl/src/crypto/pkcs7/pkcs7err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/sign.c b/src/lib/libssl/src/crypto/pkcs7/sign.c
index 22290e192c..8b59885f7e 100644
--- a/src/lib/libssl/src/crypto/pkcs7/sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/pkcs7/verify.c b/src/lib/libssl/src/crypto/pkcs7/verify.c
index 49fc8d8bed..5f7afe8933 100644
--- a/src/lib/libssl/src/crypto/pkcs7/verify.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/Makefile.ssl b/src/lib/libssl/src/crypto/rand/Makefile.ssl
index 707eaac678..42623d18d8 100644
--- a/src/lib/libssl/src/crypto/rand/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/md_rand.c b/src/lib/libssl/src/crypto/rand/md_rand.c
index 04b9d695b0..a00ed70718 100644
--- a/src/lib/libssl/src/crypto/rand/md_rand.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand.h b/src/lib/libssl/src/crypto/rand/rand.h
index 9c6052733e..e17aa7a9f7 100644
--- a/src/lib/libssl/src/crypto/rand/rand.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_egd.c b/src/lib/libssl/src/crypto/rand/rand_egd.c
index 79b5e6fa57..dd490c8254 100644
--- a/src/lib/libssl/src/crypto/rand/rand_egd.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_err.c b/src/lib/libssl/src/crypto/rand/rand_err.c
index 1af0aa0b8a..b77267e213 100644
--- a/src/lib/libssl/src/crypto/rand/rand_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_lcl.h b/src/lib/libssl/src/crypto/rand/rand_lcl.h
index 120e9366d2..618a8ec899 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lcl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_lib.c b/src/lib/libssl/src/crypto/rand/rand_lib.c
index 57eff0f132..5cf5dc1188 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_os2.c b/src/lib/libssl/src/crypto/rand/rand_os2.c
new file mode 100644
index 0000000000..c3e36d4e5e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_unix.c b/src/lib/libssl/src/crypto/rand/rand_unix.c
new file mode 100644
index 0000000000..0b29235130
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_vms.c b/src/lib/libssl/src/crypto/rand/rand_vms.c
new file mode 100644
index 0000000000..29b2d7af0b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/rand_win.c b/src/lib/libssl/src/crypto/rand/rand_win.c
index 3d137badd0..c1b955b06f 100644
--- a/src/lib/libssl/src/crypto/rand/rand_win.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/randfile.c b/src/lib/libssl/src/crypto/rand/randfile.c
index c4eb79ac5f..4b221e08f5 100644
--- a/src/lib/libssl/src/crypto/rand/randfile.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rand/randtest.c b/src/lib/libssl/src/crypto/rand/randtest.c
index da96e3f695..b64de616db 100644
--- a/src/lib/libssl/src/crypto/rand/randtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc2/Makefile.ssl b/src/lib/libssl/src/crypto/rc2/Makefile.ssl
index 39813d68be..73ebbfa400 100644
--- a/src/lib/libssl/src/crypto/rc2/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc2/rc2.h b/src/lib/libssl/src/crypto/rc2/rc2.h
index 076c0a067c..7816b454dc 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc2/rc2speed.c b/src/lib/libssl/src/crypto/rc2/rc2speed.c
index 9f7f5ccfa3..47d34b444e 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2speed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc2/rc2test.c b/src/lib/libssl/src/crypto/rc2/rc2test.c
index 521269ded1..d9a2a0a1cb 100644
--- a/src/lib/libssl/src/crypto/rc2/rc2test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/Makefile.ssl b/src/lib/libssl/src/crypto/rc4/Makefile.ssl
index e75858d3b9..25d9e4344c 100644
--- a/src/lib/libssl/src/crypto/rc4/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4.c b/src/lib/libssl/src/crypto/rc4/rc4.c
index bfb0a3c1f9..c2165b0b75 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4.h b/src/lib/libssl/src/crypto/rc4/rc4.h
index 40251024a4..8722091f2e 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4speed.c b/src/lib/libssl/src/crypto/rc4/rc4speed.c
index b448f4a5c6..ced98c52df 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4speed.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc4/rc4test.c b/src/lib/libssl/src/crypto/rc4/rc4test.c
index 3914eb6c38..a28d457c8d 100644
--- a/src/lib/libssl/src/crypto/rc4/rc4test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc5/Makefile.ssl b/src/lib/libssl/src/crypto/rc5/Makefile.ssl
index c8ee124776..25740ab961 100644
--- a/src/lib/libssl/src/crypto/rc5/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rc5/rc5.h b/src/lib/libssl/src/crypto/rc5/rc5.h
index fc4cea5e36..4adfd2db5a 100644
--- a/src/lib/libssl/src/crypto/rc5/rc5.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rijndael/Makefile.ssl b/src/lib/libssl/src/crypto/rijndael/Makefile.ssl
new file mode 100644
index 0000000000..ddc480e9d7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rijndael/README b/src/lib/libssl/src/crypto/rijndael/README
new file mode 100644
index 0000000000..1118ccbad8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rijndael/rd_fst.c b/src/lib/libssl/src/crypto/rijndael/rd_fst.c
new file mode 100644
index 0000000000..f1597288f0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rijndael/rd_fst.h b/src/lib/libssl/src/crypto/rijndael/rd_fst.h
new file mode 100644
index 0000000000..fcace29478
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rijndael/rijndael.h b/src/lib/libssl/src/crypto/rijndael/rijndael.h
new file mode 100644
index 0000000000..72edcc2942
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/Makefile.ssl b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
index 1550c32ca1..a3a6563a5b 100644
--- a/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/ripemd.h b/src/lib/libssl/src/crypto/ripemd/ripemd.h
index dd1627cf40..78d5f36560 100644
--- a/src/lib/libssl/src/crypto/ripemd/ripemd.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmd_dgst.c b/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
index bdfae270b6..a3170f7c8a 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmd_locl.h b/src/lib/libssl/src/crypto/ripemd/rmd_locl.h
index f537b88867..7b835dfbd4 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmd_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ripemd/rmdtest.c b/src/lib/libssl/src/crypto/ripemd/rmdtest.c
index 5d79c99725..19e9741db2 100644
--- a/src/lib/libssl/src/crypto/ripemd/rmdtest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/Makefile.ssl b/src/lib/libssl/src/crypto/rsa/Makefile.ssl
index 2bee181d4e..8a9f7cbe0c 100644
--- a/src/lib/libssl/src/crypto/rsa/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa.h b/src/lib/libssl/src/crypto/rsa/rsa.h
index bda636a365..030a6c88e5 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_asn1.c b/src/lib/libssl/src/crypto/rsa/rsa_asn1.c
new file mode 100644
index 0000000000..1455a7e0e4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_chk.c b/src/lib/libssl/src/crypto/rsa/rsa_chk.c
index 91b9115798..002f2cb487 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_chk.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
index cde5ca27d5..d82dd15493 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_err.c b/src/lib/libssl/src/crypto/rsa/rsa_err.c
index 1cde7c0da4..a7766c3b76 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
index 94395cc22c..93235744f7 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_none.c b/src/lib/libssl/src/crypto/rsa/rsa_none.c
index f22fce5016..e6f3e627ca 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_none.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_null.c b/src/lib/libssl/src/crypto/rsa/rsa_null.c
index 7b58a0eca3..64057fbdcf 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_null.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_oaep.c b/src/lib/libssl/src/crypto/rsa/rsa_oaep.c
index 1849e55cd5..e3f7c608ec 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_oaep.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_pk1.c b/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
index 48a32bc264..c1edd6764f 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_pk1.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_saos.c b/src/lib/libssl/src/crypto/rsa/rsa_saos.c
index c77f4381ff..85adacc08f 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_saos.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_sign.c b/src/lib/libssl/src/crypto/rsa/rsa_sign.c
index cf00876292..2a440901de 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_sign.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_ssl.c b/src/lib/libssl/src/crypto/rsa/rsa_ssl.c
index 482f4a8273..ea72629494 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_ssl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/rsa/rsa_test.c b/src/lib/libssl/src/crypto/rsa/rsa_test.c
index e5ae0c1f69..b8b462d33b 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/Makefile.ssl b/src/lib/libssl/src/crypto/sha/Makefile.ssl
index 790e572fa2..f203ad7681 100644
--- a/src/lib/libssl/src/crypto/sha/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha.h b/src/lib/libssl/src/crypto/sha/sha.h
index 77f6d9695e..3fd54a10cc 100644
--- a/src/lib/libssl/src/crypto/sha/sha.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha1_one.c b/src/lib/libssl/src/crypto/sha/sha1_one.c
index 861752eaa7..e6a24888ed 100644
--- a/src/lib/libssl/src/crypto/sha/sha1_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha1dgst.c b/src/lib/libssl/src/crypto/sha/sha1dgst.c
index c09edb4cd7..182f65982a 100644
--- a/src/lib/libssl/src/crypto/sha/sha1dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha1test.c b/src/lib/libssl/src/crypto/sha/sha1test.c
index 688d06c637..499a1cf5af 100644
--- a/src/lib/libssl/src/crypto/sha/sha1test.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha_dgst.c b/src/lib/libssl/src/crypto/sha/sha_dgst.c
index 894a96274a..5a4b3ab204 100644
--- a/src/lib/libssl/src/crypto/sha/sha_dgst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha_locl.h b/src/lib/libssl/src/crypto/sha/sha_locl.h
index 2f8aef83f3..471dfb9f8f 100644
--- a/src/lib/libssl/src/crypto/sha/sha_locl.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/sha_one.c b/src/lib/libssl/src/crypto/sha/sha_one.c
index 2d955de162..5426faae4a 100644
--- a/src/lib/libssl/src/crypto/sha/sha_one.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/sha/shatest.c b/src/lib/libssl/src/crypto/sha/shatest.c
index a5786bbf76..331294a74f 100644
--- a/src/lib/libssl/src/crypto/sha/shatest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/stack/Makefile.ssl b/src/lib/libssl/src/crypto/stack/Makefile.ssl
index c916fd5451..23b24040bc 100644
--- a/src/lib/libssl/src/crypto/stack/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/stack/safestack.h b/src/lib/libssl/src/crypto/stack/safestack.h
index 9fa63e1be5..ed9ed2c23a 100644
--- a/src/lib/libssl/src/crypto/stack/safestack.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/stack/stack.c b/src/lib/libssl/src/crypto/stack/stack.c
index 02857f0446..2496f28a8c 100644
--- a/src/lib/libssl/src/crypto/stack/stack.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/symhacks.h b/src/lib/libssl/src/crypto/symhacks.h
index 358ad355bb..de0f452b47 100644
--- a/src/lib/libssl/src/crypto/symhacks.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/threads/mttest.c b/src/lib/libssl/src/crypto/threads/mttest.c
index 019add4d9c..c474a63c74 100644
--- a/src/lib/libssl/src/crypto/threads/mttest.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/threads/th-lock.c b/src/lib/libssl/src/crypto/threads/th-lock.c
index 553d2218de..a6a79b9f45 100644
--- a/src/lib/libssl/src/crypto/threads/th-lock.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/tmdiff.c b/src/lib/libssl/src/crypto/tmdiff.c
index 7773928666..7ebf2b202a 100644
--- a/src/lib/libssl/src/crypto/tmdiff.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/txt_db/Makefile.ssl b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
index ee054e91f2..8af2fa4cd6 100644
--- a/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/txt_db/txt_db.c b/src/lib/libssl/src/crypto/txt_db/txt_db.c
index 3b04fe280c..e6334d6add 100644
--- a/src/lib/libssl/src/crypto/txt_db/txt_db.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/txt_db/txt_db.h b/src/lib/libssl/src/crypto/txt_db/txt_db.h
index 342533d40d..563392aeff 100644
--- a/src/lib/libssl/src/crypto/txt_db/txt_db.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/Makefile.ssl b/src/lib/libssl/src/crypto/ui/Makefile.ssl
new file mode 100644
index 0000000000..d51c1ff67a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui.h b/src/lib/libssl/src/crypto/ui/ui.h
new file mode 100644
index 0000000000..735a2d988e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_compat.c b/src/lib/libssl/src/crypto/ui/ui_compat.c
new file mode 100644
index 0000000000..13e0f70d90
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_compat.h b/src/lib/libssl/src/crypto/ui/ui_compat.h
new file mode 100644
index 0000000000..b35c9bb7fd
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_err.c b/src/lib/libssl/src/crypto/ui/ui_err.c
new file mode 100644
index 0000000000..39a62ae737
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
new file mode 100644
index 0000000000..16946cad95
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_locl.h b/src/lib/libssl/src/crypto/ui/ui_locl.h
new file mode 100644
index 0000000000..7d3a75a619
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c
new file mode 100644
index 0000000000..3aa03f74aa
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/ui/ui_util.c b/src/lib/libssl/src/crypto/ui/ui_util.c
new file mode 100644
index 0000000000..7c6f7d3a73
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/uid.c b/src/lib/libssl/src/crypto/uid.c
index b5b61b76d4..d3d249c36f 100644
--- a/src/lib/libssl/src/crypto/uid.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/Makefile.ssl b/src/lib/libssl/src/crypto/x509/Makefile.ssl
index 79f09d4f71..62243ae812 100644
--- a/src/lib/libssl/src/crypto/x509/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/by_file.c b/src/lib/libssl/src/crypto/x509/by_file.c
index 78e9240a8d..92e00d2d73 100644
--- a/src/lib/libssl/src/crypto/x509/by_file.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509.h b/src/lib/libssl/src/crypto/x509/x509.h
index 813c8adffd..c75aa0c717 100644
--- a/src/lib/libssl/src/crypto/x509/x509.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_att.c b/src/lib/libssl/src/crypto/x509/x509_att.c
index caafde658f..0bae3d32a1 100644
--- a/src/lib/libssl/src/crypto/x509/x509_att.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_cmp.c b/src/lib/libssl/src/crypto/x509/x509_cmp.c
index 3f9f9b3d47..cd20b6d66f 100644
--- a/src/lib/libssl/src/crypto/x509/x509_cmp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_d2.c b/src/lib/libssl/src/crypto/x509/x509_d2.c
index 753d53eb43..51410cfd1a 100644
--- a/src/lib/libssl/src/crypto/x509/x509_d2.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_err.c b/src/lib/libssl/src/crypto/x509/x509_err.c
index 848add56e9..5bbf4acf76 100644
--- a/src/lib/libssl/src/crypto/x509/x509_err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_ext.c b/src/lib/libssl/src/crypto/x509/x509_ext.c
index 2955989807..e7fdacb5e4 100644
--- a/src/lib/libssl/src/crypto/x509/x509_ext.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_lu.c b/src/lib/libssl/src/crypto/x509/x509_lu.c
index 863c738cad..b780dae5e2 100644
--- a/src/lib/libssl/src/crypto/x509/x509_lu.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_obj.c b/src/lib/libssl/src/crypto/x509/x509_obj.c
index f0271fdfa1..1e718f76eb 100644
--- a/src/lib/libssl/src/crypto/x509/x509_obj.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_req.c b/src/lib/libssl/src/crypto/x509/x509_req.c
index 7eca1bd57a..0affa3bf30 100644
--- a/src/lib/libssl/src/crypto/x509/x509_req.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_trs.c b/src/lib/libssl/src/crypto/x509/x509_trs.c
index 86b3b79dcc..17d69ac005 100644
--- a/src/lib/libssl/src/crypto/x509/x509_trs.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_txt.c b/src/lib/libssl/src/crypto/x509/x509_txt.c
index cfb478d4bc..4f83db8ba2 100644
--- a/src/lib/libssl/src/crypto/x509/x509_txt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_v3.c b/src/lib/libssl/src/crypto/x509/x509_v3.c
index 52887986fe..b5f7daa2e5 100644
--- a/src/lib/libssl/src/crypto/x509/x509_v3.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_vfy.c b/src/lib/libssl/src/crypto/x509/x509_vfy.c
index 0f4110cc64..db12f7bd35 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509_vfy.h b/src/lib/libssl/src/crypto/x509/x509_vfy.h
index e289d5309a..f0be21f452 100644
--- a/src/lib/libssl/src/crypto/x509/x509_vfy.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509cset.c b/src/lib/libssl/src/crypto/x509/x509cset.c
new file mode 100644
index 0000000000..6cac440ea9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x509spki.c b/src/lib/libssl/src/crypto/x509/x509spki.c
index fd0a534d88..4c3af946ec 100644
--- a/src/lib/libssl/src/crypto/x509/x509spki.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509/x_all.c b/src/lib/libssl/src/crypto/x509/x_all.c
index 9bd6e2a39b..fb5015cd4d 100644
--- a/src/lib/libssl/src/crypto/x509/x_all.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/Makefile.ssl b/src/lib/libssl/src/crypto/x509v3/Makefile.ssl
index 236e13af4e..8620992280 100644
--- a/src/lib/libssl/src/crypto/x509v3/Makefile.ssl
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/ext_dat.h b/src/lib/libssl/src/crypto/x509v3/ext_dat.h
index 801a585a52..586f116db5 100644
--- a/src/lib/libssl/src/crypto/x509v3/ext_dat.h
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_akey.c b/src/lib/libssl/src/crypto/x509v3/v3_akey.c
index 0889a18993..97e686f97a 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_akey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_akeya.c b/src/lib/libssl/src/crypto/x509v3/v3_akeya.c
new file mode 100644
index 0000000000..2aafa26ba7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_alt.c b/src/lib/libssl/src/crypto/x509v3/v3_alt.c
index 94bebcd448..0e9e7dcb4f 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_alt.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_bcons.c b/src/lib/libssl/src/crypto/x509v3/v3_bcons.c
index c576b8e955..cbb012715e 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_bcons.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_bitst.c b/src/lib/libssl/src/crypto/x509v3/v3_bitst.c
index 0e1167d05c..16cf125562 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_bitst.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_conf.c b/src/lib/libssl/src/crypto/x509v3/v3_conf.c
index bdc9c1cbc1..1a3448e121 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_conf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_cpols.c b/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
index 8203ed7571..0d4ab1f680 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_cpols.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_crld.c b/src/lib/libssl/src/crypto/x509v3/v3_crld.c
index 67feea4017..894a8b94d8 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_crld.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_enum.c b/src/lib/libssl/src/crypto/x509v3/v3_enum.c
index aecfdc87f8..010c9d6260 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_enum.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_extku.c b/src/lib/libssl/src/crypto/x509v3/v3_extku.c
index 53ec40a027..b1cfaba1aa 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_extku.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_genn.c b/src/lib/libssl/src/crypto/x509v3/v3_genn.c
index d44751458e..650b510980 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_genn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_info.c b/src/lib/libssl/src/crypto/x509v3/v3_info.c
index a045a629ee..7f17f3231d 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_info.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_int.c b/src/lib/libssl/src/crypto/x509v3/v3_int.c
index 63c201e5f4..f34cbfb731 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_int.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_lib.c b/src/lib/libssl/src/crypto/x509v3/v3_lib.c
index ea86b9ebb9..482ca8ccf5 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_lib.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_ocsp.c b/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c
new file mode 100644
index 0000000000..083112314e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_pku.c b/src/lib/libssl/src/crypto/x509v3/v3_pku.c
index 47f9e8f123..49a2e4697a 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_pku.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_prn.c b/src/lib/libssl/src/crypto/x509v3/v3_prn.c
index 14b804c4ad..aeaf6170fe 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_prn.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_purp.c b/src/lib/libssl/src/crypto/x509v3/v3_purp.c
index 8aecd00e63..b739e4fd83 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_purp.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_skey.c b/src/lib/libssl/src/crypto/x509v3/v3_skey.c
index 939845fa8f..c0f044ac1b 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_skey.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_sxnet.c b/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c
index bfecacd336..d3f4ba3a72 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_sxnet.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3_utl.c b/src/lib/libssl/src/crypto/x509v3/v3_utl.c
index 619f161b58..283e943e46 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3_utl.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3conf.c b/src/lib/libssl/src/crypto/x509v3/v3conf.c
index 21cf746f45..67ee14f334 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3conf.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3err.c b/src/lib/libssl/src/crypto/x509v3/v3err.c
index aa4a605dc4..6458e95bb9 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3err.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/v3prin.c b/src/lib/libssl/src/crypto/x509v3/v3prin.c
index ee798859f0..b529814319 100644
--- a/src/lib/libssl/src/crypto/x509v3/v3prin.c
+++ b/src/lib/libssl/src/crypto/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/libssl/src/crypto/x509v3/x509v3.h b/src/lib/libssl/src/crypto/x509v3/x509v3.h
index 0453b12d63..daecc55271 100644
--- a/src/lib/libssl/src/crypto/x509v3/x509v3.h
+++ b/src/lib/libssl/src/crypto/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
diff --git a/src/lib/libssl/src/demos/asn1/README.ASN1 b/src/lib/libssl/src/demos/asn1/README.ASN1
new file mode 100644
index 0000000000..ac497be184
--- /dev/null
+++ b/src/lib/libssl/src/demos/asn1/README.ASN1
@@ -0,0 +1,7 @@
1This is a demo of the new ASN1 code. Its an OCSP ASN1 module. Doesn't
2do much yet other than demonstrate what the new ASN1 modules might look
3like.
4
5It wont even compile yet: the new code isn't in place.
6
7
diff --git a/src/lib/libssl/src/demos/asn1/ocsp.c b/src/lib/libssl/src/demos/asn1/ocsp.c
new file mode 100644
index 0000000000..0199fe1004
--- /dev/null
+++ b/src/lib/libssl/src/demos/asn1/ocsp.c
@@ -0,0 +1,366 @@
1/* ocsp.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/x509v3.h>
61
62
63
64
65/* Example of new ASN1 code, OCSP request
66
67 OCSPRequest ::= SEQUENCE {
68 tbsRequest TBSRequest,
69 optionalSignature [0] EXPLICIT Signature OPTIONAL }
70
71 TBSRequest ::= SEQUENCE {
72 version [0] EXPLICIT Version DEFAULT v1,
73 requestorName [1] EXPLICIT GeneralName OPTIONAL,
74 requestList SEQUENCE OF Request,
75 requestExtensions [2] EXPLICIT Extensions OPTIONAL }
76
77 Signature ::= SEQUENCE {
78 signatureAlgorithm AlgorithmIdentifier,
79 signature BIT STRING,
80 certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
81
82 Version ::= INTEGER { v1(0) }
83
84 Request ::= SEQUENCE {
85 reqCert CertID,
86 singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
87
88 CertID ::= SEQUENCE {
89 hashAlgorithm AlgorithmIdentifier,
90 issuerNameHash OCTET STRING, -- Hash of Issuer's DN
91 issuerKeyHash OCTET STRING, -- Hash of Issuers public key
92 serialNumber CertificateSerialNumber }
93
94 OCSPResponse ::= SEQUENCE {
95 responseStatus OCSPResponseStatus,
96 responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
97
98 OCSPResponseStatus ::= ENUMERATED {
99 successful (0), --Response has valid confirmations
100 malformedRequest (1), --Illegal confirmation request
101 internalError (2), --Internal error in issuer
102 tryLater (3), --Try again later
103 --(4) is not used
104 sigRequired (5), --Must sign the request
105 unauthorized (6) --Request unauthorized
106 }
107
108 ResponseBytes ::= SEQUENCE {
109 responseType OBJECT IDENTIFIER,
110 response OCTET STRING }
111
112 BasicOCSPResponse ::= SEQUENCE {
113 tbsResponseData ResponseData,
114 signatureAlgorithm AlgorithmIdentifier,
115 signature BIT STRING,
116 certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
117
118 ResponseData ::= SEQUENCE {
119 version [0] EXPLICIT Version DEFAULT v1,
120 responderID ResponderID,
121 producedAt GeneralizedTime,
122 responses SEQUENCE OF SingleResponse,
123 responseExtensions [1] EXPLICIT Extensions OPTIONAL }
124
125 ResponderID ::= CHOICE {
126 byName [1] Name, --EXPLICIT
127 byKey [2] KeyHash }
128
129 KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
130 --(excluding the tag and length fields)
131
132 SingleResponse ::= SEQUENCE {
133 certID CertID,
134 certStatus CertStatus,
135 thisUpdate GeneralizedTime,
136 nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
137 singleExtensions [1] EXPLICIT Extensions OPTIONAL }
138
139 CertStatus ::= CHOICE {
140 good [0] IMPLICIT NULL,
141 revoked [1] IMPLICIT RevokedInfo,
142 unknown [2] IMPLICIT UnknownInfo }
143
144 RevokedInfo ::= SEQUENCE {
145 revocationTime GeneralizedTime,
146 revocationReason [0] EXPLICIT CRLReason OPTIONAL }
147
148 UnknownInfo ::= NULL -- this can be replaced with an enumeration
149
150 ArchiveCutoff ::= GeneralizedTime
151
152 AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER
153
154 ServiceLocator ::= SEQUENCE {
155 issuer Name,
156 locator AuthorityInfoAccessSyntax }
157
158 -- Object Identifiers
159
160 id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 }
161 id-pkix-ocsp OBJECT IDENTIFIER ::= { id-ad-ocsp }
162 id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 }
163 id-pkix-ocsp-nonce OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
164 id-pkix-ocsp-crl OBJECT IDENTIFIER ::= { id-pkix-ocsp 3 }
165 id-pkix-ocsp-response OBJECT IDENTIFIER ::= { id-pkix-ocsp 4 }
166 id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
167 id-pkix-ocsp-archive-cutoff OBJECT IDENTIFIER ::= { id-pkix-ocsp 6 }
168 id-pkix-ocsp-service-locator OBJECT IDENTIFIER ::= { id-pkix-ocsp 7 }
169
170*/
171
172/* Request Structures */
173
174DECLARE_STACK_OF(Request)
175
176typedef struct {
177 ASN1_INTEGER *version;
178 GENERAL_NAME *requestorName;
179 STACK_OF(Request) *requestList;
180 STACK_OF(X509_EXTENSION) *requestExtensions;
181} TBSRequest;
182
183typedef struct {
184 X509_ALGOR *signatureAlgorithm;
185 ASN1_BIT_STRING *signature;
186 STACK_OF(X509) *certs;
187} Signature;
188
189typedef struct {
190 TBSRequest *tbsRequest;
191 Signature *optionalSignature;
192} OCSPRequest;
193
194typedef struct {
195 X509_ALGOR *hashAlgorithm;
196 ASN1_OCTET_STRING *issuerNameHash;
197 ASN1_OCTET_STRING *issuerKeyHash;
198 ASN1_INTEGER *certificateSerialNumber;
199} CertID;
200
201typedef struct {
202 CertID *reqCert;
203 STACK_OF(X509_EXTENSION) *singleRequestExtensions;
204} Request;
205
206/* Response structures */
207
208typedef struct {
209 ASN1_OBJECT *responseType;
210 ASN1_OCTET_STRING *response;
211} ResponseBytes;
212
213typedef struct {
214 ASN1_ENUMERATED *responseStatus;
215 ResponseBytes *responseBytes;
216} OCSPResponse;
217
218typedef struct {
219 int type;
220 union {
221 X509_NAME *byName;
222 ASN1_OCTET_STRING *byKey;
223 }d;
224} ResponderID;
225
226typedef struct {
227 ASN1_INTEGER *version;
228 ResponderID *responderID;
229 ASN1_GENERALIZEDTIME *producedAt;
230 STACK_OF(SingleResponse) *responses;
231 STACK_OF(X509_EXTENSION) *responseExtensions;
232} ResponseData;
233
234typedef struct {
235 ResponseData *tbsResponseData;
236 X509_ALGOR *signatureAlgorithm;
237 ASN1_BIT_STRING *signature;
238 STACK_OF(X509) *certs;
239} BasicOCSPResponse;
240
241typedef struct {
242 ASN1_GENERALIZEDTIME *revocationTime;
243 ASN1_ENUMERATED * revocationReason;
244} RevokedInfo;
245
246typedef struct {
247 int type;
248 union {
249 ASN1_NULL *good;
250 RevokedInfo *revoked;
251 ASN1_NULL *unknown;
252 } d;
253} CertStatus;
254
255typedef struct {
256 CertID *certID;
257 CertStatus *certStatus;
258 ASN1_GENERALIZEDTIME *thisUpdate;
259 ASN1_GENERALIZEDTIME *nextUpdate;
260 STACK_OF(X509_EXTENSION) *singleExtensions;
261} SingleResponse;
262
263
264typedef struct {
265 X509_NAME *issuer;
266 STACK_OF(ACCESS_DESCRIPTION) *locator;
267} ServiceLocator;
268
269
270/* Now the ASN1 templates */
271
272IMPLEMENT_COMPAT_ASN1(X509);
273IMPLEMENT_COMPAT_ASN1(X509_ALGOR);
274//IMPLEMENT_COMPAT_ASN1(X509_EXTENSION);
275IMPLEMENT_COMPAT_ASN1(GENERAL_NAME);
276IMPLEMENT_COMPAT_ASN1(X509_NAME);
277
278ASN1_SEQUENCE(X509_EXTENSION) = {
279 ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT),
280 ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN),
281 ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING)
282} ASN1_SEQUENCE_END(X509_EXTENSION);
283
284
285ASN1_SEQUENCE(Signature) = {
286 ASN1_SIMPLE(Signature, signatureAlgorithm, X509_ALGOR),
287 ASN1_SIMPLE(Signature, signature, ASN1_BIT_STRING),
288 ASN1_SEQUENCE_OF(Signature, certs, X509)
289} ASN1_SEQUENCE_END(Signature);
290
291ASN1_SEQUENCE(CertID) = {
292 ASN1_SIMPLE(CertID, hashAlgorithm, X509_ALGOR),
293 ASN1_SIMPLE(CertID, issuerNameHash, ASN1_OCTET_STRING),
294 ASN1_SIMPLE(CertID, issuerKeyHash, ASN1_OCTET_STRING),
295 ASN1_SIMPLE(CertID, certificateSerialNumber, ASN1_INTEGER)
296} ASN1_SEQUENCE_END(CertID);
297
298ASN1_SEQUENCE(Request) = {
299 ASN1_SIMPLE(Request, reqCert, CertID),
300 ASN1_EXP_SEQUENCE_OF_OPT(Request, singleRequestExtensions, X509_EXTENSION, 0)
301} ASN1_SEQUENCE_END(Request);
302
303ASN1_SEQUENCE(TBSRequest) = {
304 ASN1_EXP_OPT(TBSRequest, version, ASN1_INTEGER, 0),
305 ASN1_EXP_OPT(TBSRequest, requestorName, GENERAL_NAME, 1),
306 ASN1_SEQUENCE_OF(TBSRequest, requestList, Request),
307 ASN1_EXP_SEQUENCE_OF_OPT(TBSRequest, requestExtensions, X509_EXTENSION, 2)
308} ASN1_SEQUENCE_END(TBSRequest);
309
310ASN1_SEQUENCE(OCSPRequest) = {
311 ASN1_SIMPLE(OCSPRequest, tbsRequest, TBSRequest),
312 ASN1_EXP_OPT(OCSPRequest, optionalSignature, Signature, 0)
313} ASN1_SEQUENCE_END(OCSPRequest);
314
315
316/* Response templates */
317
318ASN1_SEQUENCE(ResponseBytes) = {
319 ASN1_SIMPLE(ResponseBytes, responseType, ASN1_OBJECT),
320 ASN1_SIMPLE(ResponseBytes, response, ASN1_OCTET_STRING)
321} ASN1_SEQUENCE_END(ResponseBytes);
322
323ASN1_SEQUENCE(OCSPResponse) = {
324 ASN1_SIMPLE(OCSPResponse, responseStatus, ASN1_ENUMERATED),
325 ASN1_EXP_OPT(OCSPResponse, responseBytes, ResponseBytes, 0)
326} ASN1_SEQUENCE_END(OCSPResponse);
327
328ASN1_CHOICE(ResponderID) = {
329 ASN1_EXP(ResponderID, d.byName, X509_NAME, 1),
330 ASN1_IMP(ResponderID, d.byKey, ASN1_OCTET_STRING, 2)
331} ASN1_CHOICE_END(ResponderID);
332
333ASN1_SEQUENCE(RevokedInfo) = {
334 ASN1_SIMPLE(RevokedInfo, revocationTime, ASN1_GENERALIZEDTIME),
335 ASN1_EXP_OPT(RevokedInfo, revocationReason, ASN1_ENUMERATED, 0)
336} ASN1_SEQUENCE_END(RevokedInfo);
337
338ASN1_CHOICE(CertStatus) = {
339 ASN1_IMP(CertStatus, d.good, ASN1_NULL, 0),
340 ASN1_IMP(CertStatus, d.revoked, RevokedInfo, 1),
341 ASN1_IMP(CertStatus, d.unknown, ASN1_NULL, 2)
342} ASN1_CHOICE_END(CertStatus);
343
344ASN1_SEQUENCE(SingleResponse) = {
345 ASN1_SIMPLE(SingleResponse, certID, CertID),
346 ASN1_SIMPLE(SingleResponse, certStatus, CertStatus),
347 ASN1_SIMPLE(SingleResponse, thisUpdate, ASN1_GENERALIZEDTIME),
348 ASN1_EXP_OPT(SingleResponse, nextUpdate, ASN1_GENERALIZEDTIME, 0),
349 ASN1_EXP_SEQUENCE_OF_OPT(SingleResponse, singleExtensions, X509_EXTENSION, 1)
350} ASN1_SEQUENCE_END(SingleResponse);
351
352ASN1_SEQUENCE(ResponseData) = {
353 ASN1_EXP_OPT(ResponseData, version, ASN1_INTEGER, 0),
354 ASN1_SIMPLE(ResponseData, responderID, ResponderID),
355 ASN1_SIMPLE(ResponseData, producedAt, ASN1_GENERALIZEDTIME),
356 ASN1_SEQUENCE_OF(ResponseData, responses, SingleResponse),
357 ASN1_EXP_SEQUENCE_OF_OPT(ResponseData, responseExtensions, X509_EXTENSION, 1)
358} ASN1_SEQUENCE_END(ResponseData);
359
360ASN1_SEQUENCE(BasicOCSPResponse) = {
361 ASN1_SIMPLE(BasicOCSPResponse, tbsResponseData, ResponseData),
362 ASN1_SIMPLE(BasicOCSPResponse, signatureAlgorithm, X509_ALGOR),
363 ASN1_SIMPLE(BasicOCSPResponse, signature, ASN1_BIT_STRING),
364 ASN1_EXP_SEQUENCE_OF_OPT(BasicOCSPResponse, certs, X509, 0)
365} ASN1_SEQUENCE_END(BasicOCSPResponse);
366
diff --git a/src/lib/libssl/src/demos/b64.c b/src/lib/libssl/src/demos/b64.c
index 8e248e7e72..113da89baf 100644
--- a/src/lib/libssl/src/demos/b64.c
+++ b/src/lib/libssl/src/demos/b64.c
@@ -91,8 +91,8 @@ char **argv;
91 EVP_CIPHER *cipher=NULL,*c; 91 EVP_CIPHER *cipher=NULL,*c;
92 char *inf=NULL,*outf=NULL; 92 char *inf=NULL,*outf=NULL;
93 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; 93 BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
94#define PROG_NAME_SIZE 16 94#define PROG_NAME_SIZE 39
95 char pname[PROG_NAME_SIZE]; 95 char pname[PROG_NAME_SIZE+1];
96 96
97 97
98 apps_startup(); 98 apps_startup();
diff --git a/src/lib/libssl/src/demos/easy_tls/Makefile b/src/lib/libssl/src/demos/easy_tls/Makefile
new file mode 100644
index 0000000000..fd3c246ef4
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/Makefile
@@ -0,0 +1,123 @@
1# Makefile for easy-tls example application (rudimentary client and server)
2# $Id: Makefile,v 1.1 2002/05/15 02:29:18 beck Exp $
3
4SOLARIS_CFLAGS=-Wall -pedantic -g -O2
5SOLARIS_LIBS=-lxnet
6
7LINUX_CFLAGS=-Wall -pedantic -g -O2
8LINUX_LIBS=
9
10
11auto-all:
12 case `uname -s` in \
13 SunOS) echo Using SunOS configuration; \
14 make SYSCFLAGS="$(SOLARIS_CFLAGS)" SYSLIBS="$(SOLARIS_LIBS)" all;; \
15 Linux) echo Using Linux configuration; \
16 make SYSCFLAGS="$(LINUX_CFLAGS)" SYSLIBS="$(LINUX_LIBS)" all;; \
17 *) echo "unknown system"; exit 1;; \
18 esac
19
20all: test TAGS
21
22# For adapting this Makefile to a different system, only the following
23# definitions should need customizing:
24
25OPENSSLDIR=../..
26CC=gcc
27
28SYSCFLAGS=whatever
29SYSLIBS=whatever
30
31
32#############################################################################
33#
34# SSLeay/OpenSSL imports
35#
36# OPENSSLDIR (set above) can be either the directory where OpenSSL is
37# installed or the directory where it was compiled.
38
39# We rely on having a new OpenSSL release where include files
40# have names like <openssl/ssl.h> (not just <ssl.h>).
41OPENSSLINCLUDES=-I$(OPENSSLDIR)/include
42
43# libcrypto.a and libssl.a are directly in $(OPENSSLDIR) if this is
44# the compile directory, or in $(OPENSSLDIR)/lib if we use an installed
45# library. With the following definition, we can handle either case.
46OPENSSLLIBS=-L$(OPENSSLDIR) -L$(OPENSSLDIR)/lib -lssl -lcrypto
47
48
49#############################################################################
50#
51# Stuff for handling the source files
52#
53
54SOURCES=easy-tls.c test.c
55HEADERS=easy-tls.h test.h
56DOCSandEXAMPLESetc=Makefile cert.pem cacerts.pem
57EVERYTHING=$(SOURCES) $(HEADERS) $(DOCSandEXAMPLESetc)
58
59ls: ls-l
60ls-l:
61 ls -l $(EVERYTHING)
62# For RCS:
63tag:
64 -rcs -n_`date +%y%m%d`: $(EVERYTHING)
65 rcs -nMYTAG $(EVERYTHING)
66 rcs -nMYTAG: $(EVERYTHING)
67diff:
68 -rcsdiff -rMYTAG -u $(EVERYTHING)
69today:
70 -rcsdiff -r_`date +%y%m%d` -u $(EVERYTHING)
71ident:
72 for a in $(EVERYTHING); do ident $$a; done
73
74# Distribution .tar:
75easy-tls.tar.gz: $(EVERYTHING)
76 tar cvf - $(EVERYTHING) | \
77 gzip -9 > easy-tls.tar.gz
78
79# Working .tar:
80tls.tgz: $(EVERYTHING)
81 tar cfv - `find . -type f -a ! -name '*.tgz' -a ! -name '*.tar.gz'` | \
82 gzip -9 > tls.tgz
83
84# For emacs:
85etags: TAGS
86TAGS: $(SOURCES) $(HEADERS)
87 -etags $(SOURCES) $(HEADERS)
88
89
90#############################################################################
91#
92# Compilation
93#
94# The following definitions are system dependent (and hence defined
95# at the beginning of this Makefile, where they are more easily found):
96
97### CC=gcc
98### SYSCFLAGS=-Wall -pedantic -g -O2
99### SYSLIBS=-lxnet
100
101EXTRACFLAGS=-DTLS_APP=\"test.h\"
102# EXTRACFLAGS=-DTLS_APP=\"test.h\" -DDEBUG_TLS
103
104#
105# The rest shouldn't need to be touched.
106#
107LDFLAGS=$(SYSLIBS) $(OPENSSLLIBS)
108INCLUDES=$(OPENSSLINCLUDES)
109CFLAGS=$(SYSCFLAGS) $(EXTRACFLAGS) $(INCLUDES)
110
111OBJS=easy-tls.o test.o
112
113clean:
114 @rm -f test
115 @rm -f TAGS
116 @rm -f *.o
117 @rm -f core
118
119test: $(OBJS)
120 $(CC) $(OBJS) $(LDFLAGS) -o test
121
122test.o: $(HEADERS)
123easy-tls.o: $(HEADERS)
diff --git a/src/lib/libssl/src/demos/easy_tls/README b/src/lib/libssl/src/demos/easy_tls/README
new file mode 100644
index 0000000000..816a58009c
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/README
@@ -0,0 +1,65 @@
1easy_tls - generic SSL/TLS proxy
2========
3
4(... and example for non-blocking SSL/TLS I/O multiplexing.)
5
6
7 easy_tls.c, easy_tls.h:
8
9 Small generic SSL/TLS proxy library: With a few function calls,
10 an application socket will be replaced by a pipe handled by a
11 separate SSL/TLS proxy process. This allows easily adding
12 SSL/TLS support to many programs not originally designed for it.
13
14 [Actually easy_tls.c is not a proper library: Customization
15 requires defining preprocessor macros while compiling it.
16 This is quite confusing, so I'll probably change it.]
17
18 These files may be used under the OpenSSL license.
19
20
21
22 test.c, test.h, Makefile, cert.pem, cacerts.pem:
23
24 Rudimentary example program using the easy_tls library, and
25 example key and certificates for it. Usage examples:
26
27 $ ./test 8443 # create server listening at port 8443
28 $ ./test 127.0.0.1 8443 # create client, connect to port 8443
29 # at IP address 127.0.0.1
30
31 'test' will not automatically do SSL/TLS, or even read or write
32 data -- it must be told to do so on input lines starting
33 with a command letter. 'W' means write a line, 'R' means
34 read a line, 'C' means close the connection, 'T' means
35 start an SSL/TLS proxy. E.g. (user input tagged with '*'):
36
37 * R
38 <<< 220 mail.example.net
39 * WSTARTTLS
40 >>> STARTTLS
41 * R
42 <<< 220 Ready to start TLS
43 * T
44 test_process_init(fd = 3, client_p = 1, apparg = (nil))
45 +++ `E:self signed certificate in certificate chain'
46 +++ `<... certificate info ...>'
47 * WHELO localhost
48 >>> HELO localhost
49 R
50 <<< 250 mail.example.net
51
52 You can even do SSL/TLS over SSL/TLS over SSL/TLS ... by using
53 'T' multiple times. I have no idea why you would want to though.
54
55
56This code is rather old. When I find time I will update anything that
57should be changed, and improve code comments. To compile the sample
58program 'test' on platforms other then Linux or Solaris, you will have
59to edit the Makefile.
60
61As noted above, easy_tls.c will be changed to become a library one
62day, which means that future revisions will not be fully compatible to
63the current version.
64
65Bodo Möller <bodo@openssl.org>
diff --git a/src/lib/libssl/src/demos/easy_tls/cacerts.pem b/src/lib/libssl/src/demos/easy_tls/cacerts.pem
new file mode 100644
index 0000000000..0b1c91f95e
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/cacerts.pem
@@ -0,0 +1,18 @@
1$Id: cacerts.pem,v 1.1 2002/05/15 02:29:18 beck Exp $
2
3issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
4subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
5-----BEGIN CERTIFICATE-----
6MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV
7BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD
8VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw
9OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY
10BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0
11IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ
12DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv
131F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2
14mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v
15hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4
16YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA
17q30KIqGM/uoM60INq97qjDmCJapagcNBGQs=
18-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/demos/easy_tls/cert.pem b/src/lib/libssl/src/demos/easy_tls/cert.pem
new file mode 100644
index 0000000000..d4d19d9ad1
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/cert.pem
@@ -0,0 +1,31 @@
1$Id: cert.pem,v 1.1 2002/05/15 02:29:18 beck Exp $
2
3Example certificate and key.
4
5-----BEGIN CERTIFICATE-----
6MIIB1jCCAT8CAQEwDQYJKoZIhvcNAQEEBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV
7BAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0
8ZDAeFw05OTA1MDEwMTI2MzVaFw05OTA1MzEwMTI2MzVaMCIxCzAJBgNVBAYTAkRF
9MRMwEQYDVQQDEwpUZXN0c2VydmVyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
10gQD6I3oDKiexwwlkzjar69AIFnVUaG85LtCege2R+CtIDlkQYw68/8MbT3ou0pdF
11AcL9IGiYY3Y0SHM9PqF00RO1MCtNpqTnF3ScLpbmggGjKilmWYn2ai7emdjMjXVL
12tzWW2xGgIGATWQN32KgfJng4jXi1UjEiyLhkw0Zf1I/ggwIDAQABMA0GCSqGSIb3
13DQEBBAUAA4GBAMgM+sbAk8DfjSfa+Rf2gcGXmbrvZAzKzC+5RU3kaq/NyxIXAGco
149dZjozzWfN/xuGup5boFk+KrP+xdgsaqGHsyzlgEoqz4ekqLjQeVbnoj339hVFU9
15MhPi6JULPxjXKumjfX2LLNkikW5puz8Df3UiX0EiaJvd7EwP8J75tiUT
16-----END CERTIFICATE-----
17-----BEGIN RSA PRIVATE KEY-----
18MIICXQIBAAKBgQD6I3oDKiexwwlkzjar69AIFnVUaG85LtCege2R+CtIDlkQYw68
19/8MbT3ou0pdFAcL9IGiYY3Y0SHM9PqF00RO1MCtNpqTnF3ScLpbmggGjKilmWYn2
20ai7emdjMjXVLtzWW2xGgIGATWQN32KgfJng4jXi1UjEiyLhkw0Zf1I/ggwIDAQAB
21AoGANST8c1etf1MU19oIO5aqaE19OCXIG7oakNLCCtVTPMfvnE+vffBJH7BPIUuU
224BBzwRv1nQrkvk72TPjVjOAu81B1SStKQueun2flVuYxp9NyupNWCBley4QdohlP
23I92ml2tzTSPmNIoA6jdGyNzFcGchapRRmejsC39F1RUbHQECQQD9KX81Wt8ZOrri
24dWiEXja1L3X8Bkb9vvUjVMQDTJJPxBJjehC6eurgE6PP6SJD5p/f3RHPCcLr8tSM
25D4P/OpKhAkEA/PFNlhIZUDKK6aTvG2mn7qQ5phbadOoyN1Js3ttWG5OMOZ6b/QlC
26Wvp84h44506BIlv+Tg2YAI0AdBUrf7oEowJAM4joAVd/ROaEtqbJ4PBA2L9RmD06
275FqkEk4mHLnQqvYx/BgUIbH18ClvVlqSBBqFfw/EmU3WZSuogt6Bs0ocIQJBAOxB
28AoPiYcxbeQ5kZIVJOXaX49SzUdaUDNVJYrEBUzsspHQJJo/Avz606kJVkjbSR6Ft
29JWmIHuqcyMikIV4KxFsCQQCU2evoVjVsqkkbHi7W28f73PGBsyu0KIwlK7nu4h08
30Daf7TAI+A6jW/WRUsJ6dFhUYi7/Jvkcdrlnbgm2fxziX
31-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/demos/easy_tls/easy-tls.c b/src/lib/libssl/src/demos/easy_tls/easy-tls.c
new file mode 100644
index 0000000000..9fa0ef9a6b
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/easy-tls.c
@@ -0,0 +1,1235 @@
1/* -*- Mode: C; c-file-style: "bsd" -*- */
2/*
3 * easy-tls.c -- generic TLS proxy.
4 * $Id: easy-tls.c,v 1.1 2002/05/15 02:29:18 beck Exp $
5 */
6/*
7 (c) Copyright 1999 Bodo Moeller. All rights reserved.
8
9 This is free software; you can redistributed and/or modify it
10 unter the terms of either
11 - the GNU General Public License as published by the
12 Free Software Foundation, version 1, or (at your option)
13 any later version,
14 or
15 - the following license:
16*/
17/*
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that each of the following
20 * conditions is met:
21 *
22 * 1. Redistributions qualify as "freeware" or "Open Source Software" under
23 * one of the following terms:
24 *
25 * (a) Redistributions are made at no charge beyond the reasonable cost of
26 * materials and delivery.
27 *
28 * (b) Redistributions are accompanied by a copy of the Source Code
29 * or by an irrevocable offer to provide a copy of the Source Code
30 * for up to three years at the cost of materials and delivery.
31 * Such redistributions must allow further use, modification, and
32 * redistribution of the Source Code under substantially the same
33 * terms as this license.
34 *
35 * 2. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 *
38 * 3. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in
40 * the documentation and/or other materials provided with the
41 * distribution.
42 *
43 * 4. All advertising materials mentioning features or use of this
44 * software must display the following acknowledgment:
45 * "This product includes software developed by Bodo Moeller."
46 * (If available, substitute umlauted o for oe.)
47 *
48 * 5. Redistributions of any form whatsoever must retain the following
49 * acknowledgment:
50 * "This product includes software developed by Bodo Moeller."
51 *
52 * THIS SOFTWARE IS PROVIDED BY BODO MOELLER ``AS IS'' AND ANY
53 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BODO MOELLER OR
56 * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
59 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
61 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
63 * OF THE POSSIBILITY OF SUCH DAMAGE.
64 */
65/*
66 * Attribution for OpenSSL library:
67 *
68 * This product includes cryptographic software written by Eric Young
69 * (eay@cryptsoft.com). This product includes software written by Tim
70 * Hudson (tjh@cryptsoft.com).
71 * This product includes software developed by the OpenSSL Project
72 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)
73 */
74
75static char const rcsid[] =
76"$Id: easy-tls.c,v 1.1 2002/05/15 02:29:18 beck Exp $";
77
78#include <assert.h>
79#include <errno.h>
80#include <fcntl.h>
81#include <limits.h>
82#include <stdarg.h>
83#include <stdio.h>
84#include <string.h>
85#include <sys/select.h>
86#include <sys/socket.h>
87#include <sys/stat.h>
88#include <sys/time.h>
89#include <sys/types.h>
90#include <sys/utsname.h>
91#include <unistd.h>
92
93#include <openssl/crypto.h>
94#include <openssl/dh.h>
95#include <openssl/dsa.h>
96#include <openssl/err.h>
97#include <openssl/evp.h>
98#include <openssl/opensslv.h>
99#include <openssl/pem.h>
100#include <openssl/rand.h>
101#ifndef NO_RSA
102 #include <openssl/rsa.h>
103#endif
104#include <openssl/ssl.h>
105#include <openssl/x509.h>
106#include <openssl/x509_vfy.h>
107
108#if OPENSSL_VERSION_NUMBER < 0x00904000L /* 0.9.4-dev */
109# error "This program needs OpenSSL 0.9.4 or later."
110#endif
111
112#include "easy-tls.h" /* include after <openssl/ssl.h> if both are needed */
113
114#if TLS_INFO_SIZE > PIPE_BUF
115# if PIPE_BUF < 512
116# error "PIPE_BUF < 512" /* non-POSIX */
117# endif
118# error "TLS_INFO_SIZE > PIPE_BUF"
119#endif
120
121/*****************************************************************************/
122
123#ifdef TLS_APP
124# include TLS_APP
125#endif
126
127/* Applications can define:
128 * TLS_APP_PROCESS_INIT -- void ...(int fd, int client_p, void *apparg)
129 * TLS_CUMULATE_ERRORS
130 * TLS_ERROR_BUFSIZ
131 * TLS_APP_ERRFLUSH -- void ...(int child_p, char *, size_t, void *apparg)
132 */
133
134#ifndef TLS_APP_PROCESS_INIT
135# define TLS_APP_PROCESS_INIT(fd, client_p, apparg) ((void) 0)
136#endif
137
138#ifndef TLS_ERROR_BUFSIZ
139# define TLS_ERROR_BUFSIZ (10*160)
140#endif
141#if TLS_ERROR_BUFSIZ < 2 /* {'\n',0} */
142# error "TLS_ERROR_BUFSIZE is too small."
143#endif
144
145#ifndef TLS_APP_ERRFLUSH
146# define TLS_APP_ERRFLUSH tls_app_errflush
147static void
148tls_app_errflush(int child_p, char *errbuf, size_t num, void *apparg)
149{
150 fputs(errbuf, stderr);
151}
152#endif
153
154/*****************************************************************************/
155
156#ifdef DEBUG_TLS
157# define DEBUG_MSG(x) fprintf(stderr," %s\n",x)
158# define DEBUG_MSG2(x,y) fprintf(stderr, " %s: %d\n",x,y)
159static int tls_loop_count = 0;
160static int tls_select_count = 0;
161#else
162# define DEBUG_MSG(x) (void)0
163# define DEBUG_MSG2(x,y) (void)0
164#endif
165
166static void tls_rand_seed_uniquely(void);
167static void tls_proxy(int clear_fd, int tls_fd, int info_fd, SSL_CTX *ctx, int client_p);
168static int tls_socket_nonblocking(int fd);
169
170static int tls_child_p = 0;
171static void *tls_child_apparg;
172
173
174struct tls_start_proxy_args
175tls_start_proxy_defaultargs(void)
176{
177 struct tls_start_proxy_args ret;
178
179 ret.fd = -1;
180 ret.client_p = -1;
181 ret.ctx = NULL;
182 ret.pid = NULL;
183 ret.infofd = NULL;
184
185 return ret;
186}
187
188/* Slice in TLS proxy process at fd.
189 * Return value:
190 * 0 ok (*pid is set to child's PID if pid != NULL),
191 * < 0 look at errno
192 * > 0 other error
193 * (return value encodes place of error)
194 *
195 */
196int
197tls_start_proxy(struct tls_start_proxy_args a, void *apparg)
198{
199 int fds[2] = {-1, -1};
200 int infofds[2] = {-1, -1};
201 int r, getfd, getfl;
202 int ret;
203
204 DEBUG_MSG2("tls_start_proxy fd", a.fd);
205 DEBUG_MSG2("tls_start_proxy client_p", a.client_p);
206
207 if (a.fd == -1 || a.client_p == -1 || a.ctx == NULL)
208 return 1;
209
210 if (a.pid != NULL) {
211 *a.pid = 0;
212 }
213 if (a.infofd != NULL) {
214 *a.infofd = -1;
215 }
216
217 r = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
218 if (r == -1)
219 return -1;
220 if (a.fd >= FD_SETSIZE || fds[0] >= FD_SETSIZE) {
221 ret = 2;
222 goto err;
223 }
224 if (a.infofd != NULL) {
225 r = pipe(infofds);
226 if (r == -1) {
227 ret = -3;
228 goto err;
229 }
230 }
231
232 r = fork();
233 if (r == -1) {
234 ret = -4;
235 goto err;
236 }
237 if (r == 0) {
238 DEBUG_MSG("fork");
239 tls_child_p = 1;
240 tls_child_apparg = apparg;
241 close(fds[1]);
242 if (infofds[0] != -1)
243 close(infofds[0]);
244 TLS_APP_PROCESS_INIT(a.fd, a.client_p, apparg);
245 DEBUG_MSG("TLS_APP_PROCESS_INIT");
246 tls_proxy(fds[0], a.fd, infofds[1], a.ctx, a.client_p);
247 exit(0);
248 }
249 if (a.pid != NULL)
250 *a.pid = r;
251 if (infofds[1] != -1) {
252 close(infofds[1]);
253 infofds[1] = -1;
254 }
255 /* install fds[1] in place of fd: */
256 close(fds[0]);
257 fds[0] = -1;
258 getfd = fcntl(a.fd, F_GETFD);
259 getfl = fcntl(a.fd, F_GETFL);
260 r = dup2(fds[1], a.fd);
261 close(fds[1]);
262 fds[1] = -1;
263 if (r == -1) {
264 ret = -5;
265 goto err;
266 }
267 if (getfd != 1)
268 fcntl(a.fd, F_SETFD, getfd);
269 if (getfl & O_NONBLOCK)
270 (void)tls_socket_nonblocking(a.fd);
271 if (a.infofd != NULL)
272 *a.infofd = infofds[0];
273 return 0;
274
275 err:
276 if (fds[0] != -1)
277 close(fds[0]);
278 if (fds[1] != -1)
279 close(fds[1]);
280 if (infofds[0] != -1)
281 close(infofds[0]);
282 if (infofds[1] != -1)
283 close(infofds[1]);
284 return ret;
285}
286
287/*****************************************************************************/
288
289static char errbuf[TLS_ERROR_BUFSIZ];
290static size_t errbuf_i = 0;
291
292static void
293tls_errflush(void *apparg)
294{
295 if (errbuf_i == 0)
296 return;
297
298 assert(errbuf_i < sizeof errbuf);
299 assert(errbuf[errbuf_i] == 0);
300 if (errbuf_i == sizeof errbuf - 1) {
301 /* make sure we have a newline, even if string has been truncated */
302 errbuf[errbuf_i - 1] = '\n';
303 }
304
305 /* TLS_APP_ERRFLUSH may modify the string as needed,
306 * e.g. substitute other characters for \n for convenience */
307 TLS_APP_ERRFLUSH(tls_child_p, errbuf, errbuf_i, apparg);
308
309 errbuf_i = 0;
310}
311
312static void
313tls_errprintf(int flush, void *apparg, const char *fmt, ...)
314{
315 va_list args;
316 int r;
317
318 if (errbuf_i < sizeof errbuf - 1) {
319 size_t n;
320
321 va_start(args, fmt);
322 n = (sizeof errbuf) - errbuf_i;
323 r = vsnprintf(errbuf + errbuf_i, n, fmt, args);
324 if (r >= n)
325 r = n - 1;
326 if (r >= 0) {
327 errbuf_i += r;
328 } else {
329 errbuf_i = sizeof errbuf - 1;
330 errbuf[errbuf_i] = '\0';
331 }
332 assert(errbuf_i < sizeof errbuf);
333 assert(errbuf[errbuf_i] == 0);
334 }
335#ifndef TLS_CUMULATE_ERRORS
336 tls_errflush(apparg);
337#else
338 if (flush)
339 tls_errflush(apparg);
340#endif
341}
342
343/* app_prefix.. are for additional information provided by caller.
344 * If OpenSSL error queue is empty, print default_text ("???" if NULL).
345 */
346static char *
347tls_openssl_errors(const char *app_prefix_1, const char *app_prefix_2, const char *default_text, void *apparg)
348{
349 static char reasons[255];
350 size_t reasons_i;
351 unsigned long err;
352 const char *file;
353 int line;
354 const char *data;
355 int flags;
356 char *errstring;
357 int printed_something = 0;
358
359 reasons_i = 0;
360
361 assert(app_prefix_1 != NULL);
362 assert(app_prefix_2 != NULL);
363
364 if (default_text == NULL)
365 default_text = "?""?""?";
366
367 while ((err = ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) {
368 if (reasons_i < sizeof reasons) {
369 size_t n;
370 int r;
371
372 n = (sizeof reasons) - reasons_i;
373 r = snprintf(reasons + reasons_i, n, "%s%s", (reasons_i > 0 ? ", " : ""), ERR_reason_error_string(err));
374 if (r >= n)
375 r = n - 1;
376 if (r >= 0) {
377 reasons_i += r;
378 } else {
379 reasons_i = sizeof reasons;
380 }
381 assert(reasons_i <= sizeof reasons);
382 }
383
384 errstring = ERR_error_string(err, NULL);
385 assert(errstring != NULL);
386 tls_errprintf(0, apparg, "OpenSSL error%s%s: %s:%s:%d:%s\n", app_prefix_1, app_prefix_2, errstring, file, line, (flags & ERR_TXT_STRING) ? data : "");
387 printed_something = 1;
388 }
389
390 if (!printed_something) {
391 assert(reasons_i == 0);
392 snprintf(reasons, sizeof reasons, "%s", default_text);
393 tls_errprintf(0, apparg, "OpenSSL error%s%s: %s\n", app_prefix_1, app_prefix_2, default_text);
394 }
395
396#ifdef TLS_CUMULATE_ERRORS
397 tls_errflush(apparg);
398#endif
399 assert(errbuf_i == 0);
400
401 return reasons;
402}
403
404/*****************************************************************************/
405
406static int tls_init_done = 0;
407
408static int
409tls_init(void *apparg)
410{
411 if (tls_init_done)
412 return 0;
413
414 SSL_load_error_strings();
415 if (!SSL_library_init() /* aka SSLeay_add_ssl_algorithms() */ ) {
416 tls_errprintf(1, apparg, "SSL_library_init failed.\n");
417 return -1;
418 }
419 tls_init_done = 1;
420 tls_rand_seed();
421 return 0;
422}
423
424/*****************************************************************************/
425
426static void
427tls_rand_seed_uniquely(void)
428{
429 struct {
430 pid_t pid;
431 time_t time;
432 void *stack;
433 } data;
434
435 data.pid = getpid();
436 data.time = time(NULL);
437 data.stack = (void *)&data;
438
439 RAND_seed((const void *)&data, sizeof data);
440}
441
442void
443tls_rand_seed(void)
444{
445 struct {
446 struct utsname uname;
447 int uname_1;
448 int uname_2;
449 uid_t uid;
450 uid_t euid;
451 gid_t gid;
452 gid_t egid;
453 } data;
454
455 data.uname_1 = uname(&data.uname);
456 data.uname_2 = errno; /* Let's hope that uname fails randomly :-) */
457
458 data.uid = getuid();
459 data.euid = geteuid();
460 data.gid = getgid();
461 data.egid = getegid();
462
463 RAND_seed((const void *)&data, sizeof data);
464 tls_rand_seed_uniquely();
465}
466
467static int tls_rand_seeded_p = 0;
468
469#define my_MIN_SEED_BYTES 256 /* struct stat can be larger than 128 */
470int
471tls_rand_seed_from_file(const char *filename, size_t n, void *apparg)
472{
473 /* Seed OpenSSL's random number generator from file.
474 Try to read n bytes if n > 0, whole file if n == 0. */
475
476 int r;
477
478 if (tls_init(apparg) == -1)
479 return -1;
480 tls_rand_seed();
481
482 r = RAND_load_file(filename, (n > 0 && n < LONG_MAX) ? (long)n : LONG_MAX);
483 /* r is the number of bytes filled into the random number generator,
484 * which are taken from "stat(filename, ...)" in addition to the
485 * file contents.
486 */
487 assert(1 < my_MIN_SEED_BYTES);
488 /* We need to detect at least those cases when the file does not exist
489 * at all. With current versions of OpenSSL, this should do it: */
490 if (n == 0)
491 n = my_MIN_SEED_BYTES;
492 if (r < n) {
493 tls_errprintf(1, apparg, "rand_seed_from_file: could not read %d bytes from %s.\n", n, filename);
494 return -1;
495 } else {
496 tls_rand_seeded_p = 1;
497 return 0;
498 }
499}
500
501void
502tls_rand_seed_from_memory(const void *buf, size_t n)
503{
504 size_t i = 0;
505
506 while (i < n) {
507 size_t rest = n - i;
508 int chunk = rest < INT_MAX ? (int)rest : INT_MAX;
509 RAND_seed((const char *)buf + i, chunk);
510 i += chunk;
511 }
512 tls_rand_seeded_p = 1;
513}
514
515
516/*****************************************************************************/
517
518struct tls_x509_name_string {
519 char str[100];
520};
521
522static void
523tls_get_x509_subject_name_oneline(X509 *cert, struct tls_x509_name_string *namestring)
524{
525 X509_NAME *name;
526
527 if (cert == NULL) {
528 namestring->str[0] = '\0';
529 return;
530 }
531
532 name = X509_get_subject_name(cert); /* does not increment any reference counter */
533
534 assert(sizeof namestring->str >= 4); /* "?" or "...", plus 0 */
535
536 if (name == NULL) {
537 namestring->str[0] = '?';
538 namestring->str[1] = 0;
539 } else {
540 size_t len;
541
542 X509_NAME_oneline(name, namestring->str, sizeof namestring->str);
543 len = strlen(namestring->str);
544 assert(namestring->str[len] == 0);
545 assert(len < sizeof namestring->str);
546
547 if (len+1 == sizeof namestring->str) {
548 /* (Probably something was cut off.)
549 * Does not really work -- X509_NAME_oneline truncates after
550 * name components, we cannot tell from the result whether
551 * anything is missing. */
552
553 assert(namestring->str[len] == 0);
554 namestring->str[--len] = '.';
555 namestring->str[--len] = '.';
556 namestring->str[--len] = '.';
557 }
558 }
559}
560
561/*****************************************************************************/
562
563/* to hinder OpenSSL from asking for passphrases */
564static int
565no_passphrase_callback(char *buf, int num, int w, void *arg)
566{
567 return -1;
568}
569
570static int
571verify_dont_fail_cb(X509_STORE_CTX *c, void *unused_arg)
572{
573 int i;
574
575 i = X509_verify_cert(c); /* sets c->error */
576#if OPENSSL_VERSION_NUMBER >= 0x00905000L /* don't allow unverified
577 * certificates -- they could
578 * survive session reuse, but
579 * OpenSSL < 0.9.5-dev does not
580 * preserve their verify_result */
581 if (i == 0)
582 return 1;
583 else
584#endif
585 return i;
586}
587
588static DH *tls_dhe1024 = NULL; /* generating these takes a while, so do it just once */
589
590void
591tls_set_dhe1024(int i, void *apparg)
592{
593 DSA *dsaparams;
594 DH *dhparams;
595 const char *seed[] = { ";-) :-( :-) :-( ",
596 ";-) :-( :-) :-( ",
597 "Random String no. 12",
598 ";-) :-( :-) :-( ",
599 "hackers have even mo", /* from jargon file */
600 };
601 unsigned char seedbuf[20];
602
603 tls_init(apparg);
604 if (i >= 0) {
605 i %= sizeof seed / sizeof seed[0];
606 assert(strlen(seed[i]) == 20);
607 memcpy(seedbuf, seed[i], 20);
608 dsaparams = DSA_generate_parameters(1024, seedbuf, 20, NULL, NULL, 0, NULL);
609 } else {
610 /* random parameters (may take a while) */
611 dsaparams = DSA_generate_parameters(1024, NULL, 0, NULL, NULL, 0, NULL);
612 }
613
614 if (dsaparams == NULL) {
615 tls_openssl_errors("", "", NULL, apparg);
616 return;
617 }
618 dhparams = DSA_dup_DH(dsaparams);
619 DSA_free(dsaparams);
620 if (dhparams == NULL) {
621 tls_openssl_errors("", "", NULL, apparg);
622 return;
623 }
624 if (tls_dhe1024 != NULL)
625 DH_free(tls_dhe1024);
626 tls_dhe1024 = dhparams;
627}
628
629struct tls_create_ctx_args
630tls_create_ctx_defaultargs(void)
631{
632 struct tls_create_ctx_args ret;
633
634 ret.client_p = 0;
635 ret.certificate_file = NULL;
636 ret.key_file = NULL;
637 ret.ca_file = NULL;
638 ret.verify_depth = -1;
639 ret.fail_unless_verified = 0;
640 ret.export_p = 0;
641
642 return ret;
643}
644
645SSL_CTX *
646tls_create_ctx(struct tls_create_ctx_args a, void *apparg)
647{
648 int r;
649 static long context_num = 0;
650 SSL_CTX *ret;
651 const char *err_pref_1 = "", *err_pref_2 = "";
652
653 if (tls_init(apparg) == -1)
654 return NULL;
655
656 ret = SSL_CTX_new((a.client_p? SSLv23_client_method:SSLv23_server_method)());
657
658 if (ret == NULL)
659 goto err;
660
661 SSL_CTX_set_default_passwd_cb(ret, no_passphrase_callback);
662 SSL_CTX_set_mode(ret, SSL_MODE_ENABLE_PARTIAL_WRITE);
663
664 if ((a.certificate_file != NULL) || (a.key_file != NULL)) {
665 if (a.key_file == NULL) {
666 tls_errprintf(1, apparg, "Need a key file.\n");
667 goto err_return;
668 }
669 if (a.certificate_file == NULL) {
670 tls_errprintf(1, apparg, "Need a certificate chain file.\n");
671 goto err_return;
672 }
673
674 if (!SSL_CTX_use_PrivateKey_file(ret, a.key_file, SSL_FILETYPE_PEM))
675 goto err;
676 if (!tls_rand_seeded_p) {
677 /* particularly paranoid people may not like this --
678 * so provide your own random seeding before calling this */
679 if (tls_rand_seed_from_file(a.key_file, 0, apparg) == -1)
680 goto err_return;
681 }
682 if (!SSL_CTX_use_certificate_chain_file(ret, a.certificate_file))
683 goto err;
684 if (!SSL_CTX_check_private_key(ret)) {
685 tls_errprintf(1, apparg, "Private key \"%s\" does not match certificate \"%s\".\n", a.key_file, a.certificate_file);
686 goto err_peek;
687 }
688 }
689
690 if ((a.ca_file != NULL) || (a.verify_depth > 0)) {
691 context_num++;
692 r = SSL_CTX_set_session_id_context(ret, (const void *)&context_num, (unsigned int)sizeof context_num);
693 if (!r)
694 goto err;
695
696 SSL_CTX_set_verify(ret, SSL_VERIFY_PEER | (a.fail_unless_verified ? SSL_VERIFY_FAIL_IF_NO_PEER_CERT : 0), 0);
697 if (!a.fail_unless_verified)
698 SSL_CTX_set_cert_verify_callback(ret, verify_dont_fail_cb, NULL);
699
700 if (a.verify_depth > 0)
701 SSL_CTX_set_verify_depth(ret, a.verify_depth);
702
703 if (a.ca_file != NULL) {
704 r = SSL_CTX_load_verify_locations(ret, a.ca_file, NULL /* no CA-directory */); /* does not report failure if file does not exist ... */
705 if (!r) {
706 err_pref_1 = " while processing certificate file ";
707 err_pref_2 = a.ca_file;
708 goto err;
709 }
710
711 if (!a.client_p) {
712 /* SSL_load_client_CA_file is a misnomer, it just creates a list of CNs. */
713 SSL_CTX_set_client_CA_list(ret, SSL_load_client_CA_file(a.ca_file));
714 /* SSL_CTX_set_client_CA_list does not have a return value;
715 * it does not really need one, but make sure
716 * (we really test if SSL_load_client_CA_file worked) */
717 if (SSL_CTX_get_client_CA_list(ret) == NULL) {
718 tls_errprintf(1, apparg, "Could not set client CA list from \"%s\".\n", a.ca_file);
719 goto err_peek;
720 }
721 }
722 }
723 }
724
725 if (!a.client_p) {
726 if (tls_dhe1024 == NULL) {
727 int i;
728
729 RAND_bytes((unsigned char *) &i, sizeof i);
730 /* make sure that i is non-negative -- pick one of the provided
731 * seeds */
732 if (i < 0)
733 i = -i;
734 if (i < 0)
735 i = 0;
736 tls_set_dhe1024(i, apparg);
737 if (tls_dhe1024 == NULL)
738 goto err_return;
739 }
740
741 if (!SSL_CTX_set_tmp_dh(ret, tls_dhe1024))
742 goto err;
743
744 /* avoid small subgroup attacks: */
745 SSL_CTX_set_options(ret, SSL_OP_SINGLE_DH_USE);
746 }
747
748#ifndef NO_RSA
749 if (!a.client_p && a.export_p) {
750 RSA *tmpkey;
751
752 tmpkey = RSA_generate_key(512, RSA_F4, 0, NULL);
753 if (tmpkey == NULL)
754 goto err;
755 if (!SSL_CTX_set_tmp_rsa(ret, tmpkey)) {
756 RSA_free(tmpkey);
757 goto err;
758 }
759 RSA_free(tmpkey); /* SSL_CTX_set_tmp_rsa uses a duplicate. */
760 }
761#endif
762
763 return ret;
764
765 err_peek:
766 if (!ERR_peek_error())
767 goto err_return;
768 err:
769 tls_openssl_errors(err_pref_1, err_pref_2, NULL, apparg);
770 err_return:
771 if (ret != NULL)
772 SSL_CTX_free(ret);
773 return NULL;
774}
775
776
777/*****************************************************************************/
778
779static int
780tls_socket_nonblocking(int fd)
781{
782 int v, r;
783
784 v = fcntl(fd, F_GETFL, 0);
785 if (v == -1) {
786 if (errno == EINVAL)
787 return 0; /* already shut down -- ignore */
788 return -1;
789 }
790 r = fcntl(fd, F_SETFL, v | O_NONBLOCK);
791 if (r == -1) {
792 if (errno == EINVAL)
793 return 0; /* already shut down -- ignore */
794 return -1;
795 }
796 return 0;
797}
798
799static int
800max(int a, int b)
801{
802 return a > b ? a : b;
803}
804
805static void
806tls_sockets_select(int read_select_1, int read_select_2, int write_select_1, int write_select_2, int seconds /* timeout, -1 means no timeout */)
807{
808 int maxfd, n;
809 fd_set reads, writes;
810 struct timeval timeout;
811 struct timeval *timeout_p;
812
813 assert(read_select_1 >= -1 && read_select_2 >= -1 && write_select_1 >= -1 && write_select_2 >= -1);
814 assert(read_select_1 < FD_SETSIZE && read_select_2 < FD_SETSIZE -1 && write_select_1 < FD_SETSIZE -1 && write_select_2 < FD_SETSIZE -1);
815
816 maxfd = max(max(read_select_1, read_select_2), max(write_select_1, write_select_2));
817 assert(maxfd >= 0);
818
819 FD_ZERO(&reads);
820 FD_ZERO(&writes);
821
822 for(n = 0; n < 4; ++n) {
823 int i = n % 2;
824 int w = n >= 2;
825 /* loop over all (i, w) in {0,1}x{0,1} */
826 int fd;
827
828 if (i == 0 && w == 0)
829 fd = read_select_1;
830 else if (i == 1 && w == 0)
831 fd = read_select_2;
832 else if (i == 0 && w == 1)
833 fd = write_select_1;
834 else {
835 assert(i == 1 && w == 1);
836 fd = write_select_2;
837 }
838
839 if (fd >= 0) {
840 if (w == 0)
841 FD_SET(fd, &reads);
842 else /* w == 1 */
843 FD_SET(fd, &writes);
844 }
845 }
846
847 if (seconds >= 0) {
848 timeout.tv_sec = seconds;
849 timeout.tv_usec = 0;
850 timeout_p = &timeout;
851 } else
852 timeout_p = NULL;
853
854 DEBUG_MSG2("select no.", ++tls_select_count);
855 select(maxfd + 1, &reads, &writes, (fd_set *) NULL, timeout_p);
856 DEBUG_MSG("cont.");
857}
858
859/*****************************************************************************/
860
861#define TUNNELBUFSIZE (16*1024)
862struct tunnelbuf {
863 char buf[TUNNELBUFSIZE];
864 size_t len;
865 size_t offset;
866};
867
868static int tls_connect_attempt(SSL *, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref);
869
870static int tls_accept_attempt(SSL *, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref);
871
872static int tls_write_attempt(SSL *, struct tunnelbuf *, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref);
873
874static int tls_read_attempt(SSL *, struct tunnelbuf *, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref);
875
876static int write_attempt(int fd, struct tunnelbuf *, int *select, int *closed, int *progress);
877
878static int read_attempt(int fd, struct tunnelbuf *, int *select, int *closed, int *progress);
879
880static void write_info(SSL *ssl, int *info_fd)
881{
882 if (*info_fd != -1) {
883 long v;
884 int v_ok;
885 struct tls_x509_name_string peer;
886 char infobuf[TLS_INFO_SIZE];
887 int r;
888
889 DEBUG_MSG("write_info");
890 v = SSL_get_verify_result(ssl);
891 v_ok = (v == X509_V_OK) ? 'A' : 'E'; /* Auth./Error */
892 {
893 X509 *peercert;
894
895 peercert = SSL_get_peer_certificate(ssl);
896 tls_get_x509_subject_name_oneline(peercert, &peer);
897 if (peercert != NULL)
898 X509_free(peercert);
899 }
900 if (peer.str[0] == '\0')
901 v_ok = '0'; /* no cert at all */
902 else
903 if (strchr(peer.str, '\n')) {
904 /* should not happen, but make sure */
905 *strchr(peer.str, '\n') = '\0';
906 }
907 r = snprintf(infobuf, sizeof infobuf, "%c:%s\n%s\n", v_ok, X509_verify_cert_error_string(v), peer.str);
908 DEBUG_MSG2("snprintf", r);
909 if (r == -1 || r >= sizeof infobuf)
910 r = sizeof infobuf - 1;
911 write(*info_fd, infobuf, r);
912 close (*info_fd);
913 *info_fd = -1;
914 }
915}
916
917
918/* tls_proxy expects that all fds are closed after return */
919static void
920tls_proxy(int clear_fd, int tls_fd, int info_fd, SSL_CTX *ctx, int client_p)
921{
922 struct tunnelbuf clear_to_tls, tls_to_clear;
923 SSL *ssl;
924 BIO *rbio, *wbio;
925 int closed, in_handshake;
926 const char *err_pref_1 = "", *err_pref_2 = "";
927 const char *err_def = NULL;
928
929 assert(clear_fd != -1);
930 assert(tls_fd != -1);
931 assert(clear_fd < FD_SETSIZE);
932 assert(tls_fd < FD_SETSIZE);
933 /* info_fd may be -1 */
934 assert(ctx != NULL);
935
936 tls_rand_seed_uniquely();
937
938 tls_socket_nonblocking(clear_fd);
939 DEBUG_MSG2("clear_fd", clear_fd);
940 tls_socket_nonblocking(tls_fd);
941 DEBUG_MSG2("tls_fd", tls_fd);
942
943 ssl = SSL_new(ctx);
944 if (ssl == NULL)
945 goto err;
946 DEBUG_MSG("SSL_new");
947 if (!SSL_set_fd(ssl, tls_fd))
948 goto err;
949 rbio = SSL_get_rbio(ssl);
950 wbio = SSL_get_wbio(ssl); /* should be the same, but who cares */
951 assert(rbio != NULL);
952 assert(wbio != NULL);
953 if (client_p)
954 SSL_set_connect_state(ssl);
955 else
956 SSL_set_accept_state(ssl);
957
958 closed = 0;
959 in_handshake = 1;
960 tls_to_clear.len = 0;
961 tls_to_clear.offset = 0;
962 clear_to_tls.len = 0;
963 clear_to_tls.offset = 0;
964
965 err_def = "I/O error";
966
967 /* loop finishes as soon as we detect that one side closed;
968 * when all (program and OS) buffers have enough space,
969 * the data from the last succesful read in each direction is transferred
970 * before close */
971 do {
972 int clear_read_select = 0, clear_write_select = 0,
973 tls_read_select = 0, tls_write_select = 0,
974 progress = 0;
975 int r;
976 unsigned long num_read = BIO_number_read(rbio),
977 num_written = BIO_number_written(wbio);
978
979 DEBUG_MSG2("loop iteration", ++tls_loop_count);
980
981 if (in_handshake) {
982 DEBUG_MSG("in_handshake");
983 if (client_p)
984 r = tls_connect_attempt(ssl, &tls_write_select, &tls_read_select, &closed, &progress, &err_pref_1);
985 else
986 r = tls_accept_attempt(ssl, &tls_write_select, &tls_read_select, &closed, &progress, &err_pref_1);
987 if (r != 0) {
988 write_info(ssl, &info_fd);
989 goto err;
990 }
991 if (closed)
992 goto err_return;
993 if (!SSL_in_init(ssl)) {
994 in_handshake = 0;
995 write_info(ssl, &info_fd);
996 }
997 }
998
999 if (clear_to_tls.len != 0 && !in_handshake) {
1000 assert(!closed);
1001
1002 r = tls_write_attempt(ssl, &clear_to_tls, &tls_write_select, &tls_read_select, &closed, &progress, &err_pref_1);
1003 if (r != 0)
1004 goto err;
1005 if (closed) {
1006 assert(progress);
1007 tls_to_clear.offset = 0;
1008 tls_to_clear.len = 0;
1009 }
1010 }
1011
1012 if (tls_to_clear.len != 0) {
1013 assert(!closed);
1014
1015 r = write_attempt(clear_fd, &tls_to_clear, &clear_write_select, &closed, &progress);
1016 if (r != 0)
1017 goto err_return;
1018 if (closed) {
1019 assert(progress);
1020 clear_to_tls.offset = 0;
1021 clear_to_tls.len = 0;
1022 }
1023 }
1024
1025 if (!closed) {
1026 if (clear_to_tls.offset + clear_to_tls.len < sizeof clear_to_tls.buf) {
1027 r = read_attempt(clear_fd, &clear_to_tls, &clear_read_select, &closed, &progress);
1028 if (r != 0)
1029 goto err_return;
1030 if (closed) {
1031 r = SSL_shutdown(ssl);
1032 DEBUG_MSG2("SSL_shutdown", r);
1033 }
1034 }
1035 }
1036
1037 if (!closed && !in_handshake) {
1038 if (tls_to_clear.offset + tls_to_clear.len < sizeof tls_to_clear.buf) {
1039 r = tls_read_attempt(ssl, &tls_to_clear, &tls_write_select, &tls_read_select, &closed, &progress, &err_pref_1);
1040 if (r != 0)
1041 goto err;
1042 if (closed) {
1043 r = SSL_shutdown(ssl);
1044 DEBUG_MSG2("SSL_shutdown", r);
1045 }
1046 }
1047 }
1048
1049 if (!progress) {
1050 DEBUG_MSG("!progress?");
1051 if (num_read != BIO_number_read(rbio) || num_written != BIO_number_written(wbio))
1052 progress = 1;
1053
1054 if (!progress) {
1055 DEBUG_MSG("!progress");
1056 assert(clear_read_select || tls_read_select || clear_write_select || tls_write_select);
1057 tls_sockets_select(clear_read_select ? clear_fd : -1, tls_read_select ? tls_fd : -1, clear_write_select ? clear_fd : -1, tls_write_select ? tls_fd : -1, -1);
1058 }
1059 }
1060 } while (!closed);
1061 return;
1062
1063 err:
1064 tls_openssl_errors(err_pref_1, err_pref_2, err_def, tls_child_apparg);
1065 err_return:
1066 return;
1067}
1068
1069
1070static int
1071tls_get_error(SSL *ssl, int r, int *write_select, int *read_select, int *closed, int *progress)
1072{
1073 int err = SSL_get_error(ssl, r);
1074
1075 if (err == SSL_ERROR_NONE) {
1076 assert(r > 0);
1077 *progress = 1;
1078 return 0;
1079 }
1080
1081 assert(r <= 0);
1082
1083 switch (err) {
1084 case SSL_ERROR_ZERO_RETURN:
1085 assert(r == 0);
1086 *closed = 1;
1087 *progress = 1;
1088 return 0;
1089
1090 case SSL_ERROR_WANT_WRITE:
1091 *write_select = 1;
1092 return 0;
1093
1094 case SSL_ERROR_WANT_READ:
1095 *read_select = 1;
1096 return 0;
1097 }
1098
1099 return -1;
1100}
1101
1102static int
1103tls_connect_attempt(SSL *ssl, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref)
1104{
1105 int n, r;
1106
1107 DEBUG_MSG("tls_connect_attempt");
1108 n = SSL_connect(ssl);
1109 DEBUG_MSG2("SSL_connect",n);
1110 r = tls_get_error(ssl, n, write_select, read_select, closed, progress);
1111 if (r == -1)
1112 *err_pref = " during SSL_connect";
1113 return r;
1114}
1115
1116static int
1117tls_accept_attempt(SSL *ssl, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref)
1118{
1119 int n, r;
1120
1121 DEBUG_MSG("tls_accept_attempt");
1122 n = SSL_accept(ssl);
1123 DEBUG_MSG2("SSL_accept",n);
1124 r = tls_get_error(ssl, n, write_select, read_select, closed, progress);
1125 if (r == -1)
1126 *err_pref = " during SSL_accept";
1127 return r;
1128}
1129
1130static int
1131tls_write_attempt(SSL *ssl, struct tunnelbuf *buf, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref)
1132{
1133 int n, r;
1134
1135 DEBUG_MSG("tls_write_attempt");
1136 n = SSL_write(ssl, buf->buf + buf->offset, buf->len);
1137 DEBUG_MSG2("SSL_write",n);
1138 r = tls_get_error(ssl, n, write_select, read_select, closed, progress);
1139 if (n > 0) {
1140 buf->len -= n;
1141 assert(buf->len >= 0);
1142 if (buf->len == 0)
1143 buf->offset = 0;
1144 else
1145 buf->offset += n;
1146 }
1147 if (r == -1)
1148 *err_pref = " during SSL_write";
1149 return r;
1150}
1151
1152static int
1153tls_read_attempt(SSL *ssl, struct tunnelbuf *buf, int *write_select, int *read_select, int *closed, int *progress, const char **err_pref)
1154{
1155 int n, r;
1156 size_t total;
1157
1158 DEBUG_MSG("tls_read_attempt");
1159 total = buf->offset + buf->len;
1160 assert(total < sizeof buf->buf);
1161 n = SSL_read(ssl, buf->buf + total, (sizeof buf->buf) - total);
1162 DEBUG_MSG2("SSL_read",n);
1163 r = tls_get_error(ssl, n, write_select, read_select, closed, progress);
1164 if (n > 0) {
1165 buf->len += n;
1166 assert(buf->offset + buf->len <= sizeof buf->buf);
1167 }
1168 if (r == -1)
1169 *err_pref = " during SSL_read";
1170 return r;
1171}
1172
1173static int
1174get_error(int r, int *select, int *closed, int *progress)
1175{
1176 if (r >= 0) {
1177 *progress = 1;
1178 if (r == 0)
1179 *closed = 1;
1180 return 0;
1181 } else {
1182 assert(r == -1);
1183 if (errno == EAGAIN || errno == EWOULDBLOCK) {
1184 *select = 1;
1185 return 0;
1186 } else if (errno == EPIPE) {
1187 *progress = 1;
1188 *closed = 1;
1189 return 0;
1190 } else
1191 return -1;
1192 }
1193}
1194
1195static int write_attempt(int fd, struct tunnelbuf *buf, int *select, int *closed, int *progress)
1196{
1197 int n, r;
1198
1199 DEBUG_MSG("write_attempt");
1200 n = write(fd, buf->buf + buf->offset, buf->len);
1201 DEBUG_MSG2("write",n);
1202 r = get_error(n, select, closed, progress);
1203 if (n > 0) {
1204 buf->len -= n;
1205 assert(buf->len >= 0);
1206 if (buf->len == 0)
1207 buf->offset = 0;
1208 else
1209 buf->offset += n;
1210 }
1211 if (r == -1)
1212 tls_errprintf(1, tls_child_apparg, "write error: %s\n", strerror(errno));
1213 return r;
1214}
1215
1216static int
1217read_attempt(int fd, struct tunnelbuf *buf, int *select, int *closed, int *progress)
1218{
1219 int n, r;
1220 size_t total;
1221
1222 DEBUG_MSG("read_attempt");
1223 total = buf->offset + buf->len;
1224 assert(total < sizeof buf->buf);
1225 n = read(fd, buf->buf + total, (sizeof buf->buf) - total);
1226 DEBUG_MSG2("read",n);
1227 r = get_error(n, select, closed, progress);
1228 if (n > 0) {
1229 buf->len += n;
1230 assert(buf->offset + buf->len <= sizeof buf->buf);
1231 }
1232 if (r == -1)
1233 tls_errprintf(1, tls_child_apparg, "read error: %s\n", strerror(errno));
1234 return r;
1235}
diff --git a/src/lib/libssl/src/demos/easy_tls/easy-tls.h b/src/lib/libssl/src/demos/easy_tls/easy-tls.h
new file mode 100644
index 0000000000..0cfbd8fe7b
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/easy-tls.h
@@ -0,0 +1,57 @@
1/* -*- Mode: C; c-file-style: "bsd" -*- */
2/*
3 * easy-tls.h -- generic TLS proxy.
4 * $Id: easy-tls.h,v 1.1 2002/05/15 02:29:18 beck Exp $
5 */
6/*
7 * (c) Copyright 1999 Bodo Moeller. All rights reserved.
8 */
9
10#ifndef HEADER_TLS_H
11#define HEADER_TLS_H
12
13#ifndef HEADER_SSL_H
14typedef struct ssl_ctx_st SSL_CTX;
15#endif
16
17#define TLS_INFO_SIZE 512 /* max. # of bytes written to infofd */
18
19void tls_set_dhe1024(int i, void* apparg);
20/* Generate DHE parameters:
21 * i >= 0 deterministic (i selects seed), i < 0 random (may take a while).
22 * tls_create_ctx calls this with random non-negative i if the application
23 * has never called it.*/
24
25void tls_rand_seed(void);
26int tls_rand_seed_from_file(const char *filename, size_t n, void *apparg);
27void tls_rand_seed_from_memory(const void *buf, size_t n);
28
29struct tls_create_ctx_args
30{
31 int client_p;
32 const char *certificate_file;
33 const char *key_file;
34 const char *ca_file;
35 int verify_depth;
36 int fail_unless_verified;
37 int export_p;
38};
39struct tls_create_ctx_args tls_create_ctx_defaultargs(void);
40/* struct tls_create_ctx_args is similar to a conventional argument list,
41 * but it can provide default values and allows for future extension. */
42SSL_CTX *tls_create_ctx(struct tls_create_ctx_args, void *apparg);
43
44struct tls_start_proxy_args
45{
46 int fd;
47 int client_p;
48 SSL_CTX *ctx;
49 pid_t *pid;
50 int *infofd;
51};
52struct tls_start_proxy_args tls_start_proxy_defaultargs(void);
53/* tls_start_proxy return value *MUST* be checked!
54 * 0 means ok, otherwise we've probably run out of some resources. */
55int tls_start_proxy(struct tls_start_proxy_args, void *apparg);
56
57#endif
diff --git a/src/lib/libssl/src/demos/easy_tls/test.c b/src/lib/libssl/src/demos/easy_tls/test.c
new file mode 100644
index 0000000000..4ce676ca93
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/test.c
@@ -0,0 +1,244 @@
1/* test.c */
2/* $Id: test.c,v 1.1 2002/05/15 02:29:18 beck Exp $ */
3
4#define L_PORT 9999
5#define C_PORT 443
6
7#include <arpa/inet.h>
8#include <assert.h>
9#include <errno.h>
10#include <fcntl.h>
11#include <netinet/in.h>
12#include <netinet/tcp.h>
13#include <stdlib.h>
14#include <stdio.h>
15#include <string.h>
16#include <sys/select.h>
17#include <sys/socket.h>
18#include <unistd.h>
19
20#include "test.h"
21#include "easy-tls.h"
22
23void
24test_process_init(int fd, int client_p, void *apparg)
25{
26 fprintf(stderr, "test_process_init(fd = %d, client_p = %d, apparg = %p)\n", fd, client_p, apparg);
27}
28
29void
30test_errflush(int child_p, char *errbuf, size_t num, void *apparg)
31{
32 fputs(errbuf, stderr);
33}
34
35
36int
37main(int argc, char *argv[])
38{
39 int s, fd, r;
40 FILE *conn_in;
41 FILE *conn_out;
42 char buf[256];
43 SSL_CTX *ctx;
44 int client_p = 0;
45 int port;
46 int tls = 0;
47 char infobuf[TLS_INFO_SIZE + 1];
48
49 if (argc > 1 && argv[1][0] == '-') {
50 fputs("Usage: test [port] -- server\n"
51 " test num.num.num.num [port] -- client\n",
52 stderr);
53 exit(1);
54 }
55
56 if (argc > 1) {
57 if (strchr(argv[1], '.')) {
58 client_p = 1;
59 }
60 }
61
62 fputs(client_p ? "Client\n" : "Server\n", stderr);
63
64 {
65 struct tls_create_ctx_args a = tls_create_ctx_defaultargs();
66 a.client_p = client_p;
67 a.certificate_file = "cert.pem";
68 a.key_file = "cert.pem";
69 a.ca_file = "cacerts.pem";
70
71 ctx = tls_create_ctx(a, NULL);
72 if (ctx == NULL)
73 exit(1);
74 }
75
76 s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
77 if (s == -1) {
78 perror("socket");
79 exit(1);
80 }
81
82 if (client_p) {
83 struct sockaddr_in addr;
84 size_t addr_len = sizeof addr;
85
86 addr.sin_family = AF_INET;
87 assert(argc > 1);
88 if (argc > 2)
89 sscanf(argv[2], "%d", &port);
90 else
91 port = C_PORT;
92 addr.sin_port = htons(port);
93 addr.sin_addr.s_addr = inet_addr(argv[1]);
94
95 r = connect(s, &addr, addr_len);
96 if (r != 0) {
97 perror("connect");
98 exit(1);
99 }
100 fd = s;
101 fprintf(stderr, "Connect (fd = %d).\n", fd);
102 } else {
103 /* server */
104 {
105 int i = 1;
106
107 r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *) &i, sizeof i);
108 if (r == -1) {
109 perror("setsockopt");
110 exit(1);
111 }
112 }
113
114 {
115 struct sockaddr_in addr;
116 size_t addr_len = sizeof addr;
117
118 if (argc > 1)
119 sscanf(argv[1], "%d", &port);
120 else
121 port = L_PORT;
122 addr.sin_family = AF_INET;
123 addr.sin_port = htons(port);
124 addr.sin_addr.s_addr = INADDR_ANY;
125
126 r = bind(s, &addr, addr_len);
127 if (r != 0) {
128 perror("bind");
129 exit(1);
130 }
131 }
132
133 r = listen(s, 1);
134 if (r == -1) {
135 perror("listen");
136 exit(1);
137 }
138
139 fprintf(stderr, "Listening at port %i.\n", port);
140
141 fd = accept(s, NULL, 0);
142 if (fd == -1) {
143 perror("accept");
144 exit(1);
145 }
146
147 fprintf(stderr, "Accept (fd = %d).\n", fd);
148 }
149
150 conn_in = fdopen(fd, "r");
151 if (conn_in == NULL) {
152 perror("fdopen");
153 exit(1);
154 }
155 conn_out = fdopen(fd, "w");
156 if (conn_out == NULL) {
157 perror("fdopen");
158 exit(1);
159 }
160
161 setvbuf(conn_in, NULL, _IOLBF, 256);
162 setvbuf(conn_out, NULL, _IOLBF, 256);
163
164 while (fgets(buf, sizeof buf, stdin) != NULL) {
165 if (buf[0] == 'W') {
166 fprintf(conn_out, "%.*s\r\n", (int)(strlen(buf + 1) - 1), buf + 1);
167 fprintf(stderr, ">>> %.*s\n", (int)(strlen(buf + 1) - 1), buf + 1);
168 } else if (buf[0] == 'C') {
169 fprintf(stderr, "Closing.\n");
170 fclose(conn_in);
171 fclose(conn_out);
172 exit(0);
173 } else if (buf[0] == 'R') {
174 int lines = 0;
175
176 sscanf(buf + 1, "%d", &lines);
177 do {
178 if (fgets(buf, sizeof buf, conn_in) == NULL) {
179 if (ferror(conn_in)) {
180 fprintf(stderr, "ERROR\n");
181 exit(1);
182 }
183 fprintf(stderr, "CLOSED\n");
184 return 0;
185 }
186 fprintf(stderr, "<<< %s", buf);
187 } while (--lines > 0);
188 } else if (buf[0] == 'T') {
189 int infofd;
190
191 tls++;
192 {
193 struct tls_start_proxy_args a = tls_start_proxy_defaultargs();
194 a.fd = fd;
195 a.client_p = client_p;
196 a.ctx = ctx;
197 a.infofd = &infofd;
198 r = tls_start_proxy(a, NULL);
199 }
200 assert(r != 1);
201 if (r != 0) {
202 fprintf(stderr, "tls_start_proxy failed: %d\n", r);
203 switch (r) {
204 case -1:
205 fputs("socketpair", stderr); break;
206 case 2:
207 fputs("FD_SETSIZE exceeded", stderr); break;
208 case -3:
209 fputs("pipe", stderr); break;
210 case -4:
211 fputs("fork", stderr); break;
212 case -5:
213 fputs("dup2", stderr); break;
214 default:
215 fputs("?", stderr);
216 }
217 if (r < 0)
218 perror("");
219 else
220 fputc('\n', stderr);
221 exit(1);
222 }
223
224 r = read(infofd, infobuf, sizeof infobuf - 1);
225 if (r > 0) {
226 const char *info = infobuf;
227 const char *eol;
228
229 infobuf[r] = '\0';
230 while ((eol = strchr(info, '\n')) != NULL) {
231 fprintf(stderr, "+++ `%.*s'\n", eol - info, info);
232 info = eol+1;
233 }
234 close (infofd);
235 }
236 } else {
237 fprintf(stderr, "W... write line to network\n"
238 "R[n] read line (n lines) from network\n"
239 "C close\n"
240 "T start %sTLS proxy\n", tls ? "another " : "");
241 }
242 }
243 return 0;
244}
diff --git a/src/lib/libssl/src/demos/easy_tls/test.h b/src/lib/libssl/src/demos/easy_tls/test.h
new file mode 100644
index 0000000000..c580169464
--- /dev/null
+++ b/src/lib/libssl/src/demos/easy_tls/test.h
@@ -0,0 +1,11 @@
1/* test.h */
2/* $Id: test.h,v 1.1 2002/05/15 02:29:18 beck Exp $ */
3
4
5void test_process_init(int fd, int client_p, void *apparg);
6#define TLS_APP_PROCESS_INIT test_process_init
7
8#undef TLS_CUMULATE_ERRORS
9
10void test_errflush(int child_p, char *errbuf, size_t num, void *apparg);
11#define TLS_APP_ERRFLUSH test_errflush
diff --git a/src/lib/libssl/src/demos/maurice/example1.c b/src/lib/libssl/src/demos/maurice/example1.c
index 0e70523a33..1ef8299900 100644
--- a/src/lib/libssl/src/demos/maurice/example1.c
+++ b/src/lib/libssl/src/demos/maurice/example1.c
@@ -72,7 +72,7 @@ void main_encrypt(void)
72 72
73 pubKey[0] = ReadPublicKey(PUBFILE); 73 pubKey[0] = ReadPublicKey(PUBFILE);
74 74
75 if(!pubKey) 75 if(!pubKey[0])
76 { 76 {
77 fprintf(stderr,"Error: can't load public key"); 77 fprintf(stderr,"Error: can't load public key");
78 exit(1); 78 exit(1);
@@ -126,11 +126,11 @@ void main_encrypt(void)
126 126
127void main_decrypt(void) 127void main_decrypt(void)
128{ 128{
129 char buf[512]; 129 char buf[520];
130 char ebuf[512]; 130 char ebuf[512];
131 unsigned int buflen; 131 unsigned int buflen;
132 EVP_CIPHER_CTX ectx; 132 EVP_CIPHER_CTX ectx;
133 unsigned char iv[8]; 133 unsigned char iv[EVP_MAX_IV_LENGTH];
134 unsigned char *encryptKey; 134 unsigned char *encryptKey;
135 unsigned int ekeylen; 135 unsigned int ekeylen;
136 EVP_PKEY *privateKey; 136 EVP_PKEY *privateKey;
@@ -164,7 +164,6 @@ void main_decrypt(void)
164 164
165 read(STDIN, encryptKey, ekeylen); 165 read(STDIN, encryptKey, ekeylen);
166 read(STDIN, iv, sizeof(iv)); 166 read(STDIN, iv, sizeof(iv));
167
168 EVP_OpenInit(&ectx, 167 EVP_OpenInit(&ectx,
169 EVP_des_ede3_cbc(), 168 EVP_des_ede3_cbc(),
170 encryptKey, 169 encryptKey,
@@ -185,7 +184,6 @@ void main_decrypt(void)
185 } 184 }
186 185
187 EVP_OpenUpdate(&ectx, buf, &buflen, ebuf, readlen); 186 EVP_OpenUpdate(&ectx, buf, &buflen, ebuf, readlen);
188
189 write(STDOUT, buf, buflen); 187 write(STDOUT, buf, buflen);
190 } 188 }
191 189
diff --git a/src/lib/libssl/src/demos/maurice/example3.c b/src/lib/libssl/src/demos/maurice/example3.c
index c8462a47c3..03d8a20f62 100644
--- a/src/lib/libssl/src/demos/maurice/example3.c
+++ b/src/lib/libssl/src/demos/maurice/example3.c
@@ -57,7 +57,8 @@ void do_cipher(char *pw, int operation)
57 57
58 EVP_BytesToKey(ALG, EVP_md5(), "salu", pw, strlen(pw), 1, key, iv); 58 EVP_BytesToKey(ALG, EVP_md5(), "salu", pw, strlen(pw), 1, key, iv);
59 59
60 EVP_CipherInit(&ectx, ALG, key, iv, operation); 60 EVP_CIPHER_CTX_init(&ectx);
61 EVP_CipherInit_ex(&ectx, ALG, NULL, key, iv, operation);
61 62
62 while(1) 63 while(1)
63 { 64 {
@@ -79,7 +80,8 @@ void do_cipher(char *pw, int operation)
79 write(STDOUT, ebuf, ebuflen); 80 write(STDOUT, ebuf, ebuflen);
80 } 81 }
81 82
82 EVP_CipherFinal(&ectx, ebuf, &ebuflen); 83 EVP_CipherFinal_ex(&ectx, ebuf, &ebuflen);
84 EVP_CIPHER_CTX_cleanup(&ectx);
83 85
84 write(STDOUT, ebuf, ebuflen); 86 write(STDOUT, ebuf, ebuflen);
85} 87}
diff --git a/src/lib/libssl/src/demos/maurice/loadkeys.c b/src/lib/libssl/src/demos/maurice/loadkeys.c
index 0f3464753a..82fd22a950 100644
--- a/src/lib/libssl/src/demos/maurice/loadkeys.c
+++ b/src/lib/libssl/src/demos/maurice/loadkeys.c
@@ -31,9 +31,7 @@ EVP_PKEY * ReadPublicKey(const char *certfile)
31 if (!fp) 31 if (!fp)
32 return NULL; 32 return NULL;
33 33
34 x509 = (X509 *)PEM_ASN1_read ((char *(*)())d2i_X509, 34 x509 = PEM_read_X509(fp, NULL, 0, NULL);
35 PEM_STRING_X509,
36 fp, NULL, NULL);
37 35
38 if (x509 == NULL) 36 if (x509 == NULL)
39 { 37 {
@@ -61,10 +59,7 @@ EVP_PKEY *ReadPrivateKey(const char *keyfile)
61 if (!fp) 59 if (!fp)
62 return NULL; 60 return NULL;
63 61
64 pkey = (EVP_PKEY*)PEM_ASN1_read ((char *(*)())d2i_PrivateKey, 62 pkey = PEM_read_PrivateKey(fp, NULL, 0, NULL);
65 PEM_STRING_EVP_PKEY,
66 fp,
67 NULL, NULL);
68 63
69 fclose (fp); 64 fclose (fp);
70 65
diff --git a/src/lib/libssl/src/demos/pkcs12/README b/src/lib/libssl/src/demos/pkcs12/README
new file mode 100644
index 0000000000..c87434b04f
--- /dev/null
+++ b/src/lib/libssl/src/demos/pkcs12/README
@@ -0,0 +1,3 @@
1PKCS#12 demo applications
2
3Written by Steve Henson.
diff --git a/src/lib/libssl/src/demos/pkcs12/pkread.c b/src/lib/libssl/src/demos/pkcs12/pkread.c
new file mode 100644
index 0000000000..8e1b686312
--- /dev/null
+++ b/src/lib/libssl/src/demos/pkcs12/pkread.c
@@ -0,0 +1,61 @@
1/* pkread.c */
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <openssl/pem.h>
6#include <openssl/err.h>
7#include <openssl/pkcs12.h>
8
9/* Simple PKCS#12 file reader */
10
11int main(int argc, char **argv)
12{
13 FILE *fp;
14 EVP_PKEY *pkey;
15 X509 *cert;
16 STACK_OF(X509) *ca = NULL;
17 PKCS12 *p12;
18 int i;
19 if (argc != 4) {
20 fprintf(stderr, "Usage: pkread p12file password opfile\n");
21 exit (1);
22 }
23 SSLeay_add_all_algorithms();
24 ERR_load_crypto_strings();
25 if (!(fp = fopen(argv[1], "rb"))) {
26 fprintf(stderr, "Error opening file %s\n", argv[1]);
27 exit(1);
28 }
29 p12 = d2i_PKCS12_fp(fp, NULL);
30 fclose (fp);
31 if (!p12) {
32 fprintf(stderr, "Error reading PKCS#12 file\n");
33 ERR_print_errors_fp(stderr);
34 exit (1);
35 }
36 if (!PKCS12_parse(p12, argv[2], &pkey, &cert, &ca)) {
37 fprintf(stderr, "Error parsing PKCS#12 file\n");
38 ERR_print_errors_fp(stderr);
39 exit (1);
40 }
41 PKCS12_free(p12);
42 if (!(fp = fopen(argv[3], "w"))) {
43 fprintf(stderr, "Error opening file %s\n", argv[1]);
44 exit(1);
45 }
46 if (pkey) {
47 fprintf(fp, "***Private Key***\n");
48 PEM_write_PrivateKey(fp, pkey, NULL, NULL, 0, NULL, NULL);
49 }
50 if (cert) {
51 fprintf(fp, "***User Certificate***\n");
52 PEM_write_X509_AUX(fp, cert);
53 }
54 if (ca && sk_num(ca)) {
55 fprintf(fp, "***Other Certificates***\n");
56 for (i = 0; i < sk_X509_num(ca); i++)
57 PEM_write_X509_AUX(fp, sk_X509_value(ca, i));
58 }
59 fclose(fp);
60 return 0;
61}
diff --git a/src/lib/libssl/src/demos/pkcs12/pkwrite.c b/src/lib/libssl/src/demos/pkcs12/pkwrite.c
new file mode 100644
index 0000000000..15f839d1eb
--- /dev/null
+++ b/src/lib/libssl/src/demos/pkcs12/pkwrite.c
@@ -0,0 +1,46 @@
1/* pkwrite.c */
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <openssl/pem.h>
6#include <openssl/err.h>
7#include <openssl/pkcs12.h>
8
9/* Simple PKCS#12 file creator */
10
11int main(int argc, char **argv)
12{
13 FILE *fp;
14 EVP_PKEY *pkey;
15 X509 *cert;
16 PKCS12 *p12;
17 if (argc != 5) {
18 fprintf(stderr, "Usage: pkwrite infile password name p12file\n");
19 exit(1);
20 }
21 SSLeay_add_all_algorithms();
22 ERR_load_crypto_strings();
23 if (!(fp = fopen(argv[1], "r"))) {
24 fprintf(stderr, "Error opening file %s\n", argv[1]);
25 exit(1);
26 }
27 cert = PEM_read_X509(fp, NULL, NULL, NULL);
28 rewind(fp);
29 pkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL);
30 fclose(fp);
31 p12 = PKCS12_create(argv[2], argv[3], pkey, cert, NULL, 0,0,0,0,0);
32 if(!p12) {
33 fprintf(stderr, "Error creating PKCS#12 structure\n");
34 ERR_print_errors_fp(stderr);
35 exit(1);
36 }
37 if (!(fp = fopen(argv[4], "wb"))) {
38 fprintf(stderr, "Error opening file %s\n", argv[1]);
39 ERR_print_errors_fp(stderr);
40 exit(1);
41 }
42 i2d_PKCS12_fp(fp, p12);
43 PKCS12_free(p12);
44 fclose(fp);
45 return 0;
46}
diff --git a/src/lib/libssl/src/demos/sign/sign.c b/src/lib/libssl/src/demos/sign/sign.c
index 0fdf0de387..a6c66e17c3 100644
--- a/src/lib/libssl/src/demos/sign/sign.c
+++ b/src/lib/libssl/src/demos/sign/sign.c
@@ -96,7 +96,7 @@ int main ()
96 96
97 fp = fopen (keyfile, "r"); 97 fp = fopen (keyfile, "r");
98 if (fp == NULL) exit (1); 98 if (fp == NULL) exit (1);
99 pkey = PEM_read_PrivateKey(fp, NULL, NULL); 99 pkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL);
100 fclose (fp); 100 fclose (fp);
101 101
102 if (pkey == NULL) { 102 if (pkey == NULL) {
@@ -122,7 +122,7 @@ int main ()
122 122
123 fp = fopen (certfile, "r"); 123 fp = fopen (certfile, "r");
124 if (fp == NULL) exit (1); 124 if (fp == NULL) exit (1);
125 x509 = PEM_read_X509(fp, NULL, NULL); 125 x509 = PEM_read_X509(fp, NULL, NULL, NULL);
126 fclose (fp); 126 fclose (fp);
127 127
128 if (x509 == NULL) { 128 if (x509 == NULL) {
diff --git a/src/lib/libssl/src/demos/ssl/cli.cpp b/src/lib/libssl/src/demos/ssl/cli.cpp
index daea2bd9c7..49cba5da0c 100644
--- a/src/lib/libssl/src/demos/ssl/cli.cpp
+++ b/src/lib/libssl/src/demos/ssl/cli.cpp
@@ -79,12 +79,12 @@ void main ()
79 str = X509_NAME_oneline (X509_get_subject_name (server_cert),0,0); 79 str = X509_NAME_oneline (X509_get_subject_name (server_cert),0,0);
80 CHK_NULL(str); 80 CHK_NULL(str);
81 printf ("\t subject: %s\n", str); 81 printf ("\t subject: %s\n", str);
82 Free (str); 82 OPENSSL_free (str);
83 83
84 str = X509_NAME_oneline (X509_get_issuer_name (server_cert),0,0); 84 str = X509_NAME_oneline (X509_get_issuer_name (server_cert),0,0);
85 CHK_NULL(str); 85 CHK_NULL(str);
86 printf ("\t issuer: %s\n", str); 86 printf ("\t issuer: %s\n", str);
87 Free (str); 87 OPENSSL_free (str);
88 88
89 /* We could do all sorts of certificate verification stuff here before 89 /* We could do all sorts of certificate verification stuff here before
90 deallocating the certificate. */ 90 deallocating the certificate. */
diff --git a/src/lib/libssl/src/demos/ssl/inetdsrv.cpp b/src/lib/libssl/src/demos/ssl/inetdsrv.cpp
index 5b09227210..efd70d2771 100644
--- a/src/lib/libssl/src/demos/ssl/inetdsrv.cpp
+++ b/src/lib/libssl/src/demos/ssl/inetdsrv.cpp
@@ -65,12 +65,12 @@ void main ()
65 str = X509_NAME_oneline (X509_get_subject_name (client_cert)); 65 str = X509_NAME_oneline (X509_get_subject_name (client_cert));
66 CHK_NULL(str); 66 CHK_NULL(str);
67 fprintf (log, "\t subject: %s\n", str); 67 fprintf (log, "\t subject: %s\n", str);
68 Free (str); 68 OPENSSL_free (str);
69 69
70 str = X509_NAME_oneline (X509_get_issuer_name (client_cert)); 70 str = X509_NAME_oneline (X509_get_issuer_name (client_cert));
71 CHK_NULL(str); 71 CHK_NULL(str);
72 fprintf (log, "\t issuer: %s\n", str); 72 fprintf (log, "\t issuer: %s\n", str);
73 Free (str); 73 OPENSSL_free (str);
74 74
75 /* We could do all sorts of certificate verification stuff here before 75 /* We could do all sorts of certificate verification stuff here before
76 deallocating the certificate. */ 76 deallocating the certificate. */
diff --git a/src/lib/libssl/src/demos/ssl/serv.cpp b/src/lib/libssl/src/demos/ssl/serv.cpp
index aec610d018..b142c758d2 100644
--- a/src/lib/libssl/src/demos/ssl/serv.cpp
+++ b/src/lib/libssl/src/demos/ssl/serv.cpp
@@ -121,12 +121,12 @@ void main ()
121 str = X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0); 121 str = X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0);
122 CHK_NULL(str); 122 CHK_NULL(str);
123 printf ("\t subject: %s\n", str); 123 printf ("\t subject: %s\n", str);
124 Free (str); 124 OPENSSL_free (str);
125 125
126 str = X509_NAME_oneline (X509_get_issuer_name (client_cert), 0, 0); 126 str = X509_NAME_oneline (X509_get_issuer_name (client_cert), 0, 0);
127 CHK_NULL(str); 127 CHK_NULL(str);
128 printf ("\t issuer: %s\n", str); 128 printf ("\t issuer: %s\n", str);
129 Free (str); 129 OPENSSL_free (str);
130 130
131 /* We could do all sorts of certificate verification stuff here before 131 /* We could do all sorts of certificate verification stuff here before
132 deallocating the certificate. */ 132 deallocating the certificate. */
diff --git a/src/lib/libssl/src/demos/state_machine/Makefile b/src/lib/libssl/src/demos/state_machine/Makefile
new file mode 100644
index 0000000000..c7a114540d
--- /dev/null
+++ b/src/lib/libssl/src/demos/state_machine/Makefile
@@ -0,0 +1,9 @@
1CFLAGS=-I../../include -Wall -Werror -g
2
3all: state_machine
4
5state_machine: state_machine.o
6 $(CC) -o state_machine state_machine.o -L../.. -lssl -lcrypto
7
8test: state_machine
9 ./state_machine 10000 ../../apps/server.pem ../../apps/server.pem
diff --git a/src/lib/libssl/src/demos/state_machine/state_machine.c b/src/lib/libssl/src/demos/state_machine/state_machine.c
new file mode 100644
index 0000000000..fef3f3e3d1
--- /dev/null
+++ b/src/lib/libssl/src/demos/state_machine/state_machine.c
@@ -0,0 +1,416 @@
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 * 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/*
56 * Nuron, a leader in hardware encryption technology, generously
57 * sponsored the development of this demo by Ben Laurie.
58 *
59 * See http://www.nuron.com/.
60 */
61
62/*
63 * the aim of this demo is to provide a fully working state-machine
64 * style SSL implementation, i.e. one where the main loop acquires
65 * some data, then converts it from or to SSL by feeding it into the
66 * SSL state machine. It then does any I/O required by the state machine
67 * and loops.
68 *
69 * In order to keep things as simple as possible, this implementation
70 * listens on a TCP socket, which it expects to get an SSL connection
71 * on (for example, from s_client) and from then on writes decrypted
72 * data to stdout and encrypts anything arriving on stdin. Verbose
73 * commentary is written to stderr.
74 *
75 * This implementation acts as a server, but it can also be done for a client. */
76
77#include <openssl/ssl.h>
78#include <assert.h>
79#include <unistd.h>
80#include <string.h>
81#include <openssl/err.h>
82#include <sys/types.h>
83#include <sys/socket.h>
84#include <netinet/in.h>
85
86/* die_unless is intended to work like assert, except that it happens
87 always, even if NDEBUG is defined. Use assert as a stopgap. */
88
89#define die_unless(x) assert(x)
90
91typedef struct
92 {
93 SSL_CTX *pCtx;
94 BIO *pbioRead;
95 BIO *pbioWrite;
96 SSL *pSSL;
97 } SSLStateMachine;
98
99void SSLStateMachine_print_error(SSLStateMachine *pMachine,const char *szErr)
100 {
101 unsigned long l;
102
103 fprintf(stderr,"%s\n",szErr);
104 while((l=ERR_get_error()))
105 {
106 char buf[1024];
107
108 ERR_error_string_n(l,buf,sizeof buf);
109 fprintf(stderr,"Error %lx: %s\n",l,buf);
110 }
111 }
112
113SSLStateMachine *SSLStateMachine_new(const char *szCertificateFile,
114 const char *szKeyFile)
115 {
116 SSLStateMachine *pMachine=malloc(sizeof *pMachine);
117 int n;
118
119 die_unless(pMachine);
120
121 pMachine->pCtx=SSL_CTX_new(SSLv23_server_method());
122 die_unless(pMachine->pCtx);
123
124 n=SSL_CTX_use_certificate_file(pMachine->pCtx,szCertificateFile,
125 SSL_FILETYPE_PEM);
126 die_unless(n > 0);
127
128 n=SSL_CTX_use_PrivateKey_file(pMachine->pCtx,szKeyFile,SSL_FILETYPE_PEM);
129 die_unless(n > 0);
130
131 pMachine->pSSL=SSL_new(pMachine->pCtx);
132 die_unless(pMachine->pSSL);
133
134 pMachine->pbioRead=BIO_new(BIO_s_mem());
135
136 pMachine->pbioWrite=BIO_new(BIO_s_mem());
137
138 SSL_set_bio(pMachine->pSSL,pMachine->pbioRead,pMachine->pbioWrite);
139
140 SSL_set_accept_state(pMachine->pSSL);
141
142 return pMachine;
143 }
144
145void SSLStateMachine_read_inject(SSLStateMachine *pMachine,
146 const unsigned char *aucBuf,int nBuf)
147 {
148 int n=BIO_write(pMachine->pbioRead,aucBuf,nBuf);
149 /* If it turns out this assert fails, then buffer the data here
150 * and just feed it in in churn instead. Seems to me that it
151 * should be guaranteed to succeed, though.
152 */
153 assert(n == nBuf);
154 fprintf(stderr,"%d bytes of encrypted data fed to state machine\n",n);
155 }
156
157int SSLStateMachine_read_extract(SSLStateMachine *pMachine,
158 unsigned char *aucBuf,int nBuf)
159 {
160 int n;
161
162 if(!SSL_is_init_finished(pMachine->pSSL))
163 {
164 fprintf(stderr,"Doing SSL_accept\n");
165 n=SSL_accept(pMachine->pSSL);
166 if(n == 0)
167 fprintf(stderr,"SSL_accept returned zero\n");
168 if(n < 0)
169 {
170 int err;
171
172 if((err=SSL_get_error(pMachine->pSSL,n)) == SSL_ERROR_WANT_READ)
173 {
174 fprintf(stderr,"SSL_accept wants more data\n");
175 return 0;
176 }
177
178 SSLStateMachine_print_error(pMachine,"SSL_accept error");
179 exit(7);
180 }
181 return 0;
182 }
183
184 n=SSL_read(pMachine->pSSL,aucBuf,nBuf);
185 if(n < 0)
186 {
187 int err=SSL_get_error(pMachine->pSSL,n);
188
189 if(err == SSL_ERROR_WANT_READ)
190 {
191 fprintf(stderr,"SSL_read wants more data\n");
192 return 0;
193 }
194
195 SSLStateMachine_print_error(pMachine,"SSL_read error");
196 exit(8);
197 }
198
199 fprintf(stderr,"%d bytes of decrypted data read from state machine\n",n);
200 return n;
201 }
202
203int SSLStateMachine_write_can_extract(SSLStateMachine *pMachine)
204 {
205 int n=BIO_pending(pMachine->pbioWrite);
206 if(n)
207 fprintf(stderr,"There is encrypted data available to write\n");
208 else
209 fprintf(stderr,"There is no encrypted data available to write\n");
210
211 return n;
212 }
213
214int SSLStateMachine_write_extract(SSLStateMachine *pMachine,
215 unsigned char *aucBuf,int nBuf)
216 {
217 int n;
218
219 n=BIO_read(pMachine->pbioWrite,aucBuf,nBuf);
220 fprintf(stderr,"%d bytes of encrypted data read from state machine\n",n);
221 return n;
222 }
223
224void SSLStateMachine_write_inject(SSLStateMachine *pMachine,
225 const unsigned char *aucBuf,int nBuf)
226 {
227 int n=SSL_write(pMachine->pSSL,aucBuf,nBuf);
228 /* If it turns out this assert fails, then buffer the data here
229 * and just feed it in in churn instead. Seems to me that it
230 * should be guaranteed to succeed, though.
231 */
232 assert(n == nBuf);
233 fprintf(stderr,"%d bytes of unencrypted data fed to state machine\n",n);
234 }
235
236int OpenSocket(int nPort)
237 {
238 int nSocket;
239 struct sockaddr_in saServer;
240 struct sockaddr_in saClient;
241 int one=1;
242 int nSize;
243 int nFD;
244 int nLen;
245
246 nSocket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
247 if(nSocket < 0)
248 {
249 perror("socket");
250 exit(1);
251 }
252
253 if(setsockopt(nSocket,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof one) < 0)
254 {
255 perror("setsockopt");
256 exit(2);
257 }
258
259 memset(&saServer,0,sizeof saServer);
260 saServer.sin_family=AF_INET;
261 saServer.sin_port=htons(nPort);
262 nSize=sizeof saServer;
263 if(bind(nSocket,(struct sockaddr *)&saServer,nSize) < 0)
264 {
265 perror("bind");
266 exit(3);
267 }
268
269 if(listen(nSocket,512) < 0)
270 {
271 perror("listen");
272 exit(4);
273 }
274
275 nLen=sizeof saClient;
276 nFD=accept(nSocket,(struct sockaddr *)&saClient,&nLen);
277 if(nFD < 0)
278 {
279 perror("accept");
280 exit(5);
281 }
282
283 fprintf(stderr,"Incoming accepted on port %d\n",nPort);
284
285 return nFD;
286 }
287
288int main(int argc,char **argv)
289 {
290 SSLStateMachine *pMachine;
291 int nPort;
292 int nFD;
293 const char *szCertificateFile;
294 const char *szKeyFile;
295 char rbuf[1];
296 int nrbuf=0;
297
298 if(argc != 4)
299 {
300 fprintf(stderr,"%s <port> <certificate file> <key file>\n",argv[0]);
301 exit(6);
302 }
303
304 nPort=atoi(argv[1]);
305 szCertificateFile=argv[2];
306 szKeyFile=argv[3];
307
308 SSL_library_init();
309 OpenSSL_add_ssl_algorithms();
310 SSL_load_error_strings();
311 ERR_load_crypto_strings();
312
313 nFD=OpenSocket(nPort);
314
315 pMachine=SSLStateMachine_new(szCertificateFile,szKeyFile);
316
317 for( ; ; )
318 {
319 fd_set rfds,wfds;
320 unsigned char buf[1024];
321 int n;
322
323 FD_ZERO(&rfds);
324 FD_ZERO(&wfds);
325
326 /* Select socket for input */
327 FD_SET(nFD,&rfds);
328
329 /* check whether there's decrypted data */
330 if(!nrbuf)
331 nrbuf=SSLStateMachine_read_extract(pMachine,rbuf,1);
332
333 /* if there's decrypted data, check whether we can write it */
334 if(nrbuf)
335 FD_SET(1,&wfds);
336
337 /* Select socket for output */
338 if(SSLStateMachine_write_can_extract(pMachine))
339 FD_SET(nFD,&wfds);
340
341 /* Select stdin for input */
342 FD_SET(0,&rfds);
343
344 /* Wait for something to do something */
345 n=select(nFD+1,&rfds,&wfds,NULL,NULL);
346 assert(n > 0);
347
348 /* Socket is ready for input */
349 if(FD_ISSET(nFD,&rfds))
350 {
351 n=read(nFD,buf,sizeof buf);
352 if(n == 0)
353 {
354 fprintf(stderr,"Got EOF on socket\n");
355 exit(0);
356 }
357 assert(n > 0);
358
359 SSLStateMachine_read_inject(pMachine,buf,n);
360 }
361
362 /* stdout is ready for output (and hence we have some to send it) */
363 if(FD_ISSET(1,&wfds))
364 {
365 assert(nrbuf == 1);
366 buf[0]=rbuf[0];
367 nrbuf=0;
368
369 n=SSLStateMachine_read_extract(pMachine,buf+1,sizeof buf-1);
370 if(n < 0)
371 {
372 SSLStateMachine_print_error(pMachine,"read extract failed");
373 break;
374 }
375 assert(n >= 0);
376 ++n;
377 if(n > 0) /* FIXME: has to be true now */
378 {
379 int w;
380
381 w=write(1,buf,n);
382 /* FIXME: we should push back any unwritten data */
383 assert(w == n);
384 }
385 }
386
387 /* Socket is ready for output (and therefore we have output to send) */
388 if(FD_ISSET(nFD,&wfds))
389 {
390 int w;
391
392 n=SSLStateMachine_write_extract(pMachine,buf,sizeof buf);
393 assert(n > 0);
394
395 w=write(nFD,buf,n);
396 /* FIXME: we should push back any unwritten data */
397 assert(w == n);
398 }
399
400 /* Stdin is ready for input */
401 if(FD_ISSET(0,&rfds))
402 {
403 n=read(0,buf,sizeof buf);
404 if(n == 0)
405 {
406 fprintf(stderr,"Got EOF on stdin\n");
407 exit(0);
408 }
409 assert(n > 0);
410
411 SSLStateMachine_write_inject(pMachine,buf,n);
412 }
413 }
414 /* not reached */
415 return 0;
416 }
diff --git a/src/lib/libssl/src/demos/tunala/A-client.pem b/src/lib/libssl/src/demos/tunala/A-client.pem
new file mode 100644
index 0000000000..a4caf6ef8a
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/A-client.pem
@@ -0,0 +1,84 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 2 (0x2)
5 Signature Algorithm: md5WithRSAEncryption
6 Issuer: C=NZ, L=Wellington, O=Really Irresponsible Authorisation Authority (RIAA), OU=Cert-stamping, CN=Jackov al-Trades/Email=none@fake.domain
7 Validity
8 Not Before: Jan 16 05:19:30 2002 GMT
9 Not After : Jan 14 05:19:30 2012 GMT
10 Subject: C=NZ, L=Auckland, O=Mordor, OU=SSL grunt things, CN=tunala-client/Email=client@fake.domain
11 Subject Public Key Info:
12 Public Key Algorithm: rsaEncryption
13 RSA Public Key: (1024 bit)
14 Modulus (1024 bit):
15 00:b0:d3:56:5c:c8:7f:fb:f4:95:9d:04:84:4f:82:
16 b7:a2:75:5c:81:48:8c:56:5d:52:ee:38:e1:5c:c8:
17 9a:70:8e:72:f2:00:1c:17:ef:df:b7:06:59:82:04:
18 f1:f6:49:11:12:a6:4d:cb:1e:ed:ac:59:1c:4a:d0:
19 3d:de:e6:f2:8d:cd:39:c2:0f:e0:46:2f:db:cb:9f:
20 47:f7:56:e7:f8:16:5f:68:71:fb:3a:e3:ab:d2:e5:
21 05:b7:da:65:61:fe:6d:30:e4:12:a8:b5:c1:71:24:
22 6b:aa:80:05:41:17:a0:8b:6e:8b:e6:04:cf:85:7b:
23 2a:ac:a1:79:7d:f4:96:6e:77
24 Exponent: 65537 (0x10001)
25 X509v3 extensions:
26 X509v3 Basic Constraints:
27 CA:FALSE
28 Netscape Comment:
29 OpenSSL Generated Certificate
30 X509v3 Subject Key Identifier:
31 F8:43:CB:4F:4D:4F:BC:6E:52:1A:FD:F9:7B:E1:12:3F:A7:A3:BA:93
32 X509v3 Authority Key Identifier:
33 keyid:49:FB:45:72:12:C4:CC:E1:45:A1:D3:08:9E:95:C4:2C:6D:55:3F:17
34 DirName:/C=NZ/L=Wellington/O=Really Irresponsible Authorisation Authority (RIAA)/OU=Cert-stamping/CN=Jackov al-Trades/Email=none@fake.domain
35 serial:00
36
37 Signature Algorithm: md5WithRSAEncryption
38 8f:5f:0e:43:da:9d:61:43:7e:03:38:9a:e6:50:9d:42:e8:95:
39 34:49:75:ec:04:8d:5c:85:99:94:70:a0:e7:1f:1e:a0:8b:0f:
40 d6:e2:cb:f7:35:d9:96:72:bd:a6:e9:8d:4e:b1:e2:ac:97:7f:
41 2f:70:01:9d:aa:04:bc:d4:01:2b:63:77:a5:de:63:3c:a8:f5:
42 f2:72:af:ec:11:12:c0:d4:70:cf:71:a6:fb:e9:1d:b3:27:07:
43 aa:f2:b1:f3:87:d6:ab:8b:ce:c2:08:1b:3c:f9:ba:ff:77:71:
44 86:09:ef:9e:4e:04:06:63:44:e9:93:20:90:c7:2d:50:c6:50:
45 f8:66
46-----BEGIN CERTIFICATE-----
47MIID9TCCA16gAwIBAgIBAjANBgkqhkiG9w0BAQQFADCBtDELMAkGA1UEBhMCTlox
48EzARBgNVBAcTCldlbGxpbmd0b24xPDA6BgNVBAoTM1JlYWxseSBJcnJlc3BvbnNp
49YmxlIEF1dGhvcmlzYXRpb24gQXV0aG9yaXR5IChSSUFBKTEWMBQGA1UECxMNQ2Vy
50dC1zdGFtcGluZzEZMBcGA1UEAxMQSmFja292IGFsLVRyYWRlczEfMB0GCSqGSIb3
51DQEJARYQbm9uZUBmYWtlLmRvbWFpbjAeFw0wMjAxMTYwNTE5MzBaFw0xMjAxMTQw
52NTE5MzBaMIGHMQswCQYDVQQGEwJOWjERMA8GA1UEBxMIQXVja2xhbmQxDzANBgNV
53BAoTBk1vcmRvcjEZMBcGA1UECxMQU1NMIGdydW50IHRoaW5nczEWMBQGA1UEAxMN
54dHVuYWxhLWNsaWVudDEhMB8GCSqGSIb3DQEJARYSY2xpZW50QGZha2UuZG9tYWlu
55MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw01ZcyH/79JWdBIRPgreidVyB
56SIxWXVLuOOFcyJpwjnLyABwX79+3BlmCBPH2SRESpk3LHu2sWRxK0D3e5vKNzTnC
57D+BGL9vLn0f3Vuf4Fl9ocfs646vS5QW32mVh/m0w5BKotcFxJGuqgAVBF6CLbovm
58BM+FeyqsoXl99JZudwIDAQABo4IBQDCCATwwCQYDVR0TBAIwADAsBglghkgBhvhC
59AQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFPhD
60y09NT7xuUhr9+XvhEj+no7qTMIHhBgNVHSMEgdkwgdaAFEn7RXISxMzhRaHTCJ6V
61xCxtVT8XoYG6pIG3MIG0MQswCQYDVQQGEwJOWjETMBEGA1UEBxMKV2VsbGluZ3Rv
62bjE8MDoGA1UEChMzUmVhbGx5IElycmVzcG9uc2libGUgQXV0aG9yaXNhdGlvbiBB
63dXRob3JpdHkgKFJJQUEpMRYwFAYDVQQLEw1DZXJ0LXN0YW1waW5nMRkwFwYDVQQD
64ExBKYWNrb3YgYWwtVHJhZGVzMR8wHQYJKoZIhvcNAQkBFhBub25lQGZha2UuZG9t
65YWluggEAMA0GCSqGSIb3DQEBBAUAA4GBAI9fDkPanWFDfgM4muZQnULolTRJdewE
66jVyFmZRwoOcfHqCLD9biy/c12ZZyvabpjU6x4qyXfy9wAZ2qBLzUAStjd6XeYzyo
679fJyr+wREsDUcM9xpvvpHbMnB6rysfOH1quLzsIIGzz5uv93cYYJ755OBAZjROmT
68IJDHLVDGUPhm
69-----END CERTIFICATE-----
70-----BEGIN RSA PRIVATE KEY-----
71MIICXgIBAAKBgQCw01ZcyH/79JWdBIRPgreidVyBSIxWXVLuOOFcyJpwjnLyABwX
7279+3BlmCBPH2SRESpk3LHu2sWRxK0D3e5vKNzTnCD+BGL9vLn0f3Vuf4Fl9ocfs6
7346vS5QW32mVh/m0w5BKotcFxJGuqgAVBF6CLbovmBM+FeyqsoXl99JZudwIDAQAB
74AoGAU4chbqbPvkclPYzaq2yGLlneHrwUft+KwzlfS6L/QVgo+CQRIUWQmjaHpaGM
75YtjVFcg1S1QK1bUqZjTEZT0XKhfbYmqW8yYTfbcDEbnY7esoYlvIlW8qRlPRlTBE
76utKrtZafmVhLgoNawYGD0aLZofPqpYjbGUlrC7nrem2vNJECQQDVLD3Qb+OlEMET
7773ApnJhYsK3e+G2LTrtjrS8y5zS4+Xv61XUqvdV7ogzRl0tpvSAmMOItVyoYadkB
78S3xSIWX9AkEA1Fm1FhkQSZwGG5rf4c6gMN71jJ6JE3/kocdVa0sUjRevIupo4XQ2
79Vkykxi84MRP8cfHqyjewq7Ozv3op2MGWgwJBAKemsb66IJjzAkaBav7u70nhOf0/
80+Dc1Zl7QF2y7NVW8sGrnccx5m+ot2lMD4AV6/kvK6jaqdKrapBZGnbGiHqkCQQDI
81T1r33mqz1R8Z2S2Jtzz6/McKf930a/dC+GLGVEutkILf39lRmytKmv/wB0jtWtoO
82rlJ5sLDSNzC+1cE1u997AkEAu3IrtGmLKiuS6kDj6W47m+iiTIsuSJtTJb1SbUaK
83fIoBNFxbvJYW6rUU9+PxpMRaEhzh5s24/jBOE+mlb17mRQ==
84-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/demos/tunala/A-server.pem b/src/lib/libssl/src/demos/tunala/A-server.pem
new file mode 100644
index 0000000000..e9f37b1895
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/A-server.pem
@@ -0,0 +1,84 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 1 (0x1)
5 Signature Algorithm: md5WithRSAEncryption
6 Issuer: C=NZ, L=Wellington, O=Really Irresponsible Authorisation Authority (RIAA), OU=Cert-stamping, CN=Jackov al-Trades/Email=none@fake.domain
7 Validity
8 Not Before: Jan 16 05:14:06 2002 GMT
9 Not After : Jan 14 05:14:06 2012 GMT
10 Subject: C=NZ, L=Wellington, O=Middle Earth, OU=SSL dev things, CN=tunala-server/Email=server@fake.domain
11 Subject Public Key Info:
12 Public Key Algorithm: rsaEncryption
13 RSA Public Key: (1024 bit)
14 Modulus (1024 bit):
15 00:a9:3e:62:87:97:13:6b:de:8f:bc:1d:0a:3f:65:
16 0c:f9:76:a3:53:ce:97:30:27:0d:c6:df:72:1f:8d:
17 5a:ce:58:23:6a:65:e5:e3:72:1a:8d:7f:fe:90:01:
18 ea:42:f1:9f:6e:7b:0a:bd:eb:52:15:7b:f4:3d:9c:
19 4e:db:74:29:2b:d1:81:9d:b9:9e:18:2b:87:e1:da:
20 50:20:3c:59:6c:c9:83:3e:2c:11:0b:78:1e:03:f4:
21 56:3a:db:95:6a:75:33:85:a9:7b:cc:3c:4a:67:96:
22 f2:24:b2:a0:cb:2e:cc:52:18:16:6f:44:d9:29:64:
23 07:2e:fb:56:cc:7c:dc:a2:d7
24 Exponent: 65537 (0x10001)
25 X509v3 extensions:
26 X509v3 Basic Constraints:
27 CA:FALSE
28 Netscape Comment:
29 OpenSSL Generated Certificate
30 X509v3 Subject Key Identifier:
31 70:AC:7A:B5:6E:97:C2:82:AF:11:9E:32:CB:8D:48:49:93:B7:DC:22
32 X509v3 Authority Key Identifier:
33 keyid:49:FB:45:72:12:C4:CC:E1:45:A1:D3:08:9E:95:C4:2C:6D:55:3F:17
34 DirName:/C=NZ/L=Wellington/O=Really Irresponsible Authorisation Authority (RIAA)/OU=Cert-stamping/CN=Jackov al-Trades/Email=none@fake.domain
35 serial:00
36
37 Signature Algorithm: md5WithRSAEncryption
38 2e:cb:a3:cd:6d:a8:9d:d1:dc:e5:f0:e0:27:7e:4b:5a:90:a8:
39 85:43:f0:05:f7:04:43:d7:5f:d1:a5:8f:5c:58:eb:fc:da:c6:
40 7c:e0:0b:2b:98:72:95:f6:79:48:96:7a:fa:0c:6b:09:ec:c6:
41 8c:91:74:45:9f:8f:0f:16:78:e3:66:14:fa:1e:f4:f0:23:ec:
42 cd:a9:52:77:20:4d:c5:05:2c:52:b6:7b:f3:42:33:fd:90:1f:
43 3e:88:6f:9b:23:61:c8:80:3b:e6:57:84:2e:f7:26:c7:35:ed:
44 00:8b:08:30:9b:aa:21:83:b6:6d:b8:7c:8a:9b:2a:ef:79:3d:
45 96:31
46-----BEGIN CERTIFICATE-----
47MIID+zCCA2SgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBtDELMAkGA1UEBhMCTlox
48EzARBgNVBAcTCldlbGxpbmd0b24xPDA6BgNVBAoTM1JlYWxseSBJcnJlc3BvbnNp
49YmxlIEF1dGhvcmlzYXRpb24gQXV0aG9yaXR5IChSSUFBKTEWMBQGA1UECxMNQ2Vy
50dC1zdGFtcGluZzEZMBcGA1UEAxMQSmFja292IGFsLVRyYWRlczEfMB0GCSqGSIb3
51DQEJARYQbm9uZUBmYWtlLmRvbWFpbjAeFw0wMjAxMTYwNTE0MDZaFw0xMjAxMTQw
52NTE0MDZaMIGNMQswCQYDVQQGEwJOWjETMBEGA1UEBxMKV2VsbGluZ3RvbjEVMBMG
53A1UEChMMTWlkZGxlIEVhcnRoMRcwFQYDVQQLEw5TU0wgZGV2IHRoaW5nczEWMBQG
54A1UEAxMNdHVuYWxhLXNlcnZlcjEhMB8GCSqGSIb3DQEJARYSc2VydmVyQGZha2Uu
55ZG9tYWluMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpPmKHlxNr3o+8HQo/
56ZQz5dqNTzpcwJw3G33IfjVrOWCNqZeXjchqNf/6QAepC8Z9uewq961IVe/Q9nE7b
57dCkr0YGduZ4YK4fh2lAgPFlsyYM+LBELeB4D9FY625VqdTOFqXvMPEpnlvIksqDL
58LsxSGBZvRNkpZAcu+1bMfNyi1wIDAQABo4IBQDCCATwwCQYDVR0TBAIwADAsBglg
59hkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0O
60BBYEFHCserVul8KCrxGeMsuNSEmTt9wiMIHhBgNVHSMEgdkwgdaAFEn7RXISxMzh
61RaHTCJ6VxCxtVT8XoYG6pIG3MIG0MQswCQYDVQQGEwJOWjETMBEGA1UEBxMKV2Vs
62bGluZ3RvbjE8MDoGA1UEChMzUmVhbGx5IElycmVzcG9uc2libGUgQXV0aG9yaXNh
63dGlvbiBBdXRob3JpdHkgKFJJQUEpMRYwFAYDVQQLEw1DZXJ0LXN0YW1waW5nMRkw
64FwYDVQQDExBKYWNrb3YgYWwtVHJhZGVzMR8wHQYJKoZIhvcNAQkBFhBub25lQGZh
65a2UuZG9tYWluggEAMA0GCSqGSIb3DQEBBAUAA4GBAC7Lo81tqJ3R3OXw4Cd+S1qQ
66qIVD8AX3BEPXX9Glj1xY6/zaxnzgCyuYcpX2eUiWevoMawnsxoyRdEWfjw8WeONm
67FPoe9PAj7M2pUncgTcUFLFK2e/NCM/2QHz6Ib5sjYciAO+ZXhC73Jsc17QCLCDCb
68qiGDtm24fIqbKu95PZYx
69-----END CERTIFICATE-----
70-----BEGIN RSA PRIVATE KEY-----
71MIICXAIBAAKBgQCpPmKHlxNr3o+8HQo/ZQz5dqNTzpcwJw3G33IfjVrOWCNqZeXj
72chqNf/6QAepC8Z9uewq961IVe/Q9nE7bdCkr0YGduZ4YK4fh2lAgPFlsyYM+LBEL
73eB4D9FY625VqdTOFqXvMPEpnlvIksqDLLsxSGBZvRNkpZAcu+1bMfNyi1wIDAQAB
74AoGANCwqHZhiAU/TyW6+WPqivEhpYw19p/dyFMuPF9DwnEmpaUROUQY8z0AUznn4
75qHhp6Jn/nrprTHowucl0ucweYIYVxZoUiUDFpxdFUbzMdFvo6HcyV1Pe4Rt81HaY
76KYWrTZ6PaPtN65hLms8NhPEdGcGAFlY1owYv4QNGq2bU1JECQQDd32LM0NSfyGmK
774ziajqGcvzK9NO2XyV/nJsGlJZNgMh2zm1t7yR28l/6Q2uyU49cCN+2aYULZCAfs
78taNvxBspAkEAw0alNub+xj2AVQvaxOB1sGfKzsJjHCzKIxUXn/tJi3j0+2asmkBZ
79Umx1MWr9jKQBnCMciCRUbnMEZiElOxCN/wJAfAeQl6Z19gx206lJzzzEo3dOye54
80k02DSxijT8q9pBzf9bN3ZK987BybtiZr8p+bZiYVsSOF1wViSLURdD1QYQJAIaMU
81qH1n24wShBPTrmAfxbBLTgxL+Dl65Eoo1KT7iSvfv0JzbuqwuDL4iPeuD0DdCiE+
82M/FWHeRwGIuTFzaFzwJBANKwx0jZS/h093w9g0Clw6UzeA1P5VcAt9y+qMC9hO3c
834KXwIxQAt9yRaFLpiIR9do5bjjKNnMguf3aO/XRSDQM=
84-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/demos/tunala/CA.pem b/src/lib/libssl/src/demos/tunala/CA.pem
new file mode 100644
index 0000000000..7a55b5463e
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/CA.pem
@@ -0,0 +1,24 @@
1-----BEGIN CERTIFICATE-----
2MIID9zCCA2CgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBtDELMAkGA1UEBhMCTlox
3EzARBgNVBAcTCldlbGxpbmd0b24xPDA6BgNVBAoTM1JlYWxseSBJcnJlc3BvbnNp
4YmxlIEF1dGhvcmlzYXRpb24gQXV0aG9yaXR5IChSSUFBKTEWMBQGA1UECxMNQ2Vy
5dC1zdGFtcGluZzEZMBcGA1UEAxMQSmFja292IGFsLVRyYWRlczEfMB0GCSqGSIb3
6DQEJARYQbm9uZUBmYWtlLmRvbWFpbjAeFw0wMjAxMTYwNTA5NTlaFw0xMjAxMTQw
7NTA5NTlaMIG0MQswCQYDVQQGEwJOWjETMBEGA1UEBxMKV2VsbGluZ3RvbjE8MDoG
8A1UEChMzUmVhbGx5IElycmVzcG9uc2libGUgQXV0aG9yaXNhdGlvbiBBdXRob3Jp
9dHkgKFJJQUEpMRYwFAYDVQQLEw1DZXJ0LXN0YW1waW5nMRkwFwYDVQQDExBKYWNr
10b3YgYWwtVHJhZGVzMR8wHQYJKoZIhvcNAQkBFhBub25lQGZha2UuZG9tYWluMIGf
11MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7QdDfFIrJn3X24hKmpkyk3TG0Ivxd
12K2wWmDPXq1wjr8lUTwrA6hM5Ba9N36jLieWpXhviLOWu9DBza5GmtgCuXloATKTC
1394xOdKHlciTVujG3wDlLDB5e710Kar84nnj6VueL1RyZ0bmP5PANa4mbGW9Tqc7J
14CkBTTW2y9d0SgQIDAQABo4IBFTCCAREwHQYDVR0OBBYEFEn7RXISxMzhRaHTCJ6V
15xCxtVT8XMIHhBgNVHSMEgdkwgdaAFEn7RXISxMzhRaHTCJ6VxCxtVT8XoYG6pIG3
16MIG0MQswCQYDVQQGEwJOWjETMBEGA1UEBxMKV2VsbGluZ3RvbjE8MDoGA1UEChMz
17UmVhbGx5IElycmVzcG9uc2libGUgQXV0aG9yaXNhdGlvbiBBdXRob3JpdHkgKFJJ
18QUEpMRYwFAYDVQQLEw1DZXJ0LXN0YW1waW5nMRkwFwYDVQQDExBKYWNrb3YgYWwt
19VHJhZGVzMR8wHQYJKoZIhvcNAQkBFhBub25lQGZha2UuZG9tYWluggEAMAwGA1Ud
20EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAYQo95V/NY+eKxYxkhibZiUQygph+
21gTfgbDG20MsnH6+8//w5ArHauFCgDrf0P2VyACgq+N4pBTWFGaAaLwbjKy9HCe2E
22j9C91tO1CqDS4MJkDB5AP13FTkK6fP1ZCiTQranOAp3DlGWTTWsFVyW5kVfQ9diS
23ZOyJZ9Fit5XM2X0=
24-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/demos/tunala/INSTALL b/src/lib/libssl/src/demos/tunala/INSTALL
new file mode 100644
index 0000000000..a65bbeb8d1
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/INSTALL
@@ -0,0 +1,107 @@
1There are two ways to build this code;
2
3(1) Manually
4
5(2) Using all-singing all-dancing (all-confusing) autotools, ie. autoconf,
6automake, and their little friends (autoheader, etc).
7
8=================
9Building Manually
10=================
11
12There is a basic "Makefile" in this directory that gets moved out of the way and
13ignored when building with autoconf et al. This Makefile is suitable for
14building tunala on Linux using gcc. Any other platform probably requires some
15tweaking. Here are the various bits you might need to do if you want to build
16this way and the default Makefile isn't sufficient;
17
18* Compiler: Edit the "CC" definition in Makefile
19
20* Headers, features: tunala.h controls what happens in the non-autoconf world.
21 It, by default, assumes the system has *everything* (except autoconf's
22 "config.h") so if a target system is missing something it must define the
23 appropriate "NO_***" symbols in CFLAGS. These include;
24
25 - NO_HAVE_UNISTD_H, NO_HAVE_FCNTL_H, NO_HAVE_LIMITS_H
26 Indicates the compiling system doesn't have (or need) these header files.
27 - NO_HAVE_STRSTR, NO_HAVE_STRTOUL
28 Indicates the compiling system doesn't have these functions. Replacements
29 are compiled and used in breakage.c
30 - NO_HAVE_SELECT, NO_HAVE_SOCKET
31 Pointless symbols - these indicate select() and/or socket() are missing in
32 which case the program won't compile anyway.
33
34 If you want to specify any of these, add them with "-D" prefixed to each in
35 the CFLAGS definition in Makefile.
36
37* Compilation flags: edit DEBUG_FLAGS and/or CFLAGS directly to control the
38 flags passed to the compiler. This can also be used to change the degree of
39 optimisation.
40
41* Linker flags: some systems (eg. Solaris) require extra linker flags such as;
42 -ldl, -lsocket, -lnsl, etc. If unsure, bring up the man page for whichever
43 function is "undefined" when the linker fails - that usually indicates what
44 you need to add. Make changes to the LINK_FLAGS symbol.
45
46* Linker command: if a different linker syntax or even a different program is
47 required to link, edit the linker line directly in the "tunala:" target
48 definition - it currently assumes the "CC" (compiler) program is used to link.
49
50======================
51Building Automagically
52======================
53
54Automagic building is handled courtesy of autoconf, automake, etc. There are in
55fact two steps required to build, and only the first has to be done on a system
56with these tools installed (and if I was prepared to bloat out the CVS
57repository, I could store these extra files, but I'm not).
58
59First step: "autogunk.sh"
60-------------------------
61
62The "./autogunk.sh" script will call all the necessary autotool commands to
63create missing files and run automake and autoconf. The result is that a
64"./configure" script should be generated and a "Makefile.in" generated from the
65supplied "Makefile.am". NB: This script also moves the "manual" Makefile (see
66above) out of the way and calls it "Makefile.plain" - the "ungunk" script
67reverses this to leave the directory it was previously.
68
69Once "ungunk" has been run, the resulting directory should be able to build on
70other systems without autoconf, automake, or libtool. Which is what the second
71step describes;
72
73Second step: "./configure"
74--------------------------
75
76The second step is to run the generated "./configure" script to create a
77config.h header for your system and to generate a "Makefile" (generated from
78"Makefile.in") tweaked to compile on your system. This is the standard sort of
79thing you see in GNU packages, for example, and the standard tricks also work.
80Eg. to override "configure"'s choice of compiler, set the CC environment
81variable prior to running configure, eg.
82
83 CC=gcc ./configure
84
85would cause "gcc" to be used even if there is an otherwise preferable (to
86autoconf) native compiler on your system.
87
88After this run "make" and it should build the "tunala" executable.
89
90Notes
91-----
92
93- Some versions of autoconf (or automake?) generate a Makefile syntax that gives
94 trouble to some "make" programs on some systems (eg. OpenBSD). If this
95 happens, either build 'Manually' (see above) or use "gmake" instead of "make".
96 I don't like this either but like even less the idea of sifting into all the
97 script magic crud that's involved.
98
99- On a solaris system I tried, the "configure" script specified some broken
100 compiler flags in the resulting Makefile that don't even get echoed to
101 stdout/err when the error happens (evil!). If this happens, go into the
102 generated Makefile, find the two affected targets ("%.o:" and "%.lo"), and
103 remove the offending hidden option in the $(COMPILE) line all the sludge after
104 the two first lines of script (ie. after the "echo" and the "COMPILE" lines).
105 NB: This will probably only function if "--disable-shared" was used, otherwise
106 who knows what would result ...
107
diff --git a/src/lib/libssl/src/demos/tunala/Makefile b/src/lib/libssl/src/demos/tunala/Makefile
new file mode 100644
index 0000000000..bef1704a3c
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/Makefile
@@ -0,0 +1,41 @@
1# Edit these to suit
2#
3# Oh yeah, and please read the README too.
4
5
6SSL_HOMEDIR=../..
7SSL_INCLUDEDIR=$(SSL_HOMEDIR)/include
8SSL_LIBDIR=$(SSL_HOMEDIR)
9
10RM=rm -f
11CC=gcc
12DEBUG_FLAGS=-g -ggdb3 -Wall -Wshadow
13INCLUDE_FLAGS=-I$(SSL_INCLUDEDIR)
14CFLAGS=$(DEBUG_FLAGS) $(INCLUDE_FLAGS) -DNO_CONFIG_H
15COMPILE=$(CC) $(CFLAGS) -c
16
17# Edit, particularly the "-ldl" if not building with "dlfcn" support
18LINK_FLAGS=-L$(SSL_LIBDIR) -lssl -lcrypto -ldl
19
20SRCS=buffer.c cb.c ip.c sm.c tunala.c breakage.c
21OBJS=buffer.o cb.o ip.o sm.o tunala.o breakage.o
22
23TARGETS=tunala
24
25default: $(TARGETS)
26
27clean:
28 $(RM) $(OBJS) $(TARGETS) *.bak core
29
30.c.o:
31 $(COMPILE) $<
32
33tunala: $(OBJS)
34 $(CC) -o tunala $(OBJS) $(LINK_FLAGS)
35
36# Extra dependencies, should really use makedepend
37buffer.o: buffer.c tunala.h
38cb.o: cb.c tunala.h
39ip.o: ip.c tunala.h
40sm.o: sm.c tunala.h
41tunala.o: tunala.c tunala.h
diff --git a/src/lib/libssl/src/demos/tunala/Makefile.am b/src/lib/libssl/src/demos/tunala/Makefile.am
new file mode 100644
index 0000000000..706c7806c9
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/Makefile.am
@@ -0,0 +1,7 @@
1# Our includes come from the OpenSSL build-tree we're in
2INCLUDES = -I$(top_builddir)/../../include
3
4bin_PROGRAMS = tunala
5
6tunala_SOURCES = tunala.c buffer.c cb.c ip.c sm.c breakage.c
7tunala_LDADD = -L$(top_builddir)/../.. -lssl -lcrypto
diff --git a/src/lib/libssl/src/demos/tunala/README b/src/lib/libssl/src/demos/tunala/README
new file mode 100644
index 0000000000..15690088f3
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/README
@@ -0,0 +1,233 @@
1This is intended to be an example of a state-machine driven SSL application. It
2acts as an SSL tunneler (functioning as either the server or client half,
3depending on command-line arguments). *PLEASE* read the comments in tunala.h
4before you treat this stuff as anything more than a curiosity - YOU HAVE BEEN
5WARNED!! There, that's the draconian bit out of the way ...
6
7
8Why "tunala"??
9--------------
10
11I thought I asked you to read tunala.h?? :-)
12
13
14Show me
15-------
16
17If you want to simply see it running, skip to the end and see some example
18command-line arguments to demonstrate with.
19
20
21Where to look and what to do?
22-----------------------------
23
24The code is split up roughly coinciding with the detaching of an "abstract" SSL
25state machine (which is the purpose of all this) and its surrounding application
26specifics. This is primarily to make it possible for me to know when I could cut
27corners and when I needed to be rigorous (or at least maintain the pretense as
28such :-).
29
30Network stuff:
31
32Basically, the network part of all this is what is supposed to be abstracted out
33of the way. The intention is to illustrate one way to stick OpenSSL's mechanisms
34inside a little memory-driven sandbox and operate it like a pure state-machine.
35So, the network code is inside both ip.c (general utility functions and gory
36IPv4 details) and tunala.c itself, which takes care of application specifics
37like the main select() loop. The connectivity between the specifics of this
38application (TCP/IP tunneling and the associated network code) and the
39underlying abstract SSL state machine stuff is through the use of the "buffer_t"
40type, declared in tunala.h and implemented in buffer.c.
41
42State machine:
43
44Which leaves us, generally speaking, with the abstract "state machine" code left
45over and this is sitting inside sm.c, with declarations inside tunala.h. As can
46be seen by the definition of the state_machine_t structure and the associated
47functions to manipulate it, there are the 3 OpenSSL "handles" plus 4 buffer_t
48structures dealing with IO on both the encrypted and unencrypted sides ("dirty"
49and "clean" respectively). The "SSL" handle is what facilitates the reading and
50writing of the unencrypted (tunneled) data. The two "BIO" handles act as the
51read and write channels for encrypted tunnel traffic - in other applications
52these are often socket BIOs so that the OpenSSL framework operates with the
53network layer directly. In this example, those two BIOs are memory BIOs
54(BIO_s_mem()) so that the sending and receiving of the tunnel traffic stays
55within the state-machine, and we can handle where this gets send to (or read
56from) ourselves.
57
58
59Why?
60----
61
62If you take a look at the "state_machine_t" section of tunala.h and the code in
63sm.c, you will notice that nothing related to the concept of 'transport' is
64involved. The binding to TCP/IP networking occurs in tunala.c, specifically
65within the "tunala_item_t" structure that associates a state_machine_t object
66with 4 file-descriptors. The way to best see where the bridge between the
67outside world (TCP/IP reads, writes, select()s, file-descriptors, etc) and the
68state machine is, is to examine the "tunala_item_io()" function in tunala.c.
69This is currently around lines 641-732 but of course could be subject to change.
70
71
72And...?
73-------
74
75Well, although that function is around 90 lines of code, it could easily have
76been a lot less only I was trying to address an easily missed "gotcha" (item (2)
77below). The main() code that drives the select/accept/IO loop initialises new
78tunala_item_t structures when connections arrive, and works out which
79file-descriptors go where depending on whether we're an SSL client or server
80(client --> accepted connection is clean and proxied is dirty, server -->
81accepted connection is dirty and proxied is clean). What that tunala_item_io()
82function is attempting to do is 2 things;
83
84 (1) Perform all reads and writes on the network directly into the
85 state_machine_t's buffers (based on a previous select() result), and only
86 then allow the abstact state_machine_t to "churn()" using those buffers.
87 This will cause the SSL machine to consume as much input data from the two
88 "IN" buffers as possible, and generate as much output data into the two
89 "OUT" buffers as possible. Back up in the main() function, the next main
90 loop loop will examine these output buffers and select() for writability
91 on the corresponding sockets if the buffers are non-empty.
92
93 (2) Handle the complicated tunneling-specific issue of cascading "close"s.
94 This is the reason for most of the complexity in the logic - if one side
95 of the tunnel is closed, you can't simply close the other side and throw
96 away the whole thing - (a) there may still be outgoing data on the other
97 side of the tunnel that hasn't been sent yet, (b) the close (or things
98 happening during the close) may cause more data to be generated that needs
99 sending on the other side. Of course, this logic is complicated yet futher
100 by the fact that it's different depending on which side closes first :-)
101 state_machine_close_clean() will indicate to the state machine that the
102 unencrypted side of the tunnel has closed, so any existing outgoing data
103 needs to be flushed, and the SSL stream needs to be closed down using the
104 appropriate shutdown sequence. state_machine_close_dirty() is simpler
105 because it indicates that the SSL stream has been disconnected, so all
106 that remains before closing the other side is to flush out anything that
107 remains and wait for it to all be sent.
108
109Anyway, with those things in mind, the code should be a little easier to follow
110in terms of "what is *this* bit supposed to achieve??!!".
111
112
113How might this help?
114--------------------
115
116Well, the reason I wrote this is that there seemed to be rather a flood of
117questions of late on the openssl-dev and openssl-users lists about getting this
118whole IO logic thing sorted out, particularly by those who were trying to either
119use non-blocking IO, or wanted SSL in an environment where "something else" was
120handling the network already and they needed to operate in memory only. This
121code is loosely based on some other stuff I've been working on, although that
122stuff is far more complete, far more dependant on a whole slew of other
123network/framework code I don't want to incorporate here, and far harder to look
124at for 5 minutes and follow where everything is going. I will be trying over
125time to suck in a few things from that into this demo in the hopes it might be
126more useful, and maybe to even make this demo usable as a utility of its own.
127Possible things include:
128
129 * controlling multiple processes/threads - this can be used to combat
130 latencies and get passed file-descriptor limits on some systems, and it uses
131 a "controller" process/thread that maintains IPC links with the
132 processes/threads doing the real work.
133
134 * cert verification rules - having some say over which certs get in or out :-)
135
136 * control over SSL protocols and cipher suites
137
138 * A few other things you can already do in s_client and s_server :-)
139
140 * Support (and control over) session resuming, particularly when functioning
141 as an SSL client.
142
143If you have a particular environment where this model might work to let you "do
144SSL" without having OpenSSL be aware of the transport, then you should find you
145could use the state_machine_t structure (or your own variant thereof) and hook
146it up to your transport stuff in much the way tunala.c matches it up with those
1474 file-descriptors. The state_machine_churn(), state_machine_close_clean(), and
148state_machine_close_dirty() functions are the main things to understand - after
149that's done, you just have to ensure you're feeding and bleeding the 4
150state_machine buffers in a logical fashion. This state_machine loop handles not
151only handshakes and normal streaming, but also renegotiates - there's no special
152handling required beyond keeping an eye on those 4 buffers and keeping them in
153sync with your outer "loop" logic. Ie. if one of the OUT buffers is not empty,
154you need to find an opportunity to try and forward its data on. If one of the IN
155buffers is not full, you should keep an eye out for data arriving that should be
156placed there.
157
158This approach could hopefully also allow you to run the SSL protocol in very
159different environments. As an example, you could support encrypted event-driven
160IPC where threads/processes pass messages to each other inside an SSL layer;
161each IPC-message's payload would be in fact the "dirty" content, and the "clean"
162payload coming out of the tunnel at each end would be the real intended message.
163Likewise, this could *easily* be made to work across unix domain sockets, or
164even entirely different network/comms protocols.
165
166This is also a quick and easy way to do VPN if you (and the remote network's
167gateway) support virtual network devices that are encapsulted in a single
168network connection, perhaps PPP going through an SSL tunnel?
169
170
171Suggestions
172-----------
173
174Please let me know if you find this useful, or if there's anything wrong or
175simply too confusing about it. Patches are also welcome, but please attach a
176description of what it changes and why, and "diff -urN" format is preferred.
177Mail to geoff@openssl.org should do the trick.
178
179
180Example
181-------
182
183Here is an example of how to use "tunala" ...
184
185First, it's assumed that OpenSSL has already built, and that you are building
186inside the ./demos/tunala/ directory. If not - please correct the paths and
187flags inside the Makefile. Likewise, if you want to tweak the building, it's
188best to try and do so in the makefile (eg. removing the debug flags and adding
189optimisation flags).
190
191Secondly, this code has mostly only been tested on Linux. However, some
192autoconf/etc support has been added and the code has been compiled on openbsd
193and solaris using that.
194
195Thirdly, if you are Win32, you probably need to do some *major* rewriting of
196ip.c to stand a hope in hell. Good luck, and please mail me the diff if you do
197this, otherwise I will take a look at another time. It can certainly be done,
198but it's very non-POSIXy.
199
200See the INSTALL document for details on building.
201
202Now, if you don't have an executable "tunala" compiled, go back to "First,...".
203Rinse and repeat.
204
205Inside one console, try typing;
206
207(i) ./tunala -listen localhost:8080 -proxy localhost:8081 -cacert CA.pem \
208 -cert A-client.pem -out_totals -v_peer -v_strict
209
210In another console, type;
211
212(ii) ./tunala -listen localhost:8081 -proxy localhost:23 -cacert CA.pem \
213 -cert A-server.pem -server 1 -out_totals -v_peer -v_strict
214
215Now if you open another console and "telnet localhost 8080", you should be
216tunneled through to the telnet service on your local machine (if it's running -
217you could change it to port "22" and tunnel ssh instead if you so desired). When
218you logout of the telnet session, the tunnel should cleanly shutdown and show
219you some traffic stats in both consoles. Feel free to experiment. :-)
220
221Notes:
222
223 - the format for the "-listen" argument can skip the host part (eg. "-listen
224 8080" is fine). If you do, the listening socket will listen on all interfaces
225 so you can connect from other machines for example. Using the "localhost"
226 form listens only on 127.0.0.1 so you can only connect locally (unless, of
227 course, you've set up weird stuff with your networking in which case probably
228 none of the above applies).
229
230 - ./tunala -? gives you a list of other command-line options, but tunala.c is
231 also a good place to look :-)
232
233
diff --git a/src/lib/libssl/src/demos/tunala/autogunk.sh b/src/lib/libssl/src/demos/tunala/autogunk.sh
new file mode 100644
index 0000000000..c9783c6261
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/autogunk.sh
@@ -0,0 +1,25 @@
1#!/bin/sh
2
3# This script tries to follow the "GNU way" w.r.t. the autobits.
4# This does of course generate a number of irritating files.
5# Try to get over it (I am getting there myself).
6
7# This should generate any missing crud, and then run autoconf which should turn
8# configure.in into a "./configure" script and "Makefile.am" into a
9# "Makefile.in". Then running "./configure" should turn "Makefile.in" into
10# "Makefile" and should generate the config.h containing your systems various
11# settings. I know ... what a hassle ...
12
13# Also, sometimes these autobits things generate bizarre output (looking like
14# errors). So I direct everything "elsewhere" ...
15
16(aclocal
17autoheader
18libtoolize --copy --force
19automake --foreign --add-missing --copy
20autoconf) 1> /dev/null 2>&1
21
22# Move the "no-autotools" Makefile out of the way
23if test ! -f Makefile.plain; then
24 mv Makefile Makefile.plain
25fi
diff --git a/src/lib/libssl/src/demos/tunala/autoungunk.sh b/src/lib/libssl/src/demos/tunala/autoungunk.sh
new file mode 100644
index 0000000000..14d10790fd
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/autoungunk.sh
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3# This script tries to clean up as much as is possible from whatever diabolical
4# mess has been left in the directory thanks to autoconf, automake, and their
5# friends.
6
7if test -f Makefile; then
8 make distclean
9 rm -f Makefile
10fi
11
12if test -f Makefile.plain; then
13 mv Makefile.plain Makefile
14fi
15
16rm -f aclocal.m4 config.* configure install-sh \
17 missing mkinstalldirs stamp-h.* Makefile.in \
18 ltconfig ltmain.sh
diff --git a/src/lib/libssl/src/demos/tunala/breakage.c b/src/lib/libssl/src/demos/tunala/breakage.c
new file mode 100644
index 0000000000..dcdd64b0ef
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/breakage.c
@@ -0,0 +1,66 @@
1#include "tunala.h"
2
3int int_strtoul(const char *str, unsigned long *val)
4{
5#ifdef HAVE_STRTOUL
6 char *tmp;
7 unsigned long ret = strtoul(str, &tmp, 10);
8 if((str == tmp) || (*tmp != '\0'))
9 /* The value didn't parse cleanly */
10 return 0;
11 if(ret == ULONG_MAX)
12 /* We hit a limit */
13 return 0;
14 *val = ret;
15 return 1;
16#else
17 char buf[2];
18 unsigned long ret = 0;
19 buf[1] = '\0';
20 if(str == '\0')
21 /* An empty string ... */
22 return 0;
23 while(*str != '\0') {
24 /* We have to multiply 'ret' by 10 before absorbing the next
25 * digit. If this will overflow, catch it now. */
26 if(ret && (((ULONG_MAX + 10) / ret) < 10))
27 return 0;
28 ret *= 10;
29 if(!isdigit(*str))
30 return 0;
31 buf[0] = *str;
32 ret += atoi(buf);
33 str++;
34 }
35 *val = ret;
36 return 1;
37#endif
38}
39
40#ifndef HAVE_STRSTR
41char *int_strstr(const char *haystack, const char *needle)
42{
43 const char *sub_haystack = haystack, *sub_needle = needle;
44 unsigned int offset = 0;
45 if(!needle)
46 return haystack;
47 if(!haystack)
48 return NULL;
49 while((*sub_haystack != '\0') && (*sub_needle != '\0')) {
50 if(sub_haystack[offset] == sub_needle) {
51 /* sub_haystack is still a candidate */
52 offset++;
53 sub_needle++;
54 } else {
55 /* sub_haystack is no longer a possibility */
56 sub_haystack++;
57 offset = 0;
58 sub_needle = needle;
59 }
60 }
61 if(*sub_haystack == '\0')
62 /* Found nothing */
63 return NULL;
64 return sub_haystack;
65}
66#endif
diff --git a/src/lib/libssl/src/demos/tunala/buffer.c b/src/lib/libssl/src/demos/tunala/buffer.c
new file mode 100644
index 0000000000..c5cd004209
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/buffer.c
@@ -0,0 +1,205 @@
1#include "tunala.h"
2
3#ifndef NO_BUFFER
4
5void buffer_init(buffer_t *buf)
6{
7 buf->used = 0;
8 buf->total_in = buf->total_out = 0;
9}
10
11void buffer_close(buffer_t *buf)
12{
13 /* Our data is static - nothing needs "release", just reset it */
14 buf->used = 0;
15}
16
17/* Code these simple ones in compact form */
18unsigned int buffer_used(buffer_t *buf) {
19 return buf->used; }
20unsigned int buffer_unused(buffer_t *buf) {
21 return (MAX_DATA_SIZE - buf->used); }
22int buffer_full(buffer_t *buf) {
23 return (buf->used == MAX_DATA_SIZE ? 1 : 0); }
24int buffer_notfull(buffer_t *buf) {
25 return (buf->used < MAX_DATA_SIZE ? 1 : 0); }
26int buffer_empty(buffer_t *buf) {
27 return (buf->used == 0 ? 1 : 0); }
28int buffer_notempty(buffer_t *buf) {
29 return (buf->used > 0 ? 1 : 0); }
30unsigned long buffer_total_in(buffer_t *buf) {
31 return buf->total_in; }
32unsigned long buffer_total_out(buffer_t *buf) {
33 return buf->total_out; }
34
35/* These 3 static (internal) functions don't adjust the "total" variables as
36 * it's not sure when they're called how it should be interpreted. Only the
37 * higher-level "buffer_[to|from]_[fd|SSL|BIO]" functions should alter these
38 * values. */
39#if 0 /* To avoid "unused" warnings */
40static unsigned int buffer_adddata(buffer_t *buf, const unsigned char *ptr,
41 unsigned int size)
42{
43 unsigned int added = MAX_DATA_SIZE - buf->used;
44 if(added > size)
45 added = size;
46 if(added == 0)
47 return 0;
48 memcpy(buf->data + buf->used, ptr, added);
49 buf->used += added;
50 buf->total_in += added;
51 return added;
52}
53
54static unsigned int buffer_tobuffer(buffer_t *to, buffer_t *from, int cap)
55{
56 unsigned int moved, tomove = from->used;
57 if((int)tomove > cap)
58 tomove = cap;
59 if(tomove == 0)
60 return 0;
61 moved = buffer_adddata(to, from->data, tomove);
62 if(moved == 0)
63 return 0;
64 buffer_takedata(from, NULL, moved);
65 return moved;
66}
67#endif
68
69static unsigned int buffer_takedata(buffer_t *buf, unsigned char *ptr,
70 unsigned int size)
71{
72 unsigned int taken = buf->used;
73 if(taken > size)
74 taken = size;
75 if(taken == 0)
76 return 0;
77 if(ptr)
78 memcpy(ptr, buf->data, taken);
79 buf->used -= taken;
80 /* Do we have to scroll? */
81 if(buf->used > 0)
82 memmove(buf->data, buf->data + taken, buf->used);
83 return taken;
84}
85
86#ifndef NO_IP
87
88int buffer_from_fd(buffer_t *buf, int fd)
89{
90 int toread = buffer_unused(buf);
91 if(toread == 0)
92 /* Shouldn't be called in this case! */
93 abort();
94 toread = read(fd, buf->data + buf->used, toread);
95 if(toread > 0) {
96 buf->used += toread;
97 buf->total_in += toread;
98 }
99 return toread;
100}
101
102int buffer_to_fd(buffer_t *buf, int fd)
103{
104 int towrite = buffer_used(buf);
105 if(towrite == 0)
106 /* Shouldn't be called in this case! */
107 abort();
108 towrite = write(fd, buf->data, towrite);
109 if(towrite > 0) {
110 buffer_takedata(buf, NULL, towrite);
111 buf->total_out += towrite;
112 }
113 return towrite;
114}
115
116#endif /* !defined(NO_IP) */
117
118#ifndef NO_OPENSSL
119
120static void int_ssl_check(SSL *s, int ret)
121{
122 int e = SSL_get_error(s, ret);
123 switch(e) {
124 /* These seem to be harmless and already "dealt with" by our
125 * non-blocking environment. NB: "ZERO_RETURN" is the clean
126 * "error" indicating a successfully closed SSL tunnel. We let
127 * this happen because our IO loop should not appear to have
128 * broken on this condition - and outside the IO loop, the
129 * "shutdown" state is checked. */
130 case SSL_ERROR_NONE:
131 case SSL_ERROR_WANT_READ:
132 case SSL_ERROR_WANT_WRITE:
133 case SSL_ERROR_WANT_X509_LOOKUP:
134 case SSL_ERROR_ZERO_RETURN:
135 return;
136 /* These seem to be indications of a genuine error that should
137 * result in the SSL tunnel being regarded as "dead". */
138 case SSL_ERROR_SYSCALL:
139 case SSL_ERROR_SSL:
140 SSL_set_app_data(s, (char *)1);
141 return;
142 default:
143 break;
144 }
145 /* For any other errors that (a) exist, and (b) crop up - we need to
146 * interpret what to do with them - so "politely inform" the caller that
147 * the code needs updating here. */
148 abort();
149}
150
151void buffer_from_SSL(buffer_t *buf, SSL *ssl)
152{
153 int ret;
154 if(!ssl || buffer_full(buf))
155 return;
156 ret = SSL_read(ssl, buf->data + buf->used, buffer_unused(buf));
157 if(ret > 0) {
158 buf->used += ret;
159 buf->total_in += ret;
160 }
161 if(ret < 0)
162 int_ssl_check(ssl, ret);
163}
164
165void buffer_to_SSL(buffer_t *buf, SSL *ssl)
166{
167 int ret;
168 if(!ssl || buffer_empty(buf))
169 return;
170 ret = SSL_write(ssl, buf->data, buf->used);
171 if(ret > 0) {
172 buffer_takedata(buf, NULL, ret);
173 buf->total_out += ret;
174 }
175 if(ret < 0)
176 int_ssl_check(ssl, ret);
177}
178
179void buffer_from_BIO(buffer_t *buf, BIO *bio)
180{
181 int ret;
182 if(!bio || buffer_full(buf))
183 return;
184 ret = BIO_read(bio, buf->data + buf->used, buffer_unused(buf));
185 if(ret > 0) {
186 buf->used += ret;
187 buf->total_in += ret;
188 }
189}
190
191void buffer_to_BIO(buffer_t *buf, BIO *bio)
192{
193 int ret;
194 if(!bio || buffer_empty(buf))
195 return;
196 ret = BIO_write(bio, buf->data, buf->used);
197 if(ret > 0) {
198 buffer_takedata(buf, NULL, ret);
199 buf->total_out += ret;
200 }
201}
202
203#endif /* !defined(NO_OPENSSL) */
204
205#endif /* !defined(NO_BUFFER) */
diff --git a/src/lib/libssl/src/demos/tunala/cb.c b/src/lib/libssl/src/demos/tunala/cb.c
new file mode 100644
index 0000000000..cd32f74c70
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/cb.c
@@ -0,0 +1,133 @@
1#include "tunala.h"
2
3#ifndef NO_OPENSSL
4
5/* For callbacks generating output, here are their file-descriptors. */
6static FILE *fp_cb_ssl_info = NULL;
7static FILE *fp_cb_ssl_verify = NULL;
8/* Output level:
9 * 0 = nothing,
10 * 1 = minimal, just errors,
11 * 2 = minimal, all steps,
12 * 3 = detail, all steps */
13static unsigned int cb_ssl_verify_level = 1;
14
15/* Other static rubbish (to mirror s_cb.c where required) */
16static int int_verify_depth = 10;
17
18/* This function is largely borrowed from the one used in OpenSSL's "s_client"
19 * and "s_server" utilities. */
20void cb_ssl_info(const SSL *s, int where, int ret)
21{
22 const char *str1, *str2;
23 int w;
24
25 if(!fp_cb_ssl_info)
26 return;
27
28 w = where & ~SSL_ST_MASK;
29 str1 = (w & SSL_ST_CONNECT ? "SSL_connect" : (w & SSL_ST_ACCEPT ?
30 "SSL_accept" : "undefined")),
31 str2 = SSL_state_string_long(s);
32
33 if (where & SSL_CB_LOOP)
34 fprintf(fp_cb_ssl_info, "(%s) %s\n", str1, str2);
35 else if (where & SSL_CB_EXIT) {
36 if (ret == 0)
37 fprintf(fp_cb_ssl_info, "(%s) failed in %s\n", str1, str2);
38/* In a non-blocking model, we get a few of these "error"s simply because we're
39 * calling "reads" and "writes" on the state-machine that are virtual NOPs
40 * simply to avoid wasting the time seeing if we *should* call them. Removing
41 * this case makes the "-out_state" output a lot easier on the eye. */
42#if 0
43 else if (ret < 0)
44 fprintf(fp_cb_ssl_info, "%s:error in %s\n", str1, str2);
45#endif
46 }
47}
48
49void cb_ssl_info_set_output(FILE *fp)
50{
51 fp_cb_ssl_info = fp;
52}
53
54static const char *int_reason_no_issuer = "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT";
55static const char *int_reason_not_yet = "X509_V_ERR_CERT_NOT_YET_VALID";
56static const char *int_reason_before = "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD";
57static const char *int_reason_expired = "X509_V_ERR_CERT_HAS_EXPIRED";
58static const char *int_reason_after = "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD";
59
60/* Stolen wholesale from apps/s_cb.c :-) And since then, mutilated ... */
61int cb_ssl_verify(int ok, X509_STORE_CTX *ctx)
62{
63 char buf1[256]; /* Used for the subject name */
64 char buf2[256]; /* Used for the issuer name */
65 const char *reason = NULL; /* Error reason (if any) */
66 X509 *err_cert;
67 int err, depth;
68
69 if(!fp_cb_ssl_verify || (cb_ssl_verify_level == 0))
70 return ok;
71 err_cert = X509_STORE_CTX_get_current_cert(ctx);
72 err = X509_STORE_CTX_get_error(ctx);
73 depth = X509_STORE_CTX_get_error_depth(ctx);
74
75 buf1[0] = buf2[0] = '\0';
76 /* Fill buf1 */
77 X509_NAME_oneline(X509_get_subject_name(err_cert), buf1, 256);
78 /* Fill buf2 */
79 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf2, 256);
80 switch (ctx->error) {
81 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
82 reason = int_reason_no_issuer;
83 break;
84 case X509_V_ERR_CERT_NOT_YET_VALID:
85 reason = int_reason_not_yet;
86 break;
87 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
88 reason = int_reason_before;
89 break;
90 case X509_V_ERR_CERT_HAS_EXPIRED:
91 reason = int_reason_expired;
92 break;
93 case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
94 reason = int_reason_after;
95 break;
96 }
97
98 if((cb_ssl_verify_level == 1) && ok)
99 return ok;
100 fprintf(fp_cb_ssl_verify, "chain-depth=%d, ", depth);
101 if(reason)
102 fprintf(fp_cb_ssl_verify, "error=%s\n", reason);
103 else
104 fprintf(fp_cb_ssl_verify, "error=%d\n", err);
105 if(cb_ssl_verify_level < 3)
106 return ok;
107 fprintf(fp_cb_ssl_verify, "--> subject = %s\n", buf1);
108 fprintf(fp_cb_ssl_verify, "--> issuer = %s\n", buf2);
109 if(!ok)
110 fprintf(fp_cb_ssl_verify,"--> verify error:num=%d:%s\n",err,
111 X509_verify_cert_error_string(err));
112 fprintf(fp_cb_ssl_verify, "--> verify return:%d\n",ok);
113 return ok;
114}
115
116void cb_ssl_verify_set_output(FILE *fp)
117{
118 fp_cb_ssl_verify = fp;
119}
120
121void cb_ssl_verify_set_depth(unsigned int verify_depth)
122{
123 int_verify_depth = verify_depth;
124}
125
126void cb_ssl_verify_set_level(unsigned int level)
127{
128 if(level < 4)
129 cb_ssl_verify_level = level;
130}
131
132#endif /* !defined(NO_OPENSSL) */
133
diff --git a/src/lib/libssl/src/demos/tunala/configure.in b/src/lib/libssl/src/demos/tunala/configure.in
new file mode 100644
index 0000000000..b2a6ffc756
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/configure.in
@@ -0,0 +1,28 @@
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(tunala.c)
3AM_CONFIG_HEADER(config.h)
4AM_INIT_AUTOMAKE(tunala, 0.0.1-dev)
5
6dnl Checks for programs. (Though skip libtool)
7AC_PROG_CC
8dnl AC_PROG_LIBTOOL
9dnl AM_PROG_LIBTOOL
10
11dnl Checks for libraries.
12AC_CHECK_LIB(dl, dlopen)
13AC_CHECK_LIB(socket, socket)
14AC_CHECK_LIB(nsl, gethostbyname)
15
16dnl Checks for header files.
17AC_HEADER_STDC
18AC_CHECK_HEADERS(fcntl.h limits.h unistd.h)
19
20dnl Checks for typedefs, structures, and compiler characteristics.
21AC_C_CONST
22
23dnl Checks for library functions.
24AC_CHECK_FUNCS(strstr strtoul)
25AC_CHECK_FUNCS(select socket)
26AC_CHECK_FUNCS(dlopen)
27
28AC_OUTPUT(Makefile)
diff --git a/src/lib/libssl/src/demos/tunala/ip.c b/src/lib/libssl/src/demos/tunala/ip.c
new file mode 100644
index 0000000000..96ef4e6536
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/ip.c
@@ -0,0 +1,146 @@
1#include "tunala.h"
2
3#ifndef NO_IP
4
5#define IP_LISTENER_BACKLOG 511 /* So if it gets masked by 256 or some other
6 such value it'll still be respectable */
7
8/* Any IP-related initialisations. For now, this means blocking SIGPIPE */
9int ip_initialise(void)
10{
11 struct sigaction sa;
12
13 sa.sa_handler = SIG_IGN;
14 sa.sa_flags = 0;
15 sigemptyset(&sa.sa_mask);
16 if(sigaction(SIGPIPE, &sa, NULL) != 0)
17 return 0;
18 return 1;
19}
20
21int ip_create_listener_split(const char *ip, unsigned short port)
22{
23 struct sockaddr_in in_addr;
24 int fd = -1;
25 int reuseVal = 1;
26
27 /* Create the socket */
28 if((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
29 goto err;
30 /* Set the SO_REUSEADDR flag - servers act weird without it */
31 if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)(&reuseVal),
32 sizeof(reuseVal)) != 0)
33 goto err;
34 /* Prepare the listen address stuff */
35 in_addr.sin_family = AF_INET;
36 memcpy(&in_addr.sin_addr.s_addr, ip, 4);
37 in_addr.sin_port = htons(port);
38 /* Bind to the required port/address/interface */
39 if(bind(fd, (struct sockaddr *)&in_addr, sizeof(struct sockaddr_in)) != 0)
40 goto err;
41 /* Start "listening" */
42 if(listen(fd, IP_LISTENER_BACKLOG) != 0)
43 goto err;
44 return fd;
45err:
46 if(fd != -1)
47 close(fd);
48 return -1;
49}
50
51int ip_create_connection_split(const char *ip, unsigned short port)
52{
53 struct sockaddr_in in_addr;
54 int flags, fd = -1;
55
56 /* Create the socket */
57 if((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
58 goto err;
59 /* Make it non-blocking */
60 if(((flags = fcntl(fd, F_GETFL, 0)) < 0) ||
61 (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0))
62 goto err;
63 /* Prepare the connection address stuff */
64 in_addr.sin_family = AF_INET;
65 memcpy(&in_addr.sin_addr.s_addr, ip, 4);
66 in_addr.sin_port = htons(port);
67 /* Start a connect (non-blocking, in all likelihood) */
68 if((connect(fd, (struct sockaddr *)&in_addr,
69 sizeof(struct sockaddr_in)) != 0) &&
70 (errno != EINPROGRESS))
71 goto err;
72 return fd;
73err:
74 if(fd != -1)
75 close(fd);
76 return -1;
77}
78
79static char all_local_ip[] = {0x00,0x00,0x00,0x00};
80
81int ip_parse_address(const char *address, const char **parsed_ip,
82 unsigned short *parsed_port, int accept_all_ip)
83{
84 char buf[256];
85 struct hostent *lookup;
86 unsigned long port;
87 const char *ptr = strstr(address, ":");
88 const char *ip = all_local_ip;
89
90 if(!ptr) {
91 /* We assume we're listening on all local interfaces and have
92 * only specified a port. */
93 if(!accept_all_ip)
94 return 0;
95 ptr = address;
96 goto determine_port;
97 }
98 if((ptr - address) > 255)
99 return 0;
100 memset(buf, 0, 256);
101 memcpy(buf, address, ptr - address);
102 ptr++;
103 if((lookup = gethostbyname(buf)) == NULL) {
104 /* Spit a message to differentiate between lookup failures and
105 * bad strings. */
106 fprintf(stderr, "hostname lookup for '%s' failed\n", buf);
107 return 0;
108 }
109 ip = lookup->h_addr_list[0];
110determine_port:
111 if(strlen(ptr) < 1)
112 return 0;
113 if(!int_strtoul(ptr, &port) || (port > 65535))
114 return 0;
115 *parsed_ip = ip;
116 *parsed_port = (unsigned short)port;
117 return 1;
118}
119
120int ip_create_listener(const char *address)
121{
122 const char *ip;
123 unsigned short port;
124
125 if(!ip_parse_address(address, &ip, &port, 1))
126 return -1;
127 return ip_create_listener_split(ip, port);
128}
129
130int ip_create_connection(const char *address)
131{
132 const char *ip;
133 unsigned short port;
134
135 if(!ip_parse_address(address, &ip, &port, 0))
136 return -1;
137 return ip_create_connection_split(ip, port);
138}
139
140int ip_accept_connection(int listen_fd)
141{
142 return accept(listen_fd, NULL, NULL);
143}
144
145#endif /* !defined(NO_IP) */
146
diff --git a/src/lib/libssl/src/demos/tunala/sm.c b/src/lib/libssl/src/demos/tunala/sm.c
new file mode 100644
index 0000000000..25359e67ef
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/sm.c
@@ -0,0 +1,151 @@
1#include "tunala.h"
2
3#ifndef NO_TUNALA
4
5void state_machine_init(state_machine_t *machine)
6{
7 machine->ssl = NULL;
8 machine->bio_intossl = machine->bio_fromssl = NULL;
9 buffer_init(&machine->clean_in);
10 buffer_init(&machine->clean_out);
11 buffer_init(&machine->dirty_in);
12 buffer_init(&machine->dirty_out);
13}
14
15void state_machine_close(state_machine_t *machine)
16{
17 if(machine->ssl)
18 SSL_free(machine->ssl);
19/* SSL_free seems to decrement the reference counts already so doing this goes
20 * kaboom. */
21#if 0
22 if(machine->bio_intossl)
23 BIO_free(machine->bio_intossl);
24 if(machine->bio_fromssl)
25 BIO_free(machine->bio_fromssl);
26#endif
27 buffer_close(&machine->clean_in);
28 buffer_close(&machine->clean_out);
29 buffer_close(&machine->dirty_in);
30 buffer_close(&machine->dirty_out);
31 state_machine_init(machine);
32}
33
34buffer_t *state_machine_get_buffer(state_machine_t *machine, sm_buffer_t type)
35{
36 switch(type) {
37 case SM_CLEAN_IN:
38 return &machine->clean_in;
39 case SM_CLEAN_OUT:
40 return &machine->clean_out;
41 case SM_DIRTY_IN:
42 return &machine->dirty_in;
43 case SM_DIRTY_OUT:
44 return &machine->dirty_out;
45 default:
46 break;
47 }
48 /* Should never get here */
49 abort();
50 return NULL;
51}
52
53SSL *state_machine_get_SSL(state_machine_t *machine)
54{
55 return machine->ssl;
56}
57
58int state_machine_set_SSL(state_machine_t *machine, SSL *ssl, int is_server)
59{
60 if(machine->ssl)
61 /* Shouldn't ever be set twice */
62 abort();
63 machine->ssl = ssl;
64 /* Create the BIOs to handle the dirty side of the SSL */
65 if((machine->bio_intossl = BIO_new(BIO_s_mem())) == NULL)
66 abort();
67 if((machine->bio_fromssl = BIO_new(BIO_s_mem())) == NULL)
68 abort();
69 /* Hook up the BIOs on the dirty side of the SSL */
70 SSL_set_bio(machine->ssl, machine->bio_intossl, machine->bio_fromssl);
71 if(is_server)
72 SSL_set_accept_state(machine->ssl);
73 else
74 SSL_set_connect_state(machine->ssl);
75 /* If we're the first one to generate traffic - do it now otherwise we
76 * go into the next select empty-handed and our peer will not send data
77 * but will similarly wait for us. */
78 return state_machine_churn(machine);
79}
80
81/* Performs the data-IO loop and returns zero if the machine should close */
82int state_machine_churn(state_machine_t *machine)
83{
84 unsigned int loop;
85 if(machine->ssl == NULL) {
86 if(buffer_empty(&machine->clean_out))
87 /* Time to close this state-machine altogether */
88 return 0;
89 else
90 /* Still buffered data on the clean side to go out */
91 return 1;
92 }
93 /* Do this loop twice to cover any dependencies about which precise
94 * order of reads and writes is required. */
95 for(loop = 0; loop < 2; loop++) {
96 buffer_to_SSL(&machine->clean_in, machine->ssl);
97 buffer_to_BIO(&machine->dirty_in, machine->bio_intossl);
98 buffer_from_SSL(&machine->clean_out, machine->ssl);
99 buffer_from_BIO(&machine->dirty_out, machine->bio_fromssl);
100 }
101 /* We close on the SSL side if the info callback noticed some problems
102 * or an SSL shutdown was underway and shutdown traffic had all been
103 * sent. */
104 if(SSL_get_app_data(machine->ssl) || (SSL_get_shutdown(machine->ssl) &&
105 buffer_empty(&machine->dirty_out))) {
106 /* Great, we can seal off the dirty side completely */
107 if(!state_machine_close_dirty(machine))
108 return 0;
109 }
110 /* Either the SSL is alive and well, or the closing process still has
111 * outgoing data waiting to be sent */
112 return 1;
113}
114
115/* Called when the clean side of the SSL has lost its connection */
116int state_machine_close_clean(state_machine_t *machine)
117{
118 /* Well, first thing to do is null out the clean-side buffers - they're
119 * no use any more. */
120 buffer_close(&machine->clean_in);
121 buffer_close(&machine->clean_out);
122 /* And start an SSL shutdown */
123 if(machine->ssl)
124 SSL_shutdown(machine->ssl);
125 /* This is an "event", so flush the SSL of any generated traffic */
126 state_machine_churn(machine);
127 if(buffer_empty(&machine->dirty_in) &&
128 buffer_empty(&machine->dirty_out))
129 return 0;
130 return 1;
131}
132
133/* Called when the dirty side of the SSL has lost its connection. This is pretty
134 * terminal as all that can be left to do is send any buffered output on the
135 * clean side - after that, we're done. */
136int state_machine_close_dirty(state_machine_t *machine)
137{
138 buffer_close(&machine->dirty_in);
139 buffer_close(&machine->dirty_out);
140 buffer_close(&machine->clean_in);
141 if(machine->ssl)
142 SSL_free(machine->ssl);
143 machine->ssl = NULL;
144 machine->bio_intossl = machine->bio_fromssl = NULL;
145 if(buffer_empty(&machine->clean_out))
146 return 0;
147 return 1;
148}
149
150#endif /* !defined(NO_TUNALA) */
151
diff --git a/src/lib/libssl/src/demos/tunala/tunala.c b/src/lib/libssl/src/demos/tunala/tunala.c
new file mode 100644
index 0000000000..e802a6209f
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/tunala.c
@@ -0,0 +1,1093 @@
1#if defined(NO_BUFFER) || defined(NO_IP) || defined(NO_OPENSSL)
2#error "Badness, NO_BUFFER, NO_IP or NO_OPENSSL is defined, turn them *off*"
3#endif
4
5/* Include our bits'n'pieces */
6#include "tunala.h"
7
8
9/********************************************/
10/* Our local types that specify our "world" */
11/********************************************/
12
13/* These represent running "tunnels". Eg. if you wanted to do SSL in a
14 * "message-passing" scanario, the "int" file-descriptors might be replaced by
15 * thread or process IDs, and the "select" code might be replaced by message
16 * handling code. Whatever. */
17typedef struct _tunala_item_t {
18 /* The underlying SSL state machine. This is a data-only processing unit
19 * and we communicate with it by talking to its four "buffers". */
20 state_machine_t sm;
21 /* The file-descriptors for the "dirty" (encrypted) side of the SSL
22 * setup. In actuality, this is typically a socket and both values are
23 * identical. */
24 int dirty_read, dirty_send;
25 /* The file-descriptors for the "clean" (unencrypted) side of the SSL
26 * setup. These could be stdin/stdout, a socket (both values the same),
27 * or whatever you like. */
28 int clean_read, clean_send;
29} tunala_item_t;
30
31/* This structure is used as the data for running the main loop. Namely, in a
32 * network format such as this, it is stuff for select() - but as pointed out,
33 * when moving the real-world to somewhere else, this might be replaced by
34 * something entirely different. It's basically the stuff that controls when
35 * it's time to do some "work". */
36typedef struct _select_sets_t {
37 int max; /* As required as the first argument to select() */
38 fd_set reads, sends, excepts; /* As passed to select() */
39} select_sets_t;
40typedef struct _tunala_selector_t {
41 select_sets_t last_selected; /* Results of the last select() */
42 select_sets_t next_select; /* What we'll next select on */
43} tunala_selector_t;
44
45/* This structure is *everything*. We do it to avoid the use of globals so that,
46 * for example, it would be easier to shift things around between async-IO,
47 * thread-based, or multi-fork()ed (or combinations thereof). */
48typedef struct _tunala_world_t {
49 /* The file-descriptor we "listen" on for new connections */
50 int listen_fd;
51 /* The array of tunnels */
52 tunala_item_t *tunnels;
53 /* the number of tunnels in use and allocated, respectively */
54 unsigned int tunnels_used, tunnels_size;
55 /* Our outside "loop" context stuff */
56 tunala_selector_t selector;
57 /* Our SSL_CTX, which is configured as the SSL client or server and has
58 * the various cert-settings and callbacks configured. */
59 SSL_CTX *ssl_ctx;
60 /* Simple flag with complex logic :-) Indicates whether we're an SSL
61 * server or an SSL client. */
62 int server_mode;
63} tunala_world_t;
64
65/*****************************/
66/* Internal static functions */
67/*****************************/
68
69static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id,
70 const char *CAfile, const char *cert, const char *key,
71 const char *dcert, const char *dkey, const char *cipher_list,
72 const char *dh_file, const char *dh_special, int ctx_options,
73 int out_state, int out_verify, int verify_mode,
74 unsigned int verify_depth);
75static void selector_init(tunala_selector_t *selector);
76static void selector_add_listener(tunala_selector_t *selector, int fd);
77static void selector_add_tunala(tunala_selector_t *selector, tunala_item_t *t);
78static int selector_select(tunala_selector_t *selector);
79/* This returns -1 for error, 0 for no new connections, or 1 for success, in
80 * which case *newfd is populated. */
81static int selector_get_listener(tunala_selector_t *selector, int fd, int *newfd);
82static int tunala_world_new_item(tunala_world_t *world, int fd,
83 const char *ip, unsigned short port, int flipped);
84static void tunala_world_del_item(tunala_world_t *world, unsigned int idx);
85static int tunala_item_io(tunala_selector_t *selector, tunala_item_t *item);
86
87/*********************************************/
88/* MAIN FUNCTION (and its utility functions) */
89/*********************************************/
90
91static const char *def_proxyhost = "127.0.0.1:443";
92static const char *def_listenhost = "127.0.0.1:8080";
93static int def_max_tunnels = 50;
94static const char *def_cacert = NULL;
95static const char *def_cert = NULL;
96static const char *def_key = NULL;
97static const char *def_dcert = NULL;
98static const char *def_dkey = NULL;
99static const char *def_engine_id = NULL;
100static int def_server_mode = 0;
101static int def_flipped = 0;
102static const char *def_cipher_list = NULL;
103static const char *def_dh_file = NULL;
104static const char *def_dh_special = NULL;
105static int def_ctx_options = 0;
106static int def_verify_mode = 0;
107static unsigned int def_verify_depth = 10;
108static int def_out_state = 0;
109static unsigned int def_out_verify = 0;
110static int def_out_totals = 0;
111static int def_out_conns = 0;
112
113static const char *helpstring =
114"\n'Tunala' (A tunneler with a New Zealand accent)\n"
115"Usage: tunala [options], where options are from;\n"
116" -listen [host:]<port> (default = 127.0.0.1:8080)\n"
117" -proxy <host>:<port> (default = 127.0.0.1:443)\n"
118" -maxtunnels <num> (default = 50)\n"
119" -cacert <path|NULL> (default = NULL)\n"
120" -cert <path|NULL> (default = NULL)\n"
121" -key <path|NULL> (default = whatever '-cert' is)\n"
122" -dcert <path|NULL> (usually for DSA, default = NULL)\n"
123" -dkey <path|NULL> (usually for DSA, default = whatever '-dcert' is)\n"
124" -engine <id|NULL> (default = NULL)\n"
125" -server <0|1> (default = 0, ie. an SSL client)\n"
126" -flipped <0|1> (makes SSL servers be network clients, and vice versa)\n"
127" -cipher <list> (specifies cipher list to use)\n"
128" -dh_file <path> (a PEM file containing DH parameters to use)\n"
129" -dh_special <NULL|generate|standard> (see below: def=NULL)\n"
130" -no_ssl2 (disable SSLv2)\n"
131" -no_ssl3 (disable SSLv3)\n"
132" -no_tls1 (disable TLSv1)\n"
133" -v_peer (verify the peer certificate)\n"
134" -v_strict (do not continue if peer doesn't authenticate)\n"
135" -v_once (no verification in renegotiates)\n"
136" -v_depth <num> (limit certificate chain depth, default = 10)\n"
137" -out_conns (prints client connections and disconnections)\n"
138" -out_state (prints SSL handshake states)\n"
139" -out_verify <0|1|2|3> (prints certificate verification states: def=1)\n"
140" -out_totals (prints out byte-totals when a tunnel closes)\n"
141" -<h|help|?> (displays this help screen)\n"
142"Notes:\n"
143"(1) It is recommended to specify a cert+key when operating as an SSL server.\n"
144" If you only specify '-cert', the same file must contain a matching\n"
145" private key.\n"
146"(2) Either dh_file or dh_special can be used to specify where DH parameters\n"
147" will be obtained from (or '-dh_special NULL' for the default choice) but\n"
148" you cannot specify both. For dh_special, 'generate' will create new DH\n"
149" parameters on startup, and 'standard' will use embedded parameters\n"
150" instead.\n"
151"(3) Normally an ssl client connects to an ssl server - so that an 'ssl client\n"
152" tunala' listens for 'clean' client connections and proxies ssl, and an\n"
153" 'ssl server tunala' listens for ssl connections and proxies 'clean'. With\n"
154" '-flipped 1', this behaviour is reversed so that an 'ssl server tunala'\n"
155" listens for clean client connections and proxies ssl (but participating\n"
156" as an ssl *server* in the SSL/TLS protocol), and an 'ssl client tunala'\n"
157" listens for ssl connections (participating as an ssl *client* in the\n"
158" SSL/TLS protocol) and proxies 'clean' to the end destination. This can\n"
159" be useful for allowing network access to 'servers' where only the server\n"
160" needs to authenticate the client (ie. the other way is not required).\n"
161" Even with client and server authentication, this 'technique' mitigates\n"
162" some DoS (denial-of-service) potential as it will be the network client\n"
163" having to perform the first private key operation rather than the other\n"
164" way round.\n"
165"(4) The 'technique' used by setting '-flipped 1' is probably compatible with\n"
166" absolutely nothing except another complimentary instance of 'tunala'\n"
167" running with '-flipped 1'. :-)\n";
168
169/* Default DH parameters for use with "-dh_special standard" ... stolen striaght
170 * from s_server. */
171static unsigned char dh512_p[]={
172 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
173 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
174 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,
175 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
176 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,
177 0x47,0x74,0xE8,0x33,
178 };
179static unsigned char dh512_g[]={
180 0x02,
181 };
182
183/* And the function that parses the above "standard" parameters, again, straight
184 * out of s_server. */
185static DH *get_dh512(void)
186 {
187 DH *dh=NULL;
188
189 if ((dh=DH_new()) == NULL) return(NULL);
190 dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
191 dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
192 if ((dh->p == NULL) || (dh->g == NULL))
193 return(NULL);
194 return(dh);
195 }
196
197/* Various help/error messages used by main() */
198static int usage(const char *errstr, int isunknownarg)
199{
200 if(isunknownarg)
201 fprintf(stderr, "Error: unknown argument '%s'\n", errstr);
202 else
203 fprintf(stderr, "Error: %s\n", errstr);
204 fprintf(stderr, "%s\n", helpstring);
205 return 1;
206}
207
208static int err_str0(const char *str0)
209{
210 fprintf(stderr, "%s\n", str0);
211 return 1;
212}
213
214static int err_str1(const char *fmt, const char *str1)
215{
216 fprintf(stderr, fmt, str1);
217 fprintf(stderr, "\n");
218 return 1;
219}
220
221static int parse_max_tunnels(const char *s, unsigned int *maxtunnels)
222{
223 unsigned long l;
224 if(!int_strtoul(s, &l) || (l < 1) || (l > 1024)) {
225 fprintf(stderr, "Error, '%s' is an invalid value for "
226 "maxtunnels\n", s);
227 return 0;
228 }
229 *maxtunnels = (unsigned int)l;
230 return 1;
231}
232
233static int parse_server_mode(const char *s, int *servermode)
234{
235 unsigned long l;
236 if(!int_strtoul(s, &l) || (l > 1)) {
237 fprintf(stderr, "Error, '%s' is an invalid value for the "
238 "server mode\n", s);
239 return 0;
240 }
241 *servermode = (int)l;
242 return 1;
243}
244
245static int parse_dh_special(const char *s, const char **dh_special)
246{
247 if((strcmp(s, "NULL") == 0) || (strcmp(s, "generate") == 0) ||
248 (strcmp(s, "standard") == 0)) {
249 *dh_special = s;
250 return 1;
251 }
252 fprintf(stderr, "Error, '%s' is an invalid value for 'dh_special'\n", s);
253 return 0;
254}
255
256static int parse_verify_level(const char *s, unsigned int *verify_level)
257{
258 unsigned long l;
259 if(!int_strtoul(s, &l) || (l > 3)) {
260 fprintf(stderr, "Error, '%s' is an invalid value for "
261 "out_verify\n", s);
262 return 0;
263 }
264 *verify_level = (unsigned int)l;
265 return 1;
266}
267
268static int parse_verify_depth(const char *s, unsigned int *verify_depth)
269{
270 unsigned long l;
271 if(!int_strtoul(s, &l) || (l < 1) || (l > 50)) {
272 fprintf(stderr, "Error, '%s' is an invalid value for "
273 "verify_depth\n", s);
274 return 0;
275 }
276 *verify_depth = (unsigned int)l;
277 return 1;
278}
279
280/* Some fprintf format strings used when tunnels close */
281static const char *io_stats_dirty =
282" SSL traffic; %8lu bytes in, %8lu bytes out\n";
283static const char *io_stats_clean =
284" clear traffic; %8lu bytes in, %8lu bytes out\n";
285
286int main(int argc, char *argv[])
287{
288 unsigned int loop;
289 int newfd;
290 tunala_world_t world;
291 tunala_item_t *t_item;
292 const char *proxy_ip;
293 unsigned short proxy_port;
294 /* Overridables */
295 const char *proxyhost = def_proxyhost;
296 const char *listenhost = def_listenhost;
297 unsigned int max_tunnels = def_max_tunnels;
298 const char *cacert = def_cacert;
299 const char *cert = def_cert;
300 const char *key = def_key;
301 const char *dcert = def_dcert;
302 const char *dkey = def_dkey;
303 const char *engine_id = def_engine_id;
304 int server_mode = def_server_mode;
305 int flipped = def_flipped;
306 const char *cipher_list = def_cipher_list;
307 const char *dh_file = def_dh_file;
308 const char *dh_special = def_dh_special;
309 int ctx_options = def_ctx_options;
310 int verify_mode = def_verify_mode;
311 unsigned int verify_depth = def_verify_depth;
312 int out_state = def_out_state;
313 unsigned int out_verify = def_out_verify;
314 int out_totals = def_out_totals;
315 int out_conns = def_out_conns;
316
317/* Parse command-line arguments */
318next_arg:
319 argc--; argv++;
320 if(argc > 0) {
321 if(strcmp(*argv, "-listen") == 0) {
322 if(argc < 2)
323 return usage("-listen requires an argument", 0);
324 argc--; argv++;
325 listenhost = *argv;
326 goto next_arg;
327 } else if(strcmp(*argv, "-proxy") == 0) {
328 if(argc < 2)
329 return usage("-proxy requires an argument", 0);
330 argc--; argv++;
331 proxyhost = *argv;
332 goto next_arg;
333 } else if(strcmp(*argv, "-maxtunnels") == 0) {
334 if(argc < 2)
335 return usage("-maxtunnels requires an argument", 0);
336 argc--; argv++;
337 if(!parse_max_tunnels(*argv, &max_tunnels))
338 return 1;
339 goto next_arg;
340 } else if(strcmp(*argv, "-cacert") == 0) {
341 if(argc < 2)
342 return usage("-cacert requires an argument", 0);
343 argc--; argv++;
344 if(strcmp(*argv, "NULL") == 0)
345 cacert = NULL;
346 else
347 cacert = *argv;
348 goto next_arg;
349 } else if(strcmp(*argv, "-cert") == 0) {
350 if(argc < 2)
351 return usage("-cert requires an argument", 0);
352 argc--; argv++;
353 if(strcmp(*argv, "NULL") == 0)
354 cert = NULL;
355 else
356 cert = *argv;
357 goto next_arg;
358 } else if(strcmp(*argv, "-key") == 0) {
359 if(argc < 2)
360 return usage("-key requires an argument", 0);
361 argc--; argv++;
362 if(strcmp(*argv, "NULL") == 0)
363 key = NULL;
364 else
365 key = *argv;
366 goto next_arg;
367 } else if(strcmp(*argv, "-dcert") == 0) {
368 if(argc < 2)
369 return usage("-dcert requires an argument", 0);
370 argc--; argv++;
371 if(strcmp(*argv, "NULL") == 0)
372 dcert = NULL;
373 else
374 dcert = *argv;
375 goto next_arg;
376 } else if(strcmp(*argv, "-dkey") == 0) {
377 if(argc < 2)
378 return usage("-dkey requires an argument", 0);
379 argc--; argv++;
380 if(strcmp(*argv, "NULL") == 0)
381 dkey = NULL;
382 else
383 dkey = *argv;
384 goto next_arg;
385 } else if(strcmp(*argv, "-engine") == 0) {
386 if(argc < 2)
387 return usage("-engine requires an argument", 0);
388 argc--; argv++;
389 engine_id = *argv;
390 goto next_arg;
391 } else if(strcmp(*argv, "-server") == 0) {
392 if(argc < 2)
393 return usage("-server requires an argument", 0);
394 argc--; argv++;
395 if(!parse_server_mode(*argv, &server_mode))
396 return 1;
397 goto next_arg;
398 } else if(strcmp(*argv, "-flipped") == 0) {
399 if(argc < 2)
400 return usage("-flipped requires an argument", 0);
401 argc--; argv++;
402 if(!parse_server_mode(*argv, &flipped))
403 return 1;
404 goto next_arg;
405 } else if(strcmp(*argv, "-cipher") == 0) {
406 if(argc < 2)
407 return usage("-cipher requires an argument", 0);
408 argc--; argv++;
409 cipher_list = *argv;
410 goto next_arg;
411 } else if(strcmp(*argv, "-dh_file") == 0) {
412 if(argc < 2)
413 return usage("-dh_file requires an argument", 0);
414 if(dh_special)
415 return usage("cannot mix -dh_file with "
416 "-dh_special", 0);
417 argc--; argv++;
418 dh_file = *argv;
419 goto next_arg;
420 } else if(strcmp(*argv, "-dh_special") == 0) {
421 if(argc < 2)
422 return usage("-dh_special requires an argument", 0);
423 if(dh_file)
424 return usage("cannot mix -dh_file with "
425 "-dh_special", 0);
426 argc--; argv++;
427 if(!parse_dh_special(*argv, &dh_special))
428 return 1;
429 goto next_arg;
430 } else if(strcmp(*argv, "-no_ssl2") == 0) {
431 ctx_options |= SSL_OP_NO_SSLv2;
432 goto next_arg;
433 } else if(strcmp(*argv, "-no_ssl3") == 0) {
434 ctx_options |= SSL_OP_NO_SSLv3;
435 goto next_arg;
436 } else if(strcmp(*argv, "-no_tls1") == 0) {
437 ctx_options |= SSL_OP_NO_TLSv1;
438 goto next_arg;
439 } else if(strcmp(*argv, "-v_peer") == 0) {
440 verify_mode |= SSL_VERIFY_PEER;
441 goto next_arg;
442 } else if(strcmp(*argv, "-v_strict") == 0) {
443 verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
444 goto next_arg;
445 } else if(strcmp(*argv, "-v_once") == 0) {
446 verify_mode |= SSL_VERIFY_CLIENT_ONCE;
447 goto next_arg;
448 } else if(strcmp(*argv, "-v_depth") == 0) {
449 if(argc < 2)
450 return usage("-v_depth requires an argument", 0);
451 argc--; argv++;
452 if(!parse_verify_depth(*argv, &verify_depth))
453 return 1;
454 goto next_arg;
455 } else if(strcmp(*argv, "-out_state") == 0) {
456 out_state = 1;
457 goto next_arg;
458 } else if(strcmp(*argv, "-out_verify") == 0) {
459 if(argc < 2)
460 return usage("-out_verify requires an argument", 0);
461 argc--; argv++;
462 if(!parse_verify_level(*argv, &out_verify))
463 return 1;
464 goto next_arg;
465 } else if(strcmp(*argv, "-out_totals") == 0) {
466 out_totals = 1;
467 goto next_arg;
468 } else if(strcmp(*argv, "-out_conns") == 0) {
469 out_conns = 1;
470 goto next_arg;
471 } else if((strcmp(*argv, "-h") == 0) ||
472 (strcmp(*argv, "-help") == 0) ||
473 (strcmp(*argv, "-?") == 0)) {
474 fprintf(stderr, "%s\n", helpstring);
475 return 0;
476 } else
477 return usage(*argv, 1);
478 }
479 /* Run any sanity checks we want here */
480 if(!cert && !dcert && server_mode)
481 fprintf(stderr, "WARNING: you are running an SSL server without "
482 "a certificate - this may not work!\n");
483
484 /* Initialise network stuff */
485 if(!ip_initialise())
486 return err_str0("ip_initialise failed");
487 /* Create the SSL_CTX */
488 if((world.ssl_ctx = initialise_ssl_ctx(server_mode, engine_id,
489 cacert, cert, key, dcert, dkey, cipher_list, dh_file,
490 dh_special, ctx_options, out_state, out_verify,
491 verify_mode, verify_depth)) == NULL)
492 return err_str1("initialise_ssl_ctx(engine_id=%s) failed",
493 (engine_id == NULL) ? "NULL" : engine_id);
494 if(engine_id)
495 fprintf(stderr, "Info, engine '%s' initialised\n", engine_id);
496 /* Create the listener */
497 if((world.listen_fd = ip_create_listener(listenhost)) == -1)
498 return err_str1("ip_create_listener(%s) failed", listenhost);
499 fprintf(stderr, "Info, listening on '%s'\n", listenhost);
500 if(!ip_parse_address(proxyhost, &proxy_ip, &proxy_port, 0))
501 return err_str1("ip_parse_address(%s) failed", proxyhost);
502 fprintf(stderr, "Info, proxying to '%s' (%d.%d.%d.%d:%d)\n", proxyhost,
503 (int)proxy_ip[0], (int)proxy_ip[1],
504 (int)proxy_ip[2], (int)proxy_ip[3], (int)proxy_port);
505 fprintf(stderr, "Info, set maxtunnels to %d\n", (int)max_tunnels);
506 fprintf(stderr, "Info, set to operate as an SSL %s\n",
507 (server_mode ? "server" : "client"));
508 /* Initialise the rest of the stuff */
509 world.tunnels_used = world.tunnels_size = 0;
510 world.tunnels = NULL;
511 world.server_mode = server_mode;
512 selector_init(&world.selector);
513
514/* We're ready to loop */
515main_loop:
516 /* Should we listen for *new* tunnels? */
517 if(world.tunnels_used < max_tunnels)
518 selector_add_listener(&world.selector, world.listen_fd);
519 /* We should add in our existing tunnels */
520 for(loop = 0; loop < world.tunnels_used; loop++)
521 selector_add_tunala(&world.selector, world.tunnels + loop);
522 /* Now do the select */
523 switch(selector_select(&world.selector)) {
524 case -1:
525 fprintf(stderr, "selector_select returned a badness error.\n");
526 goto shouldnt_happen;
527 case 0:
528 fprintf(stderr, "Warn, selector_select returned 0 - signal?""?\n");
529 goto main_loop;
530 default:
531 break;
532 }
533 /* Accept new connection if we should and can */
534 if((world.tunnels_used < max_tunnels) && (selector_get_listener(
535 &world.selector, world.listen_fd,
536 &newfd) == 1)) {
537 /* We have a new connection */
538 if(!tunala_world_new_item(&world, newfd, proxy_ip,
539 proxy_port, flipped))
540 fprintf(stderr, "tunala_world_new_item failed\n");
541 else if(out_conns)
542 fprintf(stderr, "Info, new tunnel opened, now up to "
543 "%d\n", world.tunnels_used);
544 }
545 /* Give each tunnel its moment, note the while loop is because it makes
546 * the logic easier than with "for" to deal with an array that may shift
547 * because of deletes. */
548 loop = 0;
549 t_item = world.tunnels;
550 while(loop < world.tunnels_used) {
551 if(!tunala_item_io(&world.selector, t_item)) {
552 /* We're closing whether for reasons of an error or a
553 * natural close. Don't increment loop or t_item because
554 * the next item is moving to us! */
555 if(!out_totals)
556 goto skip_totals;
557 fprintf(stderr, "Tunnel closing, traffic stats follow\n");
558 /* Display the encrypted (over the network) stats */
559 fprintf(stderr, io_stats_dirty,
560 buffer_total_in(state_machine_get_buffer(
561 &t_item->sm,SM_DIRTY_IN)),
562 buffer_total_out(state_machine_get_buffer(
563 &t_item->sm,SM_DIRTY_OUT)));
564 /* Display the local (tunnelled) stats. NB: Data we
565 * *receive* is data sent *out* of the state_machine on
566 * its 'clean' side. Hence the apparent back-to-front
567 * OUT/IN mixup here :-) */
568 fprintf(stderr, io_stats_clean,
569 buffer_total_out(state_machine_get_buffer(
570 &t_item->sm,SM_CLEAN_OUT)),
571 buffer_total_in(state_machine_get_buffer(
572 &t_item->sm,SM_CLEAN_IN)));
573skip_totals:
574 tunala_world_del_item(&world, loop);
575 if(out_conns)
576 fprintf(stderr, "Info, tunnel closed, down to %d\n",
577 world.tunnels_used);
578 }
579 else {
580 /* Move to the next item */
581 loop++;
582 t_item++;
583 }
584 }
585 goto main_loop;
586 /* Should never get here */
587shouldnt_happen:
588 abort();
589 return 1;
590}
591
592/****************/
593/* OpenSSL bits */
594/****************/
595
596static int ctx_set_cert(SSL_CTX *ctx, const char *cert, const char *key)
597{
598 FILE *fp = NULL;
599 X509 *x509 = NULL;
600 EVP_PKEY *pkey = NULL;
601 int toret = 0; /* Assume an error */
602
603 /* cert */
604 if(cert) {
605 if((fp = fopen(cert, "r")) == NULL) {
606 fprintf(stderr, "Error opening cert file '%s'\n", cert);
607 goto err;
608 }
609 if(!PEM_read_X509(fp, &x509, NULL, NULL)) {
610 fprintf(stderr, "Error reading PEM cert from '%s'\n",
611 cert);
612 goto err;
613 }
614 if(!SSL_CTX_use_certificate(ctx, x509)) {
615 fprintf(stderr, "Error, cert in '%s' can not be used\n",
616 cert);
617 goto err;
618 }
619 /* Clear the FILE* for reuse in the "key" code */
620 fclose(fp);
621 fp = NULL;
622 fprintf(stderr, "Info, operating with cert in '%s'\n", cert);
623 /* If a cert was given without matching key, we assume the same
624 * file contains the required key. */
625 if(!key)
626 key = cert;
627 } else {
628 if(key)
629 fprintf(stderr, "Error, can't specify a key without a "
630 "corresponding certificate\n");
631 else
632 fprintf(stderr, "Error, ctx_set_cert called with "
633 "NULLs!\n");
634 goto err;
635 }
636 /* key */
637 if(key) {
638 if((fp = fopen(key, "r")) == NULL) {
639 fprintf(stderr, "Error opening key file '%s'\n", key);
640 goto err;
641 }
642 if(!PEM_read_PrivateKey(fp, &pkey, NULL, NULL)) {
643 fprintf(stderr, "Error reading PEM key from '%s'\n",
644 key);
645 goto err;
646 }
647 if(!SSL_CTX_use_PrivateKey(ctx, pkey)) {
648 fprintf(stderr, "Error, key in '%s' can not be used\n",
649 key);
650 goto err;
651 }
652 fprintf(stderr, "Info, operating with key in '%s'\n", key);
653 } else
654 fprintf(stderr, "Info, operating without a cert or key\n");
655 /* Success */
656 toret = 1; err:
657 if(x509)
658 X509_free(x509);
659 if(pkey)
660 EVP_PKEY_free(pkey);
661 if(fp)
662 fclose(fp);
663 return toret;
664}
665
666static int ctx_set_dh(SSL_CTX *ctx, const char *dh_file, const char *dh_special)
667{
668 DH *dh = NULL;
669 FILE *fp = NULL;
670
671 if(dh_special) {
672 if(strcmp(dh_special, "NULL") == 0)
673 return 1;
674 if(strcmp(dh_special, "standard") == 0) {
675 if((dh = get_dh512()) == NULL) {
676 fprintf(stderr, "Error, can't parse 'standard'"
677 " DH parameters\n");
678 return 0;
679 }
680 fprintf(stderr, "Info, using 'standard' DH parameters\n");
681 goto do_it;
682 }
683 if(strcmp(dh_special, "generate") != 0)
684 /* This shouldn't happen - screening values is handled
685 * in main(). */
686 abort();
687 fprintf(stderr, "Info, generating DH parameters ... ");
688 fflush(stderr);
689 if((dh = DH_generate_parameters(512, DH_GENERATOR_5,
690 NULL, NULL)) == NULL) {
691 fprintf(stderr, "error!\n");
692 return 0;
693 }
694 fprintf(stderr, "complete\n");
695 goto do_it;
696 }
697 /* So, we're loading dh_file */
698 if((fp = fopen(dh_file, "r")) == NULL) {
699 fprintf(stderr, "Error, couldn't open '%s' for DH parameters\n",
700 dh_file);
701 return 0;
702 }
703 dh = PEM_read_DHparams(fp, NULL, NULL, NULL);
704 fclose(fp);
705 if(dh == NULL) {
706 fprintf(stderr, "Error, could not parse DH parameters from '%s'\n",
707 dh_file);
708 return 0;
709 }
710 fprintf(stderr, "Info, using DH parameters from file '%s'\n", dh_file);
711do_it:
712 SSL_CTX_set_tmp_dh(ctx, dh);
713 DH_free(dh);
714 return 1;
715}
716
717static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id,
718 const char *CAfile, const char *cert, const char *key,
719 const char *dcert, const char *dkey, const char *cipher_list,
720 const char *dh_file, const char *dh_special, int ctx_options,
721 int out_state, int out_verify, int verify_mode,
722 unsigned int verify_depth)
723{
724 SSL_CTX *ctx = NULL, *ret = NULL;
725 SSL_METHOD *meth;
726 ENGINE *e = NULL;
727
728 OpenSSL_add_ssl_algorithms();
729 SSL_load_error_strings();
730
731 meth = (server_mode ? SSLv23_server_method() : SSLv23_client_method());
732 if(meth == NULL)
733 goto err;
734 if(engine_id) {
735 ENGINE_load_builtin_engines();
736 if((e = ENGINE_by_id(engine_id)) == NULL) {
737 fprintf(stderr, "Error obtaining '%s' engine, openssl "
738 "errors follow\n", engine_id);
739 goto err;
740 }
741 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
742 fprintf(stderr, "Error assigning '%s' engine, openssl "
743 "errors follow\n", engine_id);
744 goto err;
745 }
746 ENGINE_free(e);
747 }
748 if((ctx = SSL_CTX_new(meth)) == NULL)
749 goto err;
750 /* cacert */
751 if(CAfile) {
752 if(!X509_STORE_load_locations(SSL_CTX_get_cert_store(ctx),
753 CAfile, NULL)) {
754 fprintf(stderr, "Error loading CA cert(s) in '%s'\n",
755 CAfile);
756 goto err;
757 }
758 fprintf(stderr, "Info, operating with CA cert(s) in '%s'\n",
759 CAfile);
760 } else
761 fprintf(stderr, "Info, operating without a CA cert(-list)\n");
762 if(!SSL_CTX_set_default_verify_paths(ctx)) {
763 fprintf(stderr, "Error setting default verify paths\n");
764 goto err;
765 }
766
767 /* cert and key */
768 if((cert || key) && !ctx_set_cert(ctx, cert, key))
769 goto err;
770 /* dcert and dkey */
771 if((dcert || dkey) && !ctx_set_cert(ctx, dcert, dkey))
772 goto err;
773
774 /* cipher_list */
775 if(cipher_list) {
776 if(!SSL_CTX_set_cipher_list(ctx, cipher_list)) {
777 fprintf(stderr, "Error setting cipher list '%s'\n",
778 cipher_list);
779 goto err;
780 }
781 fprintf(stderr, "Info, set cipher list '%s'\n", cipher_list);
782 } else
783 fprintf(stderr, "Info, operating with default cipher list\n");
784
785 /* dh_file & dh_special */
786 if((dh_file || dh_special) && !ctx_set_dh(ctx, dh_file, dh_special))
787 goto err;
788
789 /* ctx_options */
790 SSL_CTX_set_options(ctx, ctx_options);
791
792 /* out_state (output of SSL handshake states to screen). */
793 if(out_state)
794 cb_ssl_info_set_output(stderr);
795
796 /* out_verify */
797 if(out_verify > 0) {
798 cb_ssl_verify_set_output(stderr);
799 cb_ssl_verify_set_level(out_verify);
800 }
801
802 /* verify_depth */
803 cb_ssl_verify_set_depth(verify_depth);
804
805 /* Success! (includes setting verify_mode) */
806 SSL_CTX_set_info_callback(ctx, cb_ssl_info);
807 SSL_CTX_set_verify(ctx, verify_mode, cb_ssl_verify);
808 ret = ctx;
809err:
810 if(!ret) {
811 ERR_print_errors_fp(stderr);
812 if(ctx)
813 SSL_CTX_free(ctx);
814 }
815 return ret;
816}
817
818/*****************/
819/* Selector bits */
820/*****************/
821
822static void selector_sets_init(select_sets_t *s)
823{
824 s->max = 0;
825 FD_ZERO(&s->reads);
826 FD_ZERO(&s->sends);
827 FD_ZERO(&s->excepts);
828}
829static void selector_init(tunala_selector_t *selector)
830{
831 selector_sets_init(&selector->last_selected);
832 selector_sets_init(&selector->next_select);
833}
834
835#define SEL_EXCEPTS 0x00
836#define SEL_READS 0x01
837#define SEL_SENDS 0x02
838static void selector_add_raw_fd(tunala_selector_t *s, int fd, int flags)
839{
840 FD_SET(fd, &s->next_select.excepts);
841 if(flags & SEL_READS)
842 FD_SET(fd, &s->next_select.reads);
843 if(flags & SEL_SENDS)
844 FD_SET(fd, &s->next_select.sends);
845 /* Adjust "max" */
846 if(s->next_select.max < (fd + 1))
847 s->next_select.max = fd + 1;
848}
849
850static void selector_add_listener(tunala_selector_t *selector, int fd)
851{
852 selector_add_raw_fd(selector, fd, SEL_READS);
853}
854
855static void selector_add_tunala(tunala_selector_t *s, tunala_item_t *t)
856{
857 /* Set clean read if sm.clean_in is not full */
858 if(t->clean_read != -1) {
859 selector_add_raw_fd(s, t->clean_read,
860 (buffer_full(state_machine_get_buffer(&t->sm,
861 SM_CLEAN_IN)) ? SEL_EXCEPTS : SEL_READS));
862 }
863 /* Set clean send if sm.clean_out is not empty */
864 if(t->clean_send != -1) {
865 selector_add_raw_fd(s, t->clean_send,
866 (buffer_empty(state_machine_get_buffer(&t->sm,
867 SM_CLEAN_OUT)) ? SEL_EXCEPTS : SEL_SENDS));
868 }
869 /* Set dirty read if sm.dirty_in is not full */
870 if(t->dirty_read != -1) {
871 selector_add_raw_fd(s, t->dirty_read,
872 (buffer_full(state_machine_get_buffer(&t->sm,
873 SM_DIRTY_IN)) ? SEL_EXCEPTS : SEL_READS));
874 }
875 /* Set dirty send if sm.dirty_out is not empty */
876 if(t->dirty_send != -1) {
877 selector_add_raw_fd(s, t->dirty_send,
878 (buffer_empty(state_machine_get_buffer(&t->sm,
879 SM_DIRTY_OUT)) ? SEL_EXCEPTS : SEL_SENDS));
880 }
881}
882
883static int selector_select(tunala_selector_t *selector)
884{
885 memcpy(&selector->last_selected, &selector->next_select,
886 sizeof(select_sets_t));
887 selector_sets_init(&selector->next_select);
888 return select(selector->last_selected.max,
889 &selector->last_selected.reads,
890 &selector->last_selected.sends,
891 &selector->last_selected.excepts, NULL);
892}
893
894/* This returns -1 for error, 0 for no new connections, or 1 for success, in
895 * which case *newfd is populated. */
896static int selector_get_listener(tunala_selector_t *selector, int fd, int *newfd)
897{
898 if(FD_ISSET(fd, &selector->last_selected.excepts))
899 return -1;
900 if(!FD_ISSET(fd, &selector->last_selected.reads))
901 return 0;
902 if((*newfd = ip_accept_connection(fd)) == -1)
903 return -1;
904 return 1;
905}
906
907/************************/
908/* "Tunala" world stuff */
909/************************/
910
911static int tunala_world_make_room(tunala_world_t *world)
912{
913 unsigned int newsize;
914 tunala_item_t *newarray;
915
916 if(world->tunnels_used < world->tunnels_size)
917 return 1;
918 newsize = (world->tunnels_size == 0 ? 16 :
919 ((world->tunnels_size * 3) / 2));
920 if((newarray = malloc(newsize * sizeof(tunala_item_t))) == NULL)
921 return 0;
922 memset(newarray, 0, newsize * sizeof(tunala_item_t));
923 if(world->tunnels_used > 0)
924 memcpy(newarray, world->tunnels,
925 world->tunnels_used * sizeof(tunala_item_t));
926 if(world->tunnels_size > 0)
927 free(world->tunnels);
928 /* migrate */
929 world->tunnels = newarray;
930 world->tunnels_size = newsize;
931 return 1;
932}
933
934static int tunala_world_new_item(tunala_world_t *world, int fd,
935 const char *ip, unsigned short port, int flipped)
936{
937 tunala_item_t *item;
938 int newfd;
939 SSL *new_ssl = NULL;
940
941 if(!tunala_world_make_room(world))
942 return 0;
943 if((new_ssl = SSL_new(world->ssl_ctx)) == NULL) {
944 fprintf(stderr, "Error creating new SSL\n");
945 ERR_print_errors_fp(stderr);
946 return 0;
947 }
948 item = world->tunnels + (world->tunnels_used++);
949 state_machine_init(&item->sm);
950 item->clean_read = item->clean_send =
951 item->dirty_read = item->dirty_send = -1;
952 if((newfd = ip_create_connection_split(ip, port)) == -1)
953 goto err;
954 /* Which way round? If we're a server, "fd" is the dirty side and the
955 * connection we open is the clean one. For a client, it's the other way
956 * around. Unless, of course, we're "flipped" in which case everything
957 * gets reversed. :-) */
958 if((world->server_mode && !flipped) ||
959 (!world->server_mode && flipped)) {
960 item->dirty_read = item->dirty_send = fd;
961 item->clean_read = item->clean_send = newfd;
962 } else {
963 item->clean_read = item->clean_send = fd;
964 item->dirty_read = item->dirty_send = newfd;
965 }
966 /* We use the SSL's "app_data" to indicate a call-back induced "kill" */
967 SSL_set_app_data(new_ssl, NULL);
968 if(!state_machine_set_SSL(&item->sm, new_ssl, world->server_mode))
969 goto err;
970 return 1;
971err:
972 tunala_world_del_item(world, world->tunnels_used - 1);
973 return 0;
974
975}
976
977static void tunala_world_del_item(tunala_world_t *world, unsigned int idx)
978{
979 tunala_item_t *item = world->tunnels + idx;
980 if(item->clean_read != -1)
981 close(item->clean_read);
982 if(item->clean_send != item->clean_read)
983 close(item->clean_send);
984 item->clean_read = item->clean_send = -1;
985 if(item->dirty_read != -1)
986 close(item->dirty_read);
987 if(item->dirty_send != item->dirty_read)
988 close(item->dirty_send);
989 item->dirty_read = item->dirty_send = -1;
990 state_machine_close(&item->sm);
991 /* OK, now we fix the item array */
992 if(idx + 1 < world->tunnels_used)
993 /* We need to scroll entries to the left */
994 memmove(world->tunnels + idx,
995 world->tunnels + (idx + 1),
996 (world->tunnels_used - (idx + 1)) *
997 sizeof(tunala_item_t));
998 world->tunnels_used--;
999}
1000
1001static int tunala_item_io(tunala_selector_t *selector, tunala_item_t *item)
1002{
1003 int c_r, c_s, d_r, d_s; /* Four boolean flags */
1004
1005 /* Take ourselves out of the gene-pool if there was an except */
1006 if((item->clean_read != -1) && FD_ISSET(item->clean_read,
1007 &selector->last_selected.excepts))
1008 return 0;
1009 if((item->clean_send != -1) && FD_ISSET(item->clean_send,
1010 &selector->last_selected.excepts))
1011 return 0;
1012 if((item->dirty_read != -1) && FD_ISSET(item->dirty_read,
1013 &selector->last_selected.excepts))
1014 return 0;
1015 if((item->dirty_send != -1) && FD_ISSET(item->dirty_send,
1016 &selector->last_selected.excepts))
1017 return 0;
1018 /* Grab our 4 IO flags */
1019 c_r = c_s = d_r = d_s = 0;
1020 if(item->clean_read != -1)
1021 c_r = FD_ISSET(item->clean_read, &selector->last_selected.reads);
1022 if(item->clean_send != -1)
1023 c_s = FD_ISSET(item->clean_send, &selector->last_selected.sends);
1024 if(item->dirty_read != -1)
1025 d_r = FD_ISSET(item->dirty_read, &selector->last_selected.reads);
1026 if(item->dirty_send != -1)
1027 d_s = FD_ISSET(item->dirty_send, &selector->last_selected.sends);
1028 /* If no IO has happened for us, skip needless data looping */
1029 if(!c_r && !c_s && !d_r && !d_s)
1030 return 1;
1031 if(c_r)
1032 c_r = (buffer_from_fd(state_machine_get_buffer(&item->sm,
1033 SM_CLEAN_IN), item->clean_read) <= 0);
1034 if(c_s)
1035 c_s = (buffer_to_fd(state_machine_get_buffer(&item->sm,
1036 SM_CLEAN_OUT), item->clean_send) <= 0);
1037 if(d_r)
1038 d_r = (buffer_from_fd(state_machine_get_buffer(&item->sm,
1039 SM_DIRTY_IN), item->dirty_read) <= 0);
1040 if(d_s)
1041 d_s = (buffer_to_fd(state_machine_get_buffer(&item->sm,
1042 SM_DIRTY_OUT), item->dirty_send) <= 0);
1043 /* If any of the flags is non-zero, that means they need closing */
1044 if(c_r) {
1045 close(item->clean_read);
1046 if(item->clean_send == item->clean_read)
1047 item->clean_send = -1;
1048 item->clean_read = -1;
1049 }
1050 if(c_s && (item->clean_send != -1)) {
1051 close(item->clean_send);
1052 if(item->clean_send == item->clean_read)
1053 item->clean_read = -1;
1054 item->clean_send = -1;
1055 }
1056 if(d_r) {
1057 close(item->dirty_read);
1058 if(item->dirty_send == item->dirty_read)
1059 item->dirty_send = -1;
1060 item->dirty_read = -1;
1061 }
1062 if(d_s && (item->dirty_send != -1)) {
1063 close(item->dirty_send);
1064 if(item->dirty_send == item->dirty_read)
1065 item->dirty_read = -1;
1066 item->dirty_send = -1;
1067 }
1068 /* This function name is attributed to the term donated by David
1069 * Schwartz on openssl-dev, message-ID:
1070 * <NCBBLIEPOCNJOAEKBEAKEEDGLIAA.davids@webmaster.com>. :-) */
1071 if(!state_machine_churn(&item->sm))
1072 /* If the SSL closes, it will also zero-out the _in buffers
1073 * and will in future process just outgoing data. As and
1074 * when the outgoing data has gone, it will return zero
1075 * here to tell us to bail out. */
1076 return 0;
1077 /* Otherwise, we return zero if both sides are dead. */
1078 if(((item->clean_read == -1) || (item->clean_send == -1)) &&
1079 ((item->dirty_read == -1) || (item->dirty_send == -1)))
1080 return 0;
1081 /* If only one side closed, notify the SSL of this so it can take
1082 * appropriate action. */
1083 if((item->clean_read == -1) || (item->clean_send == -1)) {
1084 if(!state_machine_close_clean(&item->sm))
1085 return 0;
1086 }
1087 if((item->dirty_read == -1) || (item->dirty_send == -1)) {
1088 if(!state_machine_close_dirty(&item->sm))
1089 return 0;
1090 }
1091 return 1;
1092}
1093
diff --git a/src/lib/libssl/src/demos/tunala/tunala.h b/src/lib/libssl/src/demos/tunala/tunala.h
new file mode 100644
index 0000000000..b4c8ec78d8
--- /dev/null
+++ b/src/lib/libssl/src/demos/tunala/tunala.h
@@ -0,0 +1,214 @@
1/* Tunala ("Tunneler with a New Zealand accent")
2 *
3 * Written by Geoff Thorpe, but endorsed/supported by noone. Please use this is
4 * if it's useful or informative to you, but it's only here as a scratchpad for
5 * ideas about how you might (or might not) program with OpenSSL. If you deploy
6 * this is in a mission-critical environment, and have not read, understood,
7 * audited, and modified this code to your satisfaction, and the result is that
8 * all hell breaks loose and you are looking for a new employer, then it proves
9 * nothing except perhaps that Darwinism is alive and well. Let's just say, *I*
10 * don't use this in a mission-critical environment, so it would be stupid for
11 * anyone to assume that it is solid and/or tested enough when even its author
12 * doesn't place that much trust in it. You have been warned.
13 *
14 * With thanks to Cryptographic Appliances, Inc.
15 */
16
17#ifndef _TUNALA_H
18#define _TUNALA_H
19
20/* pull in autoconf fluff */
21#ifndef NO_CONFIG_H
22#include "config.h"
23#else
24/* We don't have autoconf, we have to set all of these unless a tweaked Makefile
25 * tells us not to ... */
26/* headers */
27#ifndef NO_HAVE_SELECT
28#define HAVE_SELECT
29#endif
30#ifndef NO_HAVE_SOCKET
31#define HAVE_SOCKET
32#endif
33#ifndef NO_HAVE_UNISTD_H
34#define HAVE_UNISTD_H
35#endif
36#ifndef NO_HAVE_FCNTL_H
37#define HAVE_FCNTL_H
38#endif
39#ifndef NO_HAVE_LIMITS_H
40#define HAVE_LIMITS_H
41#endif
42/* features */
43#ifndef NO_HAVE_STRSTR
44#define HAVE_STRSTR
45#endif
46#ifndef NO_HAVE_STRTOUL
47#define HAVE_STRTOUL
48#endif
49#endif
50
51#if !defined(HAVE_SELECT) || !defined(HAVE_SOCKET)
52#error "can't build without some network basics like select() and socket()"
53#endif
54
55#include <stdlib.h>
56#ifndef NO_SYSTEM_H
57#include <string.h>
58#ifdef HAVE_UNISTD_H
59#include <unistd.h>
60#endif
61#ifdef HAVE_FCNTL_H
62#include <fcntl.h>
63#endif
64#ifdef HAVE_LIMITS_H
65#include <limits.h>
66#endif
67#include <netdb.h>
68#include <signal.h>
69#include <sys/socket.h>
70#include <sys/types.h>
71#include <netinet/in.h>
72#endif /* !defined(NO_SYSTEM_H) */
73
74#ifndef NO_OPENSSL
75#include <openssl/err.h>
76#include <openssl/engine.h>
77#include <openssl/ssl.h>
78#endif /* !defined(NO_OPENSSL) */
79
80#ifndef OPENSSL_NO_BUFFER
81/* This is the generic "buffer" type that is used when feeding the
82 * state-machine. It's basically a FIFO with respect to the "adddata" &
83 * "takedata" type functions that operate on it. */
84#define MAX_DATA_SIZE 16384
85typedef struct _buffer_t {
86 unsigned char data[MAX_DATA_SIZE];
87 unsigned int used;
88 /* Statistical values - counts the total number of bytes read in and
89 * read out (respectively) since "buffer_init()" */
90 unsigned long total_in, total_out;
91} buffer_t;
92
93/* Initialise a buffer structure before use */
94void buffer_init(buffer_t *buf);
95/* Cleanup a buffer structure - presently not needed, but if buffer_t is
96 * converted to using dynamic allocation, this would be required - so should be
97 * called to protect against an explosion of memory leaks later if the change is
98 * made. */
99void buffer_close(buffer_t *buf);
100
101/* Basic functions to manipulate buffers */
102
103unsigned int buffer_used(buffer_t *buf); /* How much data in the buffer */
104unsigned int buffer_unused(buffer_t *buf); /* How much space in the buffer */
105int buffer_full(buffer_t *buf); /* Boolean, is it full? */
106int buffer_notfull(buffer_t *buf); /* Boolean, is it not full? */
107int buffer_empty(buffer_t *buf); /* Boolean, is it empty? */
108int buffer_notempty(buffer_t *buf); /* Boolean, is it not empty? */
109unsigned long buffer_total_in(buffer_t *buf); /* Total bytes written to buffer */
110unsigned long buffer_total_out(buffer_t *buf); /* Total bytes read from buffer */
111
112#if 0 /* Currently used only within buffer.c - better to expose only
113 * higher-level functions anyway */
114/* Add data to the tail of the buffer, returns the amount that was actually
115 * added (so, you need to check if return value is less than size) */
116unsigned int buffer_adddata(buffer_t *buf, const unsigned char *ptr,
117 unsigned int size);
118
119/* Take data from the front of the buffer (and scroll the rest forward). If
120 * "ptr" is NULL, this just removes data off the front of the buffer. Return
121 * value is the amount actually removed (can be less than size if the buffer has
122 * too little data). */
123unsigned int buffer_takedata(buffer_t *buf, unsigned char *ptr,
124 unsigned int size);
125
126/* Flushes as much data as possible out of the "from" buffer into the "to"
127 * buffer. Return value is the amount moved. The amount moved can be restricted
128 * to a maximum by specifying "cap" - setting it to -1 means no limit. */
129unsigned int buffer_tobuffer(buffer_t *to, buffer_t *from, int cap);
130#endif
131
132#ifndef NO_IP
133/* Read or write between a file-descriptor and a buffer */
134int buffer_from_fd(buffer_t *buf, int fd);
135int buffer_to_fd(buffer_t *buf, int fd);
136#endif /* !defined(NO_IP) */
137
138#ifndef NO_OPENSSL
139/* Read or write between an SSL or BIO and a buffer */
140void buffer_from_SSL(buffer_t *buf, SSL *ssl);
141void buffer_to_SSL(buffer_t *buf, SSL *ssl);
142void buffer_from_BIO(buffer_t *buf, BIO *bio);
143void buffer_to_BIO(buffer_t *buf, BIO *bio);
144
145/* Callbacks */
146void cb_ssl_info(const SSL *s, int where, int ret);
147void cb_ssl_info_set_output(FILE *fp); /* Called if output should be sent too */
148int cb_ssl_verify(int ok, X509_STORE_CTX *ctx);
149void cb_ssl_verify_set_output(FILE *fp);
150void cb_ssl_verify_set_depth(unsigned int verify_depth);
151void cb_ssl_verify_set_level(unsigned int level);
152#endif /* !defined(NO_OPENSSL) */
153#endif /* !defined(OPENSSL_NO_BUFFER) */
154
155#ifndef NO_TUNALA
156#ifdef OPENSSL_NO_BUFFER
157#error "TUNALA section of tunala.h requires BUFFER support"
158#endif
159typedef struct _state_machine_t {
160 SSL *ssl;
161 BIO *bio_intossl;
162 BIO *bio_fromssl;
163 buffer_t clean_in, clean_out;
164 buffer_t dirty_in, dirty_out;
165} state_machine_t;
166typedef enum {
167 SM_CLEAN_IN, SM_CLEAN_OUT,
168 SM_DIRTY_IN, SM_DIRTY_OUT
169} sm_buffer_t;
170void state_machine_init(state_machine_t *machine);
171void state_machine_close(state_machine_t *machine);
172buffer_t *state_machine_get_buffer(state_machine_t *machine, sm_buffer_t type);
173SSL *state_machine_get_SSL(state_machine_t *machine);
174int state_machine_set_SSL(state_machine_t *machine, SSL *ssl, int is_server);
175/* Performs the data-IO loop and returns zero if the machine should close */
176int state_machine_churn(state_machine_t *machine);
177/* Is used to handle closing conditions - namely when one side of the tunnel has
178 * closed but the other should finish flushing. */
179int state_machine_close_clean(state_machine_t *machine);
180int state_machine_close_dirty(state_machine_t *machine);
181#endif /* !defined(NO_TUNALA) */
182
183#ifndef NO_IP
184/* Initialise anything related to the networking. This includes blocking pesky
185 * SIGPIPE signals. */
186int ip_initialise(void);
187/* ip is the 4-byte ip address (eg. 127.0.0.1 is {0x7F,0x00,0x00,0x01}), port is
188 * the port to listen on (host byte order), and the return value is the
189 * file-descriptor or -1 on error. */
190int ip_create_listener_split(const char *ip, unsigned short port);
191/* Same semantics as above. */
192int ip_create_connection_split(const char *ip, unsigned short port);
193/* Converts a string into the ip/port before calling the above */
194int ip_create_listener(const char *address);
195int ip_create_connection(const char *address);
196/* Just does a string conversion on its own. NB: If accept_all_ip is non-zero,
197 * then the address string could be just a port. Ie. it's suitable for a
198 * listening address but not a connecting address. */
199int ip_parse_address(const char *address, const char **parsed_ip,
200 unsigned short *port, int accept_all_ip);
201/* Accepts an incoming connection through the listener. Assumes selects and
202 * what-not have deemed it an appropriate thing to do. */
203int ip_accept_connection(int listen_fd);
204#endif /* !defined(NO_IP) */
205
206/* These functions wrap up things that can be portability hassles. */
207int int_strtoul(const char *str, unsigned long *val);
208#ifdef HAVE_STRSTR
209#define int_strstr strstr
210#else
211char *int_strstr(const char *haystack, const char *needle);
212#endif
213
214#endif /* !defined(_TUNALA_H) */
diff --git a/src/lib/libssl/src/demos/x509/README b/src/lib/libssl/src/demos/x509/README
new file mode 100644
index 0000000000..88f9d6c46e
--- /dev/null
+++ b/src/lib/libssl/src/demos/x509/README
@@ -0,0 +1,3 @@
1This directory contains examples of how to contruct
2various X509 structures. Certificates, certificate requests
3and CRLs.
diff --git a/src/lib/libssl/src/demos/x509/mkcert.c b/src/lib/libssl/src/demos/x509/mkcert.c
new file mode 100644
index 0000000000..4709e18e7c
--- /dev/null
+++ b/src/lib/libssl/src/demos/x509/mkcert.c
@@ -0,0 +1,168 @@
1/* Certificate creation. Demonstrates some certificate related
2 * operations.
3 */
4
5
6#include <stdio.h>
7#include <stdlib.h>
8
9#include <openssl/pem.h>
10#include <openssl/conf.h>
11#include <openssl/x509v3.h>
12#include <openssl/engine.h>
13
14int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);
15int add_ext(X509 *cert, int nid, char *value);
16
17int main(int argc, char **argv)
18 {
19 BIO *bio_err;
20 X509 *x509=NULL;
21 EVP_PKEY *pkey=NULL;
22
23 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
24
25 bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
26
27 mkcert(&x509,&pkey,512,0,365);
28
29 RSA_print_fp(stdout,pkey->pkey.rsa,0);
30 X509_print_fp(stdout,x509);
31
32 PEM_write_PrivateKey(stdout,pkey,NULL,NULL,0,NULL, NULL);
33 PEM_write_X509(stdout,x509);
34
35 X509_free(x509);
36 EVP_PKEY_free(pkey);
37
38 ENGINE_cleanup();
39 CRYPTO_cleanup_all_ex_data();
40
41 CRYPTO_mem_leaks(bio_err);
42 BIO_free(bio_err);
43 return(0);
44 }
45
46static void callback(int p, int n, void *arg)
47 {
48 char c='B';
49
50 if (p == 0) c='.';
51 if (p == 1) c='+';
52 if (p == 2) c='*';
53 if (p == 3) c='\n';
54 fputc(c,stderr);
55 }
56
57int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days)
58 {
59 X509 *x;
60 EVP_PKEY *pk;
61 RSA *rsa;
62 X509_NAME *name=NULL;
63
64 if ((pkeyp == NULL) || (*pkeyp == NULL))
65 {
66 if ((pk=EVP_PKEY_new()) == NULL)
67 {
68 abort();
69 return(0);
70 }
71 }
72 else
73 pk= *pkeyp;
74
75 if ((x509p == NULL) || (*x509p == NULL))
76 {
77 if ((x=X509_new()) == NULL)
78 goto err;
79 }
80 else
81 x= *x509p;
82
83 rsa=RSA_generate_key(bits,RSA_F4,callback,NULL);
84 if (!EVP_PKEY_assign_RSA(pk,rsa))
85 {
86 abort();
87 goto err;
88 }
89 rsa=NULL;
90
91 X509_set_version(x,3);
92 ASN1_INTEGER_set(X509_get_serialNumber(x),serial);
93 X509_gmtime_adj(X509_get_notBefore(x),0);
94 X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days);
95 X509_set_pubkey(x,pk);
96
97 name=X509_get_subject_name(x);
98
99 /* This function creates and adds the entry, working out the
100 * correct string type and performing checks on its length.
101 * Normally we'd check the return value for errors...
102 */
103 X509_NAME_add_entry_by_txt(name,"C",
104 MBSTRING_ASC, "UK", -1, -1, 0);
105 X509_NAME_add_entry_by_txt(name,"CN",
106 MBSTRING_ASC, "OpenSSL Group", -1, -1, 0);
107
108 /* Its self signed so set the issuer name to be the same as the
109 * subject.
110 */
111 X509_set_issuer_name(x,name);
112
113 /* Add various extensions: standard extensions */
114 add_ext(x, NID_basic_constraints, "critical,CA:TRUE");
115 add_ext(x, NID_key_usage, "critical,keyCertSign,cRLSign");
116
117 add_ext(x, NID_subject_key_identifier, "hash");
118
119 /* Some Netscape specific extensions */
120 add_ext(x, NID_netscape_cert_type, "sslCA");
121
122 add_ext(x, NID_netscape_comment, "example comment extension");
123
124
125#ifdef CUSTOM_EXT
126 /* Maybe even add our own extension based on existing */
127 {
128 int nid;
129 nid = OBJ_create("1.2.3.4", "MyAlias", "My Test Alias Extension");
130 X509V3_EXT_add_alias(nid, NID_netscape_comment);
131 add_ext(x, nid, "example comment alias");
132 }
133#endif
134
135 if (!X509_sign(x,pk,EVP_md5()))
136 goto err;
137
138 *x509p=x;
139 *pkeyp=pk;
140 return(1);
141err:
142 return(0);
143 }
144
145/* Add extension using V3 code: we can set the config file as NULL
146 * because we wont reference any other sections.
147 */
148
149int add_ext(X509 *cert, int nid, char *value)
150 {
151 X509_EXTENSION *ex;
152 X509V3_CTX ctx;
153 /* This sets the 'context' of the extensions. */
154 /* No configuration database */
155 X509V3_set_ctx_nodb(&ctx);
156 /* Issuer and subject certs: both the target since it is self signed,
157 * no request and no CRL
158 */
159 X509V3_set_ctx(&ctx, cert, cert, NULL, NULL, 0);
160 ex = X509V3_EXT_conf_nid(NULL, &ctx, nid, value);
161 if (!ex)
162 return 0;
163
164 X509_add_ext(cert,ex,-1);
165 X509_EXTENSION_free(ex);
166 return 1;
167 }
168
diff --git a/src/lib/libssl/src/demos/x509/mkreq.c b/src/lib/libssl/src/demos/x509/mkreq.c
new file mode 100644
index 0000000000..d69dcc392b
--- /dev/null
+++ b/src/lib/libssl/src/demos/x509/mkreq.c
@@ -0,0 +1,157 @@
1/* Certificate request creation. Demonstrates some request related
2 * operations.
3 */
4
5#include <stdio.h>
6#include <stdlib.h>
7
8#include <openssl/pem.h>
9#include <openssl/conf.h>
10#include <openssl/x509v3.h>
11#include <openssl/engine.h>
12
13int mkreq(X509_REQ **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);
14int add_ext(STACK_OF(X509_REQUEST) *sk, int nid, char *value);
15
16int main(int argc, char **argv)
17 {
18 BIO *bio_err;
19 X509_REQ *req=NULL;
20 EVP_PKEY *pkey=NULL;
21
22 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
23
24 bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
25
26 mkreq(&req,&pkey,512,0,365);
27
28 RSA_print_fp(stdout,pkey->pkey.rsa,0);
29 X509_REQ_print_fp(stdout,req);
30
31 PEM_write_X509_REQ(stdout,req);
32
33 X509_REQ_free(req);
34 EVP_PKEY_free(pkey);
35
36 ENGINE_cleanup();
37 CRYPTO_cleanup_all_ex_data();
38
39 CRYPTO_mem_leaks(bio_err);
40 BIO_free(bio_err);
41 return(0);
42 }
43
44static void callback(int p, int n, void *arg)
45 {
46 char c='B';
47
48 if (p == 0) c='.';
49 if (p == 1) c='+';
50 if (p == 2) c='*';
51 if (p == 3) c='\n';
52 fputc(c,stderr);
53 }
54
55int mkreq(X509_REQ **req, EVP_PKEY **pkeyp, int bits, int serial, int days)
56 {
57 X509_REQ *x;
58 EVP_PKEY *pk;
59 RSA *rsa;
60 X509_NAME *name=NULL;
61 STACK_OF(X509_EXTENSION) *exts = NULL;
62
63 if ((pk=EVP_PKEY_new()) == NULL)
64 goto err;
65
66 if ((x=X509_REQ_new()) == NULL)
67 goto err;
68
69 rsa=RSA_generate_key(bits,RSA_F4,callback,NULL);
70 if (!EVP_PKEY_assign_RSA(pk,rsa))
71 goto err;
72
73 rsa=NULL;
74
75 X509_REQ_set_pubkey(x,pk);
76
77 name=X509_REQ_get_subject_name(x);
78
79 /* This function creates and adds the entry, working out the
80 * correct string type and performing checks on its length.
81 * Normally we'd check the return value for errors...
82 */
83 X509_NAME_add_entry_by_txt(name,"C",
84 MBSTRING_ASC, "UK", -1, -1, 0);
85 X509_NAME_add_entry_by_txt(name,"CN",
86 MBSTRING_ASC, "OpenSSL Group", -1, -1, 0);
87
88#ifdef REQUEST_EXTENSIONS
89 /* Certificate requests can contain extensions, which can be used
90 * to indicate the extensions the requestor would like added to
91 * their certificate. CAs might ignore them however or even choke
92 * if they are present.
93 */
94
95 /* For request extensions they are all packed in a single attribute.
96 * We save them in a STACK and add them all at once later...
97 */
98
99 exts = sk_X509_EXTENSION_new_null();
100 /* Standard extenions */
101
102 add_ext(exts, NID_key_usage, "critical,digitalSignature,keyEncipherment");
103
104 /* This is a typical use for request extensions: requesting a value for
105 * subject alternative name.
106 */
107
108 add_ext(exts, NID_subject_alt_name, "email:steve@openssl.org");
109
110 /* Some Netscape specific extensions */
111 add_ext(exts, NID_netscape_cert_type, "client,email");
112
113
114
115#ifdef CUSTOM_EXT
116 /* Maybe even add our own extension based on existing */
117 {
118 int nid;
119 nid = OBJ_create("1.2.3.4", "MyAlias", "My Test Alias Extension");
120 X509V3_EXT_add_alias(nid, NID_netscape_comment);
121 add_ext(x, nid, "example comment alias");
122 }
123#endif
124
125 /* Now we've created the extensions we add them to the request */
126
127 X509_REQ_add_extensions(x, exts);
128
129 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
130
131#endif
132
133 if (!X509_REQ_sign(x,pk,EVP_md5()))
134 goto err;
135
136 *req=x;
137 *pkeyp=pk;
138 return(1);
139err:
140 return(0);
141 }
142
143/* Add extension using V3 code: we can set the config file as NULL
144 * because we wont reference any other sections.
145 */
146
147int add_ext(STACK_OF(X509_REQUEST) *sk, int nid, char *value)
148 {
149 X509_EXTENSION *ex;
150 ex = X509V3_EXT_conf_nid(NULL, NULL, nid, value);
151 if (!ex)
152 return 0;
153 sk_X509_EXTENSION_push(sk, ex);
154
155 return 1;
156 }
157
diff --git a/src/lib/libssl/src/doc/HOWTO/certificates.txt b/src/lib/libssl/src/doc/HOWTO/certificates.txt
new file mode 100644
index 0000000000..88048645db
--- /dev/null
+++ b/src/lib/libssl/src/doc/HOWTO/certificates.txt
@@ -0,0 +1,85 @@
1<DRAFT!>
2 HOWTO certificates
3
4How you handle certificates depend a great deal on what your role is.
5Your role can be one or several of:
6
7 - User of some client software
8 - User of some server software
9 - Certificate authority
10
11This file is for users who wish to get a certificate of their own.
12Certificate authorities should read ca.txt.
13
14In all the cases shown below, the standard configuration file, as
15compiled into openssl, will be used. You may find it in /etc/,
16/usr/local/ssr/ or somewhere else. The name is openssl.cnf, and
17is better described in another HOWTO <config.txt?>. If you want to
18use a different configuration file, use the argument '-config {file}'
19with the command shown below.
20
21
22Certificates are related to public key cryptography by containing a
23public key. To be useful, there must be a corresponding private key
24somewhere. With OpenSSL, public keys are easily derived from private
25keys, so before you create a certificate or a certificate request, you
26need to create a private key.
27
28Private keys are generated with 'openssl genrsa' if you want a RSA
29private key, or 'openssl gendsa' if you want a DSA private key. More
30info on how to handle these commands are found in the manual pages for
31those commands or by running them with the argument '-h'. For the
32sake of the description in this file, let's assume that the private
33key ended up in the file privkey.pem (which is the default in some
34cases).
35
36
37Let's start with the most normal way of getting a certificate. Most
38often, you want or need to get a certificate from a certificate
39authority. To handle that, the certificate authority needs a
40certificate request (or, as some certificate authorities like to put
41it, "certificate signing request", since that's exactly what they do,
42they sign it and give you the result back, thus making it authentic
43according to their policies) from you. To generate a request, use the
44command 'openssl req' like this:
45
46 openssl req -new -key privkey.pem -out cert.csr
47
48Now, cert.csr can be sent to the certificate authority, if they can
49handle files in PEM format. If not, use the extra argument '-outform'
50followed by the keyword for the format to use (see another HOWTO
51<formats.txt?>). In some cases, that isn't sufficient and you will
52have to be more creative.
53
54When the certificate authority has then done the checks the need to
55do (and probably gotten payment from you), they will hand over your
56new certificate to you.
57
58
59[fill in on how to create a self-signed certificate]
60
61
62If you created everything yourself, or if the certificate authority
63was kind enough, your certificate is a raw DER thing in PEM format.
64Your key most definitely is if you have followed the examples above.
65However, some (most?) certificate authorities will encode them with
66things like PKCS7 or PKCS12, or something else. Depending on your
67applications, this may be perfectly OK, it all depends on what they
68know how to decode. If not, There are a number of OpenSSL tools to
69convert between some (most?) formats.
70
71So, depending on your application, you may have to convert your
72certificate and your key to various formats, most often also putting
73them together into one file. The ways to do this is described in
74another HOWTO <formats.txt?>, I will just mention the simplest case.
75In the case of a raw DER thing in PEM format, and assuming that's all
76right for yor applications, simply concatenating the certificate and
77the key into a new file and using that one should be enough. With
78some applications, you don't even have to do that.
79
80
81By now, you have your cetificate and your private key and can start
82using the software that depend on it.
83
84--
85Richard Levitte
diff --git a/src/lib/libssl/src/doc/apps/CA.pl.pod b/src/lib/libssl/src/doc/apps/CA.pl.pod
index 63cd1320cc..58e0f52001 100644
--- a/src/lib/libssl/src/doc/apps/CA.pl.pod
+++ b/src/lib/libssl/src/doc/apps/CA.pl.pod
@@ -13,6 +13,7 @@ B<CA.pl>
13[B<-help>] 13[B<-help>]
14[B<-newcert>] 14[B<-newcert>]
15[B<-newreq>] 15[B<-newreq>]
16[B<-newreq-nodes>]
16[B<-newca>] 17[B<-newca>]
17[B<-xsign>] 18[B<-xsign>]
18[B<-sign>] 19[B<-sign>]
@@ -46,6 +47,10 @@ written to the file "newreq.pem".
46creates a new certificate request. The private key and request are 47creates a new certificate request. The private key and request are
47written to the file "newreq.pem". 48written to the file "newreq.pem".
48 49
50=item B<-newreq-nowdes>
51
52is like B<-newreq> except that the private key will not be encrypted.
53
49=item B<-newca> 54=item B<-newca>
50 55
51creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert> 56creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
diff --git a/src/lib/libssl/src/doc/apps/ca.pod b/src/lib/libssl/src/doc/apps/ca.pod
index d352925864..c2ca8f2400 100644
--- a/src/lib/libssl/src/doc/apps/ca.pod
+++ b/src/lib/libssl/src/doc/apps/ca.pod
@@ -13,6 +13,7 @@ B<openssl> B<ca>
13[B<-name section>] 13[B<-name section>]
14[B<-gencrl>] 14[B<-gencrl>]
15[B<-revoke file>] 15[B<-revoke file>]
16[B<-subj arg>]
16[B<-crldays days>] 17[B<-crldays days>]
17[B<-crlhours hours>] 18[B<-crlhours hours>]
18[B<-crlexts section>] 19[B<-crlexts section>]
@@ -33,9 +34,11 @@ B<openssl> B<ca>
33[B<-spkac file>] 34[B<-spkac file>]
34[B<-ss_cert file>] 35[B<-ss_cert file>]
35[B<-preserveDN>] 36[B<-preserveDN>]
37[B<-noemailDN>]
36[B<-batch>] 38[B<-batch>]
37[B<-msie_hack>] 39[B<-msie_hack>]
38[B<-extensions section>] 40[B<-extensions section>]
41[B<-extfile section>]
39 42
40=head1 DESCRIPTION 43=head1 DESCRIPTION
41 44
@@ -54,6 +57,11 @@ The options descriptions will be divided into each purpose.
54 57
55specifies the configuration file to use. 58specifies the configuration file to use.
56 59
60=item B<-name section>
61
62specifies the configuration file section to use (overrides
63B<default_ca> in the B<ca> section).
64
57=item B<-in filename> 65=item B<-in filename>
58 66
59an input filename containing a single certificate request to be 67an input filename containing a single certificate request to be
@@ -104,6 +112,7 @@ the 'ps' utility) this option should be used with caution.
104 112
105the key password source. For more information about the format of B<arg> 113the key password source. For more information about the format of B<arg>
106see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 114see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
115
107=item B<-verbose> 116=item B<-verbose>
108 117
109this prints extra details about the operations being performed. 118this prints extra details about the operations being performed.
@@ -154,6 +163,15 @@ is the same as the request. This is largely for compatibility with the
154older IE enrollment control which would only accept certificates if their 163older IE enrollment control which would only accept certificates if their
155DNs match the order of the request. This is not needed for Xenroll. 164DNs match the order of the request. This is not needed for Xenroll.
156 165
166=item B<-noemailDN>
167
168The DN of a certificate can contain the EMAIL field if present in the
169request DN, however it is good policy just having the e-mail set into
170the altName extension of the certificate. When this option is set the
171EMAIL field is removed from the certificate' subject and set only in
172the, eventually present, extensions. The B<email_in_dn> keyword can be
173used in the configuration file to enable this behaviour.
174
157=item B<-batch> 175=item B<-batch>
158 176
159this sets the batch mode. In this mode no questions will be asked 177this sets the batch mode. In this mode no questions will be asked
@@ -162,9 +180,16 @@ and all certificates will be certified automatically.
162=item B<-extensions section> 180=item B<-extensions section>
163 181
164the section of the configuration file containing certificate extensions 182the section of the configuration file containing certificate extensions
165to be added when a certificate is issued. If no extension section is 183to be added when a certificate is issued (defaults to B<x509_extensions>
166present then a V1 certificate is created. If the extension section 184unless the B<-extfile> option is used). If no extension section is
167is present (even if it is empty) then a V3 certificate is created. 185present then, a V1 certificate is created. If the extension section
186is present (even if it is empty), then a V3 certificate is created.
187
188=item B<-extfile file>
189
190an additional configuration file to read certificate extensions from
191(using the default section unless the B<-extensions> option is also
192used).
168 193
169=back 194=back
170 195
@@ -189,6 +214,12 @@ the number of hours before the next CRL is due.
189 214
190a filename containing a certificate to revoke. 215a filename containing a certificate to revoke.
191 216
217=item B<-subj arg>
218
219supersedes subject name given in the request.
220The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
221characters may be escaped by \ (backslash), no spaces are skipped.
222
192=item B<-crlexts section> 223=item B<-crlexts section>
193 224
194the section of the configuration file containing CRL extensions to 225the section of the configuration file containing CRL extensions to
@@ -202,8 +233,20 @@ that some software (for example Netscape) can't handle V2 CRLs.
202 233
203=head1 CONFIGURATION FILE OPTIONS 234=head1 CONFIGURATION FILE OPTIONS
204 235
205The options for B<ca> are contained in the B<ca> section of the 236The section of the configuration file containing options for B<ca>
206configuration file. Many of these are identical to command line 237is found as follows: If the B<-name> command line option is used,
238then it names the section to be used. Otherwise the section to
239be used must be named in the B<default_ca> option of the B<ca> section
240of the configuration file (or in the default section of the
241configuration file). Besides B<default_ca>, the following options are
242read directly from the B<ca> section:
243 RANDFILE
244 preserve
245 msie_hack
246With the exception of B<RANDFILE>, this is probably a bug and may
247change in future releases.
248
249Many of the configuration file options are identical to command line
207options. Where the option is present in the configuration file 250options. Where the option is present in the configuration file
208and the command line the command line value is used. Where an 251and the command line the command line value is used. Where an
209option is described as mandatory then it must be present in 252option is described as mandatory then it must be present in
@@ -294,6 +337,12 @@ the same as B<-crlexts>.
294 337
295the same as B<-preserveDN> 338the same as B<-preserveDN>
296 339
340=item B<email_in_dn>
341
342the same as B<-noemailDN>. If you want the EMAIL field to be removed
343from the DN of the certificate simply set this to 'no'. If not present
344the default is to allow for the EMAIL filed in the certificate's DN.
345
297=item B<msie_hack> 346=item B<msie_hack>
298 347
299the same as B<-msie_hack> 348the same as B<-msie_hack>
@@ -303,6 +352,37 @@ the same as B<-msie_hack>
303the same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section 352the same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
304for more information. 353for more information.
305 354
355=item B<nameopt>, B<certopt>
356
357these options allow the format used to display the certificate details
358when asking the user to confirm signing. All the options supported by
359the B<x509> utilities B<-nameopt> and B<-certopt> switches can be used
360here, except the B<no_signame> and B<no_sigdump> are permanently set
361and cannot be disabled (this is because the certificate signature cannot
362be displayed because the certificate has not been signed at this point).
363
364For convenience the values B<default_ca> are accepted by both to produce
365a reasonable output.
366
367If neither option is present the format used in earlier versions of
368OpenSSL is used. Use of the old format is B<strongly> discouraged because
369it only displays fields mentioned in the B<policy> section, mishandles
370multicharacter string types and does not display extensions.
371
372=item B<copy_extensions>
373
374determines how extensions in certificate requests should be handled.
375If set to B<none> or this option is not present then extensions are
376ignored and not copied to the certificate. If set to B<copy> then any
377extensions present in the request that are not already present are copied
378to the certificate. If set to B<copyall> then all extensions in the
379request are copied to the certificate: if the extension is already present
380in the certificate it is deleted first. See the B<WARNINGS> section before
381using this option.
382
383The main use of this option is to allow a certificate request to supply
384values for certain extensions such as subjectAltName.
385
306=back 386=back
307 387
308=head1 POLICY FORMAT 388=head1 POLICY FORMAT
@@ -392,6 +472,11 @@ A sample configuration file with the relevant sections for B<ca>:
392 default_md = md5 # md to use 472 default_md = md5 # md to use
393 473
394 policy = policy_any # default policy 474 policy = policy_any # default policy
475 email_in_dn = no # Don't add the email into cert DN
476
477 nameopt = default_ca # Subject name display option
478 certopt = default_ca # Certificate display option
479 copy_extensions = none # Don't copy extensions from request
395 480
396 [ policy_any ] 481 [ policy_any ]
397 countryName = supplied 482 countryName = supplied
@@ -406,7 +491,7 @@ A sample configuration file with the relevant sections for B<ca>:
406The B<ca> command is quirky and at times downright unfriendly. 491The B<ca> command is quirky and at times downright unfriendly.
407 492
408The B<ca> utility was originally meant as an example of how to do things 493The B<ca> utility was originally meant as an example of how to do things
409in a CA. It was not supposed be be used as a full blown CA itself: 494in a CA. It was not supposed to be used as a full blown CA itself:
410nevertheless some people are using it for this purpose. 495nevertheless some people are using it for this purpose.
411 496
412The B<ca> command is effectively a single user command: no locking is 497The B<ca> command is effectively a single user command: no locking is
@@ -457,10 +542,6 @@ The use of an in memory text database can cause problems when large
457numbers of certificates are present because, as the name implies 542numbers of certificates are present because, as the name implies
458the database has to be kept in memory. 543the database has to be kept in memory.
459 544
460Certificate request extensions are ignored: some kind of "policy" should
461be included to use certain static extensions and certain extensions
462from the request.
463
464It is not possible to certify two certificates with the same DN: this 545It is not possible to certify two certificates with the same DN: this
465is a side effect of how the text database is indexed and it cannot easily 546is a side effect of how the text database is indexed and it cannot easily
466be fixed without introducing other problems. Some S/MIME clients can use 547be fixed without introducing other problems. Some S/MIME clients can use
@@ -473,13 +554,39 @@ exposed at either a command or interface level so a more friendly utility
473B<CA.pl> help a little but not very much. 554B<CA.pl> help a little but not very much.
474 555
475Any fields in a request that are not present in a policy are silently 556Any fields in a request that are not present in a policy are silently
476deleted. This does not happen if the B<-preserveDN> option is used but 557deleted. This does not happen if the B<-preserveDN> option is used. To
477the extra fields are not displayed when the user is asked to certify 558enforce the absence of the EMAIL field within the DN, as suggested by
478a request. The behaviour should be more friendly and configurable. 559RFCs, regardless the contents of the request' subject the B<-noemailDN>
560option can be used. The behaviour should be more friendly and
561configurable.
479 562
480Cancelling some commands by refusing to certify a certificate can 563Cancelling some commands by refusing to certify a certificate can
481create an empty file. 564create an empty file.
482 565
566=head1 WARNINGS
567
568The B<copy_extensions> option should be used with caution. If care is
569not taken then it can be a security risk. For example if a certificate
570request contains a basicConstraints extension with CA:TRUE and the
571B<copy_extensions> value is set to B<copyall> and the user does not spot
572this when the certificate is displayed then this will hand the requestor
573a valid CA certificate.
574
575This situation can be avoided by setting B<copy_extensions> to B<copy>
576and including basicConstraints with CA:FALSE in the configuration file.
577Then if the request contains a basicConstraints extension it will be
578ignored.
579
580It is advisable to also include values for other extensions such
581as B<keyUsage> to prevent a request supplying its own values.
582
583Additional restrictions can be placed on the CA certificate itself.
584For example if the CA certificate has:
585
586 basicConstraints = CA:TRUE, pathlen:0
587
588then even if a certificate is issued with CA:TRUE it will not be valid.
589
483=head1 SEE ALSO 590=head1 SEE ALSO
484 591
485L<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>, 592L<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>,
diff --git a/src/lib/libssl/src/doc/apps/enc.pod b/src/lib/libssl/src/doc/apps/enc.pod
index a68ddca139..ddf081617f 100644
--- a/src/lib/libssl/src/doc/apps/enc.pod
+++ b/src/lib/libssl/src/doc/apps/enc.pod
@@ -21,6 +21,7 @@ B<openssl enc -ciphername>
21[B<-p>] 21[B<-p>]
22[B<-P>] 22[B<-P>]
23[B<-bufsize number>] 23[B<-bufsize number>]
24[B<-nopad>]
24[B<-debug>] 25[B<-debug>]
25 26
26=head1 DESCRIPTION 27=head1 DESCRIPTION
@@ -122,6 +123,10 @@ or decryption.
122 123
123set the buffer size for I/O 124set the buffer size for I/O
124 125
126=item B<-nopad>
127
128disable standard block padding
129
125=item B<-debug> 130=item B<-debug>
126 131
127debug the BIOs used for I/O. 132debug the BIOs used for I/O.
@@ -150,11 +155,14 @@ Some of the ciphers do not have large keys and others have security
150implications if not used correctly. A beginner is advised to just use 155implications if not used correctly. A beginner is advised to just use
151a strong block cipher in CBC mode such as bf or des3. 156a strong block cipher in CBC mode such as bf or des3.
152 157
153All the block ciphers use PKCS#5 padding also known as standard block 158All the block ciphers normally use PKCS#5 padding also known as standard block
154padding: this allows a rudimentary integrity or password check to be 159padding: this allows a rudimentary integrity or password check to be
155performed. However since the chance of random data passing the test is 160performed. However since the chance of random data passing the test is
156better than 1 in 256 it isn't a very good test. 161better than 1 in 256 it isn't a very good test.
157 162
163If padding is disabled then the input data must be a multiple of the cipher
164block length.
165
158All RC2 ciphers have the same key and effective key length. 166All RC2 ciphers have the same key and effective key length.
159 167
160Blowfish and RC5 algorithms use a 128 bit key. 168Blowfish and RC5 algorithms use a 128 bit key.
@@ -256,8 +264,8 @@ The B<-A> option when used with large files doesn't work properly.
256 264
257There should be an option to allow an iteration count to be included. 265There should be an option to allow an iteration count to be included.
258 266
259Like the EVP library the B<enc> program only supports a fixed number of 267The B<enc> program only supports a fixed number of algorithms with
260algorithms with certain parameters. So if, for example, you want to use RC2 268certain parameters. So if, for example, you want to use RC2 with a
261with a 76 bit key or RC4 with an 84 bit key you can't use this program. 26976 bit key or RC4 with an 84 bit key you can't use this program.
262 270
263=cut 271=cut
diff --git a/src/lib/libssl/src/doc/apps/ocsp.pod b/src/lib/libssl/src/doc/apps/ocsp.pod
new file mode 100644
index 0000000000..da201b95e6
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps/ocsp.pod
@@ -0,0 +1,348 @@
1=pod
2
3=head1 NAME
4
5ocsp - Online Certificate Status Protocol utility
6
7=head1 SYNOPSIS
8
9B<openssl> B<ocsp>
10[B<-out file>]
11[B<-issuer file>]
12[B<-cert file>]
13[B<-serial n>]
14[B<-req_text>]
15[B<-resp_text>]
16[B<-text>]
17[B<-reqout file>]
18[B<-respout file>]
19[B<-reqin file>]
20[B<-respin file>]
21[B<-nonce>]
22[B<-no_nonce>]
23[B<-url responder_url>]
24[B<-host host:n>]
25[B<-path>]
26[B<-CApath file>]
27[B<-CAfile file>]
28[B<-VAfile file>]
29[B<-verify_certs file>]
30[B<-noverify>]
31[B<-trust_other>]
32[B<-no_intern>]
33[B<-no_sig_verify>]
34[B<-no_cert_verify>]
35[B<-no_chain>]
36[B<-no_cert_checks>]
37[B<-validity_period nsec>]
38[B<-status_age nsec>]
39
40=head1 DESCRIPTION
41
42B<WARNING: this documentation is preliminary and subject to change.>
43
44The Online Certificate Status Protocol (OCSP) enables applications to
45determine the (revocation) state of an identified certificate (RFC 2560).
46
47The B<ocsp> command performs many common OCSP tasks. It can be used
48to print out requests and responses, create requests and send queries
49to an OCSP responder and behave like a mini OCSP server itself.
50
51=head1 OCSP CLIENT OPTIONS
52
53=over 4
54
55=item B<-out filename>
56
57specify output filename, default is standard output.
58
59=item B<-issuer filename>
60
61This specifies the current issuer certificate. This option can be used
62multiple times. The certificate specified in B<filename> must be in
63PEM format.
64
65=item B<-cert filename>
66
67Add the certificate B<filename> to the request. The issuer certificate
68is taken from the previous B<issuer> option, or an error occurs if no
69issuer certificate is specified.
70
71=item B<-serial num>
72
73Same as the B<cert> option except the certificate with serial number
74B<num> is added to the request. The serial number is interpreted as a
75decimal integer unless preceded by B<0x>. Negative integers can also
76be specified by preceding the value by a B<-> sign.
77
78=item B<-signer filename>, B<-signkey filename>
79
80Sign the OCSP request using the certificate specified in the B<signer>
81option and the private key specified by the B<signkey> option. If
82the B<signkey> option is not present then the private key is read
83from the same file as the certificate. If neither option is specified then
84the OCSP request is not signed.
85
86=item B<-nonce>, B<-no_nonce>
87
88Add an OCSP nonce extension to a request or disable OCSP nonce addition.
89Normally if an OCSP request is input using the B<respin> option no
90nonce is added: using the B<nonce> option will force addition of a nonce.
91If an OCSP request is being created (using B<cert> and B<serial> options)
92a nonce is automatically added specifying B<no_nonce> overrides this.
93
94=item B<-req_text>, B<-resp_text>, B<-text>
95
96print out the text form of the OCSP request, response or both respectively.
97
98=item B<-reqout file>, B<-respout file>
99
100write out the DER encoded certificate request or response to B<file>.
101
102=item B<-reqin file>, B<-respin file>
103
104read OCSP request or response file from B<file>. These option are ignored
105if OCSP request or response creation is implied by other options (for example
106with B<serial>, B<cert> and B<host> options).
107
108=item B<-url responder_url>
109
110specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs can be specified.
111
112=item B<-host hostname:port>, B<-path pathname>
113
114if the B<host> option is present then the OCSP request is sent to the host
115B<hostname> on port B<port>. B<path> specifies the HTTP path name to use
116or "/" by default.
117
118=item B<-CAfile file>, B<-CApath pathname>
119
120file or pathname containing trusted CA certificates. These are used to verify
121the signature on the OCSP response.
122
123=item B<-verify_certs file>
124
125file containing additional certificates to search when attempting to locate
126the OCSP response signing certificate. Some responders omit the actual signer's
127certificate from the response: this option can be used to supply the necessary
128certificate in such cases.
129
130=item B<-trust_other>
131
132the certificates specified by the B<-verify_certs> option should be explicitly
133trusted and no additional checks will be performed on them. This is useful
134when the complete responder certificate chain is not available or trusting a
135root CA is not appropriate.
136
137=item B<-VAfile file>
138
139file containing explicitly trusted responder certificates. Equivalent to the
140B<-verify_certs> and B<-trust_other> options.
141
142=item B<-noverify>
143
144don't attempt to verify the OCSP response signature or the nonce values. This
145option will normally only be used for debugging since it disables all verification
146of the responders certificate.
147
148=item B<-no_intern>
149
150ignore certificates contained in the OCSP response when searching for the
151signers certificate. With this option the signers certificate must be specified
152with either the B<-verify_certs> or B<-VAfile> options.
153
154=item B<-no_sig_verify>
155
156don't check the signature on the OCSP response. Since this option tolerates invalid
157signatures on OCSP responses it will normally only be used for testing purposes.
158
159=item B<-no_cert_verify>
160
161don't verify the OCSP response signers certificate at all. Since this option allows
162the OCSP response to be signed by any certificate it should only be used for
163testing purposes.
164
165=item B<-no_chain>
166
167do not use certificates in the response as additional untrusted CA
168certificates.
169
170=item B<-no_cert_checks>
171
172don't perform any additional checks on the OCSP response signers certificate.
173That is do not make any checks to see if the signers certificate is authorised
174to provide the necessary status information: as a result this option should
175only be used for testing purposes.
176
177=item B<-validity_period nsec>, B<-status_age age>
178
179these options specify the range of times, in seconds, which will be tolerated
180in an OCSP response. Each certificate status response includes a B<notBefore> time and
181an optional B<notAfter> time. The current time should fall between these two values, but
182the interval between the two times may be only a few seconds. In practice the OCSP
183responder and clients clocks may not be precisely synchronised and so such a check
184may fail. To avoid this the B<-validity_period> option can be used to specify an
185acceptable error range in seconds, the default value is 5 minutes.
186
187If the B<notAfter> time is omitted from a response then this means that new status
188information is immediately available. In this case the age of the B<notBefore> field
189is checked to see it is not older than B<age> seconds old. By default this additional
190check is not performed.
191
192=back
193
194=head1 OCSP SERVER OPTIONS
195
196=over 4
197
198=item B<-index indexfile>
199
200B<indexfile> is a text index file in B<ca> format containing certificate revocation
201information.
202
203If the B<index> option is specified the B<ocsp> utility is in responder mode, otherwise
204it is in client mode. The request(s) the responder processes can be either specified on
205the command line (using B<issuer> and B<serial> options), supplied in a file (using the
206B<respin> option) or via external OCSP clients (if B<port> or B<url> is specified).
207
208If the B<index> option is present then the B<CA> and B<rsigner> options must also be
209present.
210
211=item B<-CA file>
212
213CA certificate corresponding to the revocation information in B<indexfile>.
214
215=item B<-rsigner file>
216
217The certificate to sign OCSP responses with.
218
219=item B<-rother file>
220
221Additional certificates to include in the OCSP response.
222
223=item B<-resp_no_certs>
224
225Don't include any certificates in the OCSP response.
226
227=item B<-resp_key_id>
228
229Identify the signer certificate using the key ID, default is to use the subject name.
230
231=item B<-rkey file>
232
233The private key to sign OCSP responses with: if not present the file specified in the
234B<rsigner> option is used.
235
236=item B<-port portnum>
237
238Port to listen for OCSP requests on. The port may also be specified using the B<url>
239option.
240
241=item B<-nrequest number>
242
243The OCSP server will exit after receiving B<number> requests, default unlimited.
244
245=item B<-nmin minutes>, B<-ndays days>
246
247Number of minutes or days when fresh revocation information is available: used in the
248B<nextUpdate> field. If neither option is present then the B<nextUpdate> field is
249omitted meaning fresh revocation information is immediately available.
250
251=back
252
253=head1 OCSP Response verification.
254
255OCSP Response follows the rules specified in RFC2560.
256
257Initially the OCSP responder certificate is located and the signature on
258the OCSP request checked using the responder certificate's public key.
259
260Then a normal certificate verify is performed on the OCSP responder certificate
261building up a certificate chain in the process. The locations of the trusted
262certificates used to build the chain can be specified by the B<CAfile>
263and B<CApath> options or they will be looked for in the standard OpenSSL
264certificates directory.
265
266If the initial verify fails then the OCSP verify process halts with an
267error.
268
269Otherwise the issuing CA certificate in the request is compared to the OCSP
270responder certificate: if there is a match then the OCSP verify succeeds.
271
272Otherwise the OCSP responder certificate's CA is checked against the issuing
273CA certificate in the request. If there is a match and the OCSPSigning
274extended key usage is present in the OCSP responder certificate then the
275OCSP verify succeeds.
276
277Otherwise the root CA of the OCSP responders CA is checked to see if it
278is trusted for OCSP signing. If it is the OCSP verify succeeds.
279
280If none of these checks is successful then the OCSP verify fails.
281
282What this effectively means if that if the OCSP responder certificate is
283authorised directly by the CA it is issuing revocation information about
284(and it is correctly configured) then verification will succeed.
285
286If the OCSP responder is a "global responder" which can give details about
287multiple CAs and has its own separate certificate chain then its root
288CA can be trusted for OCSP signing. For example:
289
290 openssl x509 -in ocspCA.pem -addtrust OCSPSigning -out trustedCA.pem
291
292Alternatively the responder certificate itself can be explicitly trusted
293with the B<-VAfile> option.
294
295=head1 NOTES
296
297As noted, most of the verify options are for testing or debugging purposes.
298Normally only the B<-CApath>, B<-CAfile> and (if the responder is a 'global
299VA') B<-VAfile> options need to be used.
300
301The OCSP server is only useful for test and demonstration purposes: it is
302not really usable as a full OCSP responder. It contains only a very
303simple HTTP request handling and can only handle the POST form of OCSP
304queries. It also handles requests serially meaning it cannot respond to
305new requests until it has processed the current one. The text index file
306format of revocation is also inefficient for large quantities of revocation
307data.
308
309It is possible to run the B<ocsp> application in responder mode via a CGI
310script using the B<respin> and B<respout> options.
311
312=head1 EXAMPLES
313
314Create an OCSP request and write it to a file:
315
316 openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem -reqout req.der
317
318Send a query to an OCSP responder with URL http://ocsp.myhost.com/ save the
319response to a file and print it out in text form
320
321 openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \
322 -url http://ocsp.myhost.com/ -resp_text -respout resp.der
323
324Read in an OCSP response and print out text form:
325
326 openssl ocsp -respin resp.der -text
327
328OCSP server on port 8888 using a standard B<ca> configuration, and a separate
329responder certificate. All requests and responses are printed to a file.
330
331 openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
332 -text -out log.txt
333
334As above but exit after processing one request:
335
336 openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
337 -nrequest 1
338
339Query status information using internally generated request:
340
341 openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
342 -issuer demoCA/cacert.pem -serial 1
343
344Query status information using request read from a file, write response to a
345second file.
346
347 openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
348 -reqin req.der -respout resp.der
diff --git a/src/lib/libssl/src/doc/apps/openssl.pod b/src/lib/libssl/src/doc/apps/openssl.pod
index 0cbd199d79..07dd80eabe 100644
--- a/src/lib/libssl/src/doc/apps/openssl.pod
+++ b/src/lib/libssl/src/doc/apps/openssl.pod
@@ -121,10 +121,18 @@ Generation of DSA Parameters.
121 121
122Generation of RSA Parameters. 122Generation of RSA Parameters.
123 123
124=item L<B<ocsp>|ocsp(1)>
125
126Online Certificate Status Protocol utility.
127
124=item L<B<passwd>|passwd(1)> 128=item L<B<passwd>|passwd(1)>
125 129
126Generation of hashed passwords. 130Generation of hashed passwords.
127 131
132=item L<B<pkcs12>|pkcs12(1)>
133
134PKCS#12 Data Management.
135
128=item L<B<pkcs7>|pkcs7(1)> 136=item L<B<pkcs7>|pkcs7(1)>
129 137
130PKCS#7 Data Management. 138PKCS#7 Data Management.
diff --git a/src/lib/libssl/src/doc/apps/passwd.pod b/src/lib/libssl/src/doc/apps/passwd.pod
index 6e098940c7..07d849c824 100644
--- a/src/lib/libssl/src/doc/apps/passwd.pod
+++ b/src/lib/libssl/src/doc/apps/passwd.pod
@@ -13,6 +13,7 @@ B<openssl passwd>
13[B<-salt> I<string>] 13[B<-salt> I<string>]
14[B<-in> I<file>] 14[B<-in> I<file>]
15[B<-stdin>] 15[B<-stdin>]
16[B<-noverify>]
16[B<-quiet>] 17[B<-quiet>]
17[B<-table>] 18[B<-table>]
18{I<password>} 19{I<password>}
@@ -22,7 +23,7 @@ B<openssl passwd>
22The B<passwd> command computes the hash of a password typed at 23The B<passwd> command computes the hash of a password typed at
23run-time or the hash of each password in a list. The password list is 24run-time or the hash of each password in a list. The password list is
24taken from the named file for option B<-in file>, from stdin for 25taken from the named file for option B<-in file>, from stdin for
25option B<-stdin>, and from the command line otherwise. 26option B<-stdin>, or from the command line, or from the terminal otherwise.
26The Unix standard algorithm B<crypt> and the MD5-based BSD password 27The Unix standard algorithm B<crypt> and the MD5-based BSD password
27algorithm B<1> and its Apache variant B<apr1> are available. 28algorithm B<1> and its Apache variant B<apr1> are available.
28 29
@@ -45,6 +46,7 @@ Use the B<apr1> algorithm (Apache variant of the BSD algorithm).
45=item B<-salt> I<string> 46=item B<-salt> I<string>
46 47
47Use the specified salt. 48Use the specified salt.
49When reading a password from the terminal, this implies B<-noverify>.
48 50
49=item B<-in> I<file> 51=item B<-in> I<file>
50 52
@@ -54,6 +56,10 @@ Read passwords from I<file>.
54 56
55Read passwords from B<stdin>. 57Read passwords from B<stdin>.
56 58
59=item B<-noverify>
60
61Don't verify when reading a password from the terminal.
62
57=item B<-quiet> 63=item B<-quiet>
58 64
59Don't output warnings when passwords given at the command line are truncated. 65Don't output warnings when passwords given at the command line are truncated.
diff --git a/src/lib/libssl/src/doc/apps/pkcs12.pod b/src/lib/libssl/src/doc/apps/pkcs12.pod
index 7e0307dda0..7d84146293 100644
--- a/src/lib/libssl/src/doc/apps/pkcs12.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs12.pod
@@ -262,7 +262,7 @@ the one corresponding to the private key. Certain software which requires
262a private key and certificate and assumes the first certificate in the 262a private key and certificate and assumes the first certificate in the
263file is the one corresponding to the private key: this may not always 263file is the one corresponding to the private key: this may not always
264be the case. Using the B<-clcerts> option will solve this problem by only 264be the case. Using the B<-clcerts> option will solve this problem by only
265outputing the certificate corresponding to the private key. If the CA 265outputting the certificate corresponding to the private key. If the CA
266certificates are required then they can be output to a separate file using 266certificates are required then they can be output to a separate file using
267the B<-nokeys -cacerts> options to just output CA certificates. 267the B<-nokeys -cacerts> options to just output CA certificates.
268 268
diff --git a/src/lib/libssl/src/doc/apps/pkcs7.pod b/src/lib/libssl/src/doc/apps/pkcs7.pod
index 4e9bd6e46b..9871c0e0cd 100644
--- a/src/lib/libssl/src/doc/apps/pkcs7.pod
+++ b/src/lib/libssl/src/doc/apps/pkcs7.pod
@@ -78,7 +78,7 @@ The PEM PKCS#7 format uses the header and footer lines:
78 -----BEGIN PKCS7----- 78 -----BEGIN PKCS7-----
79 -----END PKCS7----- 79 -----END PKCS7-----
80 80
81For compatability with some CAs it will also accept: 81For compatibility with some CAs it will also accept:
82 82
83 -----BEGIN CERTIFICATE----- 83 -----BEGIN CERTIFICATE-----
84 -----END CERTIFICATE----- 84 -----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/doc/apps/rand.pod b/src/lib/libssl/src/doc/apps/rand.pod
index cbf8768801..75745ca002 100644
--- a/src/lib/libssl/src/doc/apps/rand.pod
+++ b/src/lib/libssl/src/doc/apps/rand.pod
@@ -15,7 +15,7 @@ I<num>
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17The B<rand> command outputs I<num> pseudo-random bytes after seeding 17The B<rand> command outputs I<num> pseudo-random bytes after seeding
18the random number generater once. As in other B<openssl> command 18the random number generator once. As in other B<openssl> command
19line tools, PRNG seeding uses the file I<$HOME/>B<.rnd> or B<.rnd> 19line tools, PRNG seeding uses the file I<$HOME/>B<.rnd> or B<.rnd>
20in addition to the files given in the B<-rand> option. A new 20in addition to the files given in the B<-rand> option. A new
21I<$HOME>/B<.rnd> or B<.rnd> file will be written back if enough 21I<$HOME>/B<.rnd> or B<.rnd> file will be written back if enough
diff --git a/src/lib/libssl/src/doc/apps/req.pod b/src/lib/libssl/src/doc/apps/req.pod
index a3f54f45a3..10e4e12a5c 100644
--- a/src/lib/libssl/src/doc/apps/req.pod
+++ b/src/lib/libssl/src/doc/apps/req.pod
@@ -3,7 +3,7 @@
3 3
4=head1 NAME 4=head1 NAME
5 5
6req - PKCS#10 certificate and certificate generating utility. 6req - PKCS#10 certificate request and certificate generating utility.
7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
9 9
@@ -15,6 +15,7 @@ B<openssl> B<req>
15[B<-out filename>] 15[B<-out filename>]
16[B<-passout arg>] 16[B<-passout arg>]
17[B<-text>] 17[B<-text>]
18[B<-pubkey>]
18[B<-noout>] 19[B<-noout>]
19[B<-verify>] 20[B<-verify>]
20[B<-modulus>] 21[B<-modulus>]
@@ -28,12 +29,18 @@ B<openssl> B<req>
28[B<-keyout filename>] 29[B<-keyout filename>]
29[B<-[md5|sha1|md2|mdc2]>] 30[B<-[md5|sha1|md2|mdc2]>]
30[B<-config filename>] 31[B<-config filename>]
32[B<-subj arg>]
31[B<-x509>] 33[B<-x509>]
32[B<-days n>] 34[B<-days n>]
35[B<-set_serial n>]
33[B<-asn1-kludge>] 36[B<-asn1-kludge>]
34[B<-newhdr>] 37[B<-newhdr>]
35[B<-extensions section>] 38[B<-extensions section>]
36[B<-reqexts section>] 39[B<-reqexts section>]
40[B<-utf8>]
41[B<-nameopt>]
42[B<-batch>]
43[B<-verbose>]
37 44
38=head1 DESCRIPTION 45=head1 DESCRIPTION
39 46
@@ -82,6 +89,10 @@ see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
82 89
83prints out the certificate request in text form. 90prints out the certificate request in text form.
84 91
92=item B<-pubkey>
93
94outputs the public key.
95
85=item B<-noout> 96=item B<-noout>
86 97
87this option prevents output of the encoded version of the request. 98this option prevents output of the encoded version of the request.
@@ -154,18 +165,33 @@ this allows an alternative configuration file to be specified,
154this overrides the compile time filename or any specified in 165this overrides the compile time filename or any specified in
155the B<OPENSSL_CONF> environment variable. 166the B<OPENSSL_CONF> environment variable.
156 167
168=item B<-subj arg>
169
170sets subject name for new request or supersedes the subject name
171when processing a request.
172The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
173characters may be escaped by \ (backslash), no spaces are skipped.
174
157=item B<-x509> 175=item B<-x509>
158 176
159this option outputs a self signed certificate instead of a certificate 177this option outputs a self signed certificate instead of a certificate
160request. This is typically used to generate a test certificate or 178request. This is typically used to generate a test certificate or
161a self signed root CA. The extensions added to the certificate 179a self signed root CA. The extensions added to the certificate
162(if any) are specified in the configuration file. 180(if any) are specified in the configuration file. Unless specified
181using the B<set_serial> option B<0> will be used for the serial
182number.
163 183
164=item B<-days n> 184=item B<-days n>
165 185
166when the B<-x509> option is being used this specifies the number of 186when the B<-x509> option is being used this specifies the number of
167days to certify the certificate for. The default is 30 days. 187days to certify the certificate for. The default is 30 days.
168 188
189=item B<-set_serial n>
190
191serial number to use when outputting a self signed certificate. This
192may be specified as a decimal value or a hex value if preceded by B<0x>.
193It is possible to use negative serial numbers but this is not recommended.
194
169=item B<-extensions section> 195=item B<-extensions section>
170 196
171=item B<-reqexts section> 197=item B<-reqexts section>
@@ -176,6 +202,20 @@ request extensions. This allows several different sections to
176be used in the same configuration file to specify requests for 202be used in the same configuration file to specify requests for
177a variety of purposes. 203a variety of purposes.
178 204
205=item B<-utf8>
206
207this option causes field values to be interpreted as UTF8 strings, by
208default they are interpreted as ASCII. This means that the field
209values, whether prompted from a terminal or obtained from a
210configuration file, must be valid UTF8 strings.
211
212=item B<-nameopt option>
213
214option which determines how the subject or issuer names are displayed. The
215B<option> argument can be a single option or multiple options separated by
216commas. Alternatively the B<-nameopt> switch may be used more than once to
217set multiple options. See the L<x509(1)|x509(1)> manual page for details.
218
179=item B<-asn1-kludge> 219=item B<-asn1-kludge>
180 220
181by default the B<req> command outputs certificate requests containing 221by default the B<req> command outputs certificate requests containing
@@ -196,6 +236,14 @@ It should be noted that very few CAs still require the use of this option.
196Adds the word B<NEW> to the PEM file header and footer lines on the outputed 236Adds the word B<NEW> to the PEM file header and footer lines on the outputed
197request. Some software (Netscape certificate server) and some CAs need this. 237request. Some software (Netscape certificate server) and some CAs need this.
198 238
239=item B<-batch>
240
241non-interactive mode.
242
243=item B<-verbose>
244
245print extra details about the operations being performed.
246
199=back 247=back
200 248
201=head1 CONFIGURATION FILE FORMAT 249=head1 CONFIGURATION FILE FORMAT
@@ -292,6 +340,13 @@ if set to the value B<no> this disables prompting of certificate fields
292and just takes values from the config file directly. It also changes the 340and just takes values from the config file directly. It also changes the
293expected format of the B<distinguished_name> and B<attributes> sections. 341expected format of the B<distinguished_name> and B<attributes> sections.
294 342
343=item B<utf8>
344
345if set to the value B<yes> then field values to be interpreted as UTF8
346strings, by default they are interpreted as ASCII. This means that
347the field values, whether prompted from a terminal or obtained from a
348configuration file, must be valid UTF8 strings.
349
295=item B<attributes> 350=item B<attributes>
296 351
297this specifies the section containing any request attributes: its format 352this specifies the section containing any request attributes: its format
diff --git a/src/lib/libssl/src/doc/apps/rsa.pod b/src/lib/libssl/src/doc/apps/rsa.pod
index f0e613ed05..ef74f1adff 100644
--- a/src/lib/libssl/src/doc/apps/rsa.pod
+++ b/src/lib/libssl/src/doc/apps/rsa.pod
@@ -136,7 +136,7 @@ and Microsoft IIS .key files, this uses unsalted RC4 for its encryption.
136It is not very secure and so should only be used when necessary. 136It is not very secure and so should only be used when necessary.
137 137
138Some newer version of IIS have additional data in the exported .key 138Some newer version of IIS have additional data in the exported .key
139files. To use thse with the utility view the file with a binary editor 139files. To use these with the utility, view the file with a binary editor
140and look for the string "private-key", then trace back to the byte 140and look for the string "private-key", then trace back to the byte
141sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data 141sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data
142from this point onwards to another file and use that as the input 142from this point onwards to another file and use that as the input
diff --git a/src/lib/libssl/src/doc/apps/s_client.pod b/src/lib/libssl/src/doc/apps/s_client.pod
index 078ff086c3..7fca9cbdbd 100644
--- a/src/lib/libssl/src/doc/apps/s_client.pod
+++ b/src/lib/libssl/src/doc/apps/s_client.pod
@@ -18,6 +18,7 @@ B<openssl> B<s_client>
18[B<-pause>] 18[B<-pause>]
19[B<-showcerts>] 19[B<-showcerts>]
20[B<-debug>] 20[B<-debug>]
21[B<-msg>]
21[B<-nbio_test>] 22[B<-nbio_test>]
22[B<-state>] 23[B<-state>]
23[B<-nbio>] 24[B<-nbio>]
@@ -32,8 +33,8 @@ B<openssl> B<s_client>
32[B<-no_tls1>] 33[B<-no_tls1>]
33[B<-bugs>] 34[B<-bugs>]
34[B<-cipher cipherlist>] 35[B<-cipher cipherlist>]
35[B<-rand file(s)>]
36[B<-engine id>] 36[B<-engine id>]
37[B<-rand file(s)>]
37 38
38=head1 DESCRIPTION 39=head1 DESCRIPTION
39 40
@@ -112,6 +113,10 @@ prints out the SSL session states.
112 113
113print extensive debugging information including a hex dump of all traffic. 114print extensive debugging information including a hex dump of all traffic.
114 115
116=item B<-msg>
117
118show all protocol messages with hex dump.
119
115=item B<-nbio_test> 120=item B<-nbio_test>
116 121
117tests non-blocking I/O 122tests non-blocking I/O
@@ -132,7 +137,7 @@ input.
132 137
133=item B<-quiet> 138=item B<-quiet>
134 139
135inhibit printing of session and certificate information. This implicitely 140inhibit printing of session and certificate information. This implicitly
136turns on B<-ign_eof> as well. 141turns on B<-ign_eof> as well.
137 142
138=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> 143=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
@@ -158,6 +163,13 @@ the server determines which cipher suite is used it should take the first
158supported cipher in the list sent by the client. See the B<ciphers> 163supported cipher in the list sent by the client. See the B<ciphers>
159command for more information. 164command for more information.
160 165
166=item B<-engine id>
167
168specifying an engine (by it's unique B<id> string) will cause B<s_client>
169to attempt to obtain a functional reference to the specified engine,
170thus initialising it if needed. The engine will then be set as the default
171for all available algorithms.
172
161=item B<-rand file(s)> 173=item B<-rand file(s)>
162 174
163a file or files containing random data used to seed the random number 175a file or files containing random data used to seed the random number
@@ -166,13 +178,6 @@ Multiple files can be specified separated by a OS-dependent character.
166The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 178The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
167all others. 179all others.
168 180
169=item B<-engine id>
170
171specifying an engine (by it's unique B<id> string) will cause B<s_client>
172to attempt to obtain a functional reference to the specified engine,
173thus initialising it if needed. The engine will then be set as the default
174for all available algorithms.
175
176=back 181=back
177 182
178=head1 CONNECTED COMMANDS 183=head1 CONNECTED COMMANDS
@@ -180,7 +185,7 @@ for all available algorithms.
180If a connection is established with an SSL server then any data received 185If a connection is established with an SSL server then any data received
181from the server is displayed and any key presses will be sent to the 186from the server is displayed and any key presses will be sent to the
182server. When used interactively (which means neither B<-quiet> nor B<-ign_eof> 187server. When used interactively (which means neither B<-quiet> nor B<-ign_eof>
183have been given), the session will be renegociated if the line begins with an 188have been given), the session will be renegotiated if the line begins with an
184B<R>, and if the line begins with a B<Q> or if end of file is reached, the 189B<R>, and if the line begins with a B<Q> or if end of file is reached, the
185connection will be closed down. 190connection will be closed down.
186 191
diff --git a/src/lib/libssl/src/doc/apps/s_server.pod b/src/lib/libssl/src/doc/apps/s_server.pod
index 313116ab66..4b1e4260ef 100644
--- a/src/lib/libssl/src/doc/apps/s_server.pod
+++ b/src/lib/libssl/src/doc/apps/s_server.pod
@@ -21,6 +21,7 @@ B<openssl> B<s_server>
21[B<-nbio_test>] 21[B<-nbio_test>]
22[B<-crlf>] 22[B<-crlf>]
23[B<-debug>] 23[B<-debug>]
24[B<-msg>]
24[B<-state>] 25[B<-state>]
25[B<-CApath directory>] 26[B<-CApath directory>]
26[B<-CAfile filename>] 27[B<-CAfile filename>]
@@ -39,8 +40,9 @@ B<openssl> B<s_server>
39[B<-hack>] 40[B<-hack>]
40[B<-www>] 41[B<-www>]
41[B<-WWW>] 42[B<-WWW>]
42[B<-rand file(s)>] 43[B<-HTTP>]
43[B<-engine id>] 44[B<-engine id>]
45[B<-rand file(s)>]
44 46
45=head1 DESCRIPTION 47=head1 DESCRIPTION
46 48
@@ -135,6 +137,10 @@ prints out the SSL session states.
135 137
136print extensive debugging information including a hex dump of all traffic. 138print extensive debugging information including a hex dump of all traffic.
137 139
140=item B<-msg>
141
142show all protocol messages with hex dump.
143
138=item B<-nbio_test> 144=item B<-nbio_test>
139 145
140tests non blocking I/O 146tests non blocking I/O
@@ -188,13 +194,13 @@ emulates a simple web server. Pages will be resolved relative to the
188current directory, for example if the URL https://myhost/page.html is 194current directory, for example if the URL https://myhost/page.html is
189requested the file ./page.html will be loaded. 195requested the file ./page.html will be loaded.
190 196
191=item B<-rand file(s)> 197=item B<-HTTP>
192 198
193a file or files containing random data used to seed the random number 199emulates a simple web server. Pages will be resolved relative to the
194generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 200current directory, for example if the URL https://myhost/page.html is
195Multiple files can be specified separated by a OS-dependent character. 201requested the file ./page.html will be loaded. The files loaded are
196The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 202assumed to contain a complete and correct HTTP response (lines that
197all others. 203are part of the HTTP response line and headers must end with CRLF).
198 204
199=item B<-engine id> 205=item B<-engine id>
200 206
@@ -203,6 +209,14 @@ to attempt to obtain a functional reference to the specified engine,
203thus initialising it if needed. The engine will then be set as the default 209thus initialising it if needed. The engine will then be set as the default
204for all available algorithms. 210for all available algorithms.
205 211
212=item B<-rand file(s)>
213
214a file or files containing random data used to seed the random number
215generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
216Multiple files can be specified separated by a OS-dependent character.
217The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
218all others.
219
206=back 220=back
207 221
208=head1 CONNECTED COMMANDS 222=head1 CONNECTED COMMANDS
diff --git a/src/lib/libssl/src/doc/apps/verify.pod b/src/lib/libssl/src/doc/apps/verify.pod
index 90455525d1..ea5c29c150 100644
--- a/src/lib/libssl/src/doc/apps/verify.pod
+++ b/src/lib/libssl/src/doc/apps/verify.pod
@@ -200,13 +200,13 @@ the signature of the certificate is invalid. Unused.
200 200
201the certificate is not yet valid: the notBefore date is after the current time. 201the certificate is not yet valid: the notBefore date is after the current time.
202 202
203=item B<10 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid> 203=item B<10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
204 204
205the CRL is not yet valid. Unused. 205the certificate has expired: that is the notAfter date is before the current time.
206 206
207=item B<11 X509_V_ERR_CERT_HAS_EXPIRED: Certificate has expired> 207=item B<11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
208 208
209the certificate has expired: that is the notAfter date is before the current time. 209the CRL is not yet valid. Unused.
210 210
211=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired> 211=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
212 212
diff --git a/src/lib/libssl/src/doc/apps/version.pod b/src/lib/libssl/src/doc/apps/version.pod
index 5d261a6405..e00324c446 100644
--- a/src/lib/libssl/src/doc/apps/version.pod
+++ b/src/lib/libssl/src/doc/apps/version.pod
@@ -46,6 +46,10 @@ compilation flags.
46 46
47platform setting. 47platform setting.
48 48
49=item B<-d>
50
51OPENSSLDIR setting.
52
49=back 53=back
50 54
51=head1 NOTES 55=head1 NOTES
@@ -53,4 +57,8 @@ platform setting.
53The output of B<openssl version -a> would typically be used when sending 57The output of B<openssl version -a> would typically be used when sending
54in a bug report. 58in a bug report.
55 59
60=head1 HISTORY
61
62The B<-d> option was added in OpenSSL 0.9.7.
63
56=cut 64=cut
diff --git a/src/lib/libssl/src/doc/apps/x509.pod b/src/lib/libssl/src/doc/apps/x509.pod
index 84f76cb421..23367b7659 100644
--- a/src/lib/libssl/src/doc/apps/x509.pod
+++ b/src/lib/libssl/src/doc/apps/x509.pod
@@ -36,6 +36,7 @@ B<openssl> B<x509>
36[B<-addreject arg>] 36[B<-addreject arg>]
37[B<-setalias arg>] 37[B<-setalias arg>]
38[B<-days arg>] 38[B<-days arg>]
39[B<-set_serial n>]
39[B<-signkey filename>] 40[B<-signkey filename>]
40[B<-x509toreq>] 41[B<-x509toreq>]
41[B<-req>] 42[B<-req>]
@@ -112,6 +113,13 @@ prints out the certificate in text form. Full details are output including the
112public key, signature algorithms, issuer and subject names, serial number 113public key, signature algorithms, issuer and subject names, serial number
113any extensions present and any trust settings. 114any extensions present and any trust settings.
114 115
116=item B<-certopt option>
117
118customise the output format used with B<-text>. The B<option> argument can be
119a single option or multiple options separated by commas. The B<-certopt> switch
120may be also be used more than once to set multiple options. See the B<TEXT OPTIONS>
121section for more information.
122
115=item B<-noout> 123=item B<-noout>
116 124
117this option prevents output of the encoded version of the request. 125this option prevents output of the encoded version of the request.
@@ -141,9 +149,10 @@ outputs the issuer name.
141 149
142=item B<-nameopt option> 150=item B<-nameopt option>
143 151
144option which determine how the subject or issuer names are displayed. This 152option which determines how the subject or issuer names are displayed. The
145option may be used more than once to set multiple options. See the B<NAME 153B<option> argument can be a single option or multiple options separated by
146OPTIONS> section for more information. 154commas. Alternatively the B<-nameopt> switch may be used more than once to
155set multiple options. See the B<NAME OPTIONS> section for more information.
147 156
148=item B<-email> 157=item B<-email>
149 158
@@ -163,7 +172,8 @@ prints out the start and expiry dates of a certificate.
163 172
164=item B<-fingerprint> 173=item B<-fingerprint>
165 174
166prints out the digest of the DER encoded version of the whole certificate. 175prints out the digest of the DER encoded version of the whole certificate
176(see digest options).
167 177
168=item B<-C> 178=item B<-C>
169 179
@@ -292,6 +302,16 @@ is used to pass the required private key.
292by default a certificate is expected on input. With this option a 302by default a certificate is expected on input. With this option a
293certificate request is expected instead. 303certificate request is expected instead.
294 304
305=item B<-set_serial n>
306
307specifies the serial number to use. This option can be used with either
308the B<-signkey> or B<-CA> options. If used in conjunction with the B<-CA>
309option the serial number file (as specified by the B<-CAserial> or
310B<-CAcreateserial> options) is not used.
311
312The serial number can be decimal or hex (if preceded by B<0x>). Negative
313serial numbers can also be specified but their use is not recommended.
314
295=item B<-CA filename> 315=item B<-CA filename>
296 316
297specifies the CA certificate to be used for signing. When this option is 317specifies the CA certificate to be used for signing. When this option is
@@ -372,12 +392,12 @@ options.
372=item B<multiline> 392=item B<multiline>
373 393
374a multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>, 394a multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>,
375B<spc_eq> and B<lname>. 395B<spc_eq>, B<lname> and B<align>.
376 396
377=item B<esc_2253> 397=item B<esc_2253>
378 398
379escape the "special" characters required by RFC2253 in a field That is 399escape the "special" characters required by RFC2253 in a field That is
380B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginnging of a string 400B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginning of a string
381and a space character at the beginning or end of a string. 401and a space character at the beginning or end of a string.
382 402
383=item B<esc_ctrl> 403=item B<esc_ctrl>
@@ -431,7 +451,7 @@ B<#XXXX...> format.
431 451
432dump non character string types (for example OCTET STRING) if this 452dump non character string types (for example OCTET STRING) if this
433option is not set then non character string types will be displayed 453option is not set then non character string types will be displayed
434as though each content octet repesents a single character. 454as though each content octet represents a single character.
435 455
436=item B<dump_all> 456=item B<dump_all>
437 457
@@ -467,6 +487,11 @@ not display the field at all. B<sname> uses the "short name" form
467B<oid> represents the OID in numerical form and is useful for 487B<oid> represents the OID in numerical form and is useful for
468diagnostic purpose. 488diagnostic purpose.
469 489
490=item B<align>
491
492align field values for a more readable output. Only usable with
493B<sep_multiline>.
494
470=item B<spc_eq> 495=item B<spc_eq>
471 496
472places spaces round the B<=> character which follows the field 497places spaces round the B<=> character which follows the field
@@ -474,6 +499,87 @@ name.
474 499
475=back 500=back
476 501
502=head1 TEXT OPTIONS
503
504As well as customising the name output format, it is also possible to
505customise the actual fields printed using the B<certopt> options when
506the B<text> option is present. The default behaviour is to print all fields.
507
508=item B<compatible>
509
510use the old format. This is equivalent to specifying no output options at all.
511
512=item B<no_header>
513
514don't print header information: that is the lines saying "Certificate" and "Data".
515
516=item B<no_version>
517
518don't print out the version number.
519
520=item B<no_serial>
521
522don't print out the serial number.
523
524=item B<no_signame>
525
526don't print out the signature algorithm used.
527
528=item B<no_validity>
529
530don't print the validity, that is the B<notBefore> and B<notAfter> fields.
531
532=item B<no_subject>
533
534don't print out the subject name.
535
536=item B<no_issuer>
537
538don't print out the issuer name.
539
540=item B<no_pubkey>
541
542don't print out the public key.
543
544=item B<no_sigdump>
545
546don't give a hexadecimal dump of the certificate signature.
547
548=item B<no_aux>
549
550don't print out certificate trust information.
551
552=item B<no_extensions>
553
554don't print out any X509V3 extensions.
555
556=item B<ext_default>
557
558retain default extension behaviour: attempt to print out unsupported certificate extensions.
559
560=item B<ext_error>
561
562print an error message for unsupported certificate extensions.
563
564=item B<ext_parse>
565
566ASN1 parse unsupported extensions.
567
568=item B<ext_dump>
569
570hex dump unsupported extensions.
571
572=item B<ca_default>
573
574the value used by the B<ca> utility, equivalent to B<no_issuer>, B<no_pubkey>, B<no_header>,
575B<no_version>, B<no_sigdump> and B<no_signame>.
576
577
578
579=over 4
580
581=back
582
477=head1 EXAMPLES 583=head1 EXAMPLES
478 584
479Note: in these examples the '\' means the example should be all on one 585Note: in these examples the '\' means the example should be all on one
@@ -498,7 +604,7 @@ Display the certificate subject name in RFC2253 form:
498Display the certificate subject name in oneline form on a terminal 604Display the certificate subject name in oneline form on a terminal
499supporting UTF8: 605supporting UTF8:
500 606
501 openssl x509 -in cert.pem -noout -subject -nameopt oneline -nameopt -escmsb 607 openssl x509 -in cert.pem -noout -subject -nameopt oneline,-escmsb
502 608
503Display the certificate MD5 fingerprint: 609Display the certificate MD5 fingerprint:
504 610
diff --git a/src/lib/libssl/src/doc/crypto/BIO_f_md.pod b/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
index c32504dfb1..0d24083e6d 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_f_md.pod
@@ -28,7 +28,7 @@ BIO_gets(), if its B<size> parameter is large enough finishes the
28digest calculation and returns the digest value. BIO_puts() is 28digest calculation and returns the digest value. BIO_puts() is
29not supported. 29not supported.
30 30
31BIO_reset() reinitializes a digest BIO. 31BIO_reset() reinitialises a digest BIO.
32 32
33BIO_set_md() sets the message digest of BIO B<b> to B<md>: this 33BIO_set_md() sets the message digest of BIO B<b> to B<md>: this
34must be called to initialize a digest BIO before any data is 34must be called to initialize a digest BIO before any data is
diff --git a/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod b/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
index 2256ba9d34..1a8dbc577b 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_new_bio_pair.pod
@@ -12,7 +12,8 @@ BIO_new_bio_pair - create a new BIO pair
12 12
13=head1 DESCRIPTION 13=head1 DESCRIPTION
14 14
15BIO_new_bio_pair() creates a buffering BIO pair. It has two endpoints between 15BIO_new_bio_pair() creates a buffering BIO pair based on the
16L<SSL_set_bio(3)|SSL_set_bio(3)> method. The BIO pair has two endpoints between which
16data can be buffered. Its typical use is to connect one endpoint as underlying 17data can be buffered. Its typical use is to connect one endpoint as underlying
17input/output BIO to an SSL and access the other one controlled by the program 18input/output BIO to an SSL and access the other one controlled by the program
18instead of accessing the network connection directly. 19instead of accessing the network connection directly.
@@ -38,7 +39,7 @@ without having to go through the SSL-interface.
38 BIO *internal_bio, *network_bio; 39 BIO *internal_bio, *network_bio;
39 ... 40 ...
40 BIO_new_bio_pair(internal_bio, 0, network_bio, 0); 41 BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
41 SSL_set_bio(ssl, internal_bio); 42 SSL_set_bio(ssl, internal_bio, internal_bio);
42 SSL_operations(); 43 SSL_operations();
43 ... 44 ...
44 45
@@ -67,7 +68,7 @@ and must be transfered to the network. Use BIO_ctrl_get_read_request() to
67find out, how many bytes must be written into the buffer before the 68find out, how many bytes must be written into the buffer before the
68SSL_operation() can successfully be continued. 69SSL_operation() can successfully be continued.
69 70
70=head1 IMPORTANT 71=head1 WARNING
71 72
72As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ 73As the data is buffered, SSL_operation() may return with a ERROR_SSL_WANT_READ
73condition, but there is still data in the write buffer. An application must 74condition, but there is still data in the write buffer. An application must
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
index c49da7fb02..55e4b730b9 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_accept.pod
@@ -10,31 +10,31 @@ BIO_get_bind_mode, BIO_do_accept - accept BIO
10 10
11 #include <openssl/bio.h> 11 #include <openssl/bio.h>
12 12
13 BIO_METHOD * BIO_s_accept(void); 13 BIO_METHOD *BIO_s_accept(void);
14 14
15 #define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) 15 long BIO_set_accept_port(BIO *b, char *name);
16 #define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) 16 char *BIO_get_accept_port(BIO *b);
17 17
18 BIO *BIO_new_accept(char *host_port); 18 BIO *BIO_new_accept(char *host_port);
19 19
20 #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) 20 long BIO_set_nbio_accept(BIO *b, int n);
21 #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) 21 long BIO_set_accept_bios(BIO *b, char *bio);
22 22
23 #define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) 23 long BIO_set_bind_mode(BIO *b, long mode);
24 #define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) 24 long BIO_get_bind_mode(BIO *b, long dummy);
25 25
26 #define BIO_BIND_NORMAL 0 26 #define BIO_BIND_NORMAL 0
27 #define BIO_BIND_REUSEADDR_IF_UNUSED 1 27 #define BIO_BIND_REUSEADDR_IF_UNUSED 1
28 #define BIO_BIND_REUSEADDR 2 28 #define BIO_BIND_REUSEADDR 2
29 29
30 #define BIO_do_accept(b) BIO_do_handshake(b) 30 int BIO_do_accept(BIO *b);
31 31
32=head1 DESCRIPTION 32=head1 DESCRIPTION
33 33
34BIO_s_accept() returns the accept BIO method. This is a wrapper 34BIO_s_accept() returns the accept BIO method. This is a wrapper
35round the platform's TCP/IP socket accept routines. 35round the platform's TCP/IP socket accept routines.
36 36
37Using accept BIOs TCP/IP connections can be accepted and data 37Using accept BIOs, TCP/IP connections can be accepted and data
38transferred using only BIO routines. In this way any platform 38transferred using only BIO routines. In this way any platform
39specific operations are hidden by the BIO abstraction. 39specific operations are hidden by the BIO abstraction.
40 40
@@ -92,7 +92,7 @@ BIO_do_accept() serves two functions. When it is first
92called, after the accept BIO has been setup, it will attempt 92called, after the accept BIO has been setup, it will attempt
93to create the accept socket and bind an address to it. Second 93to create the accept socket and bind an address to it. Second
94and subsequent calls to BIO_do_accept() will await an incoming 94and subsequent calls to BIO_do_accept() will await an incoming
95connection. 95connection, or request a retry in non blocking mode.
96 96
97=head1 NOTES 97=head1 NOTES
98 98
@@ -130,6 +130,17 @@ however because the accept BIO will still accept additional incoming
130connections. This can be resolved by using BIO_pop() (see above) 130connections. This can be resolved by using BIO_pop() (see above)
131and freeing up the accept BIO after the initial connection. 131and freeing up the accept BIO after the initial connection.
132 132
133If the underlying accept socket is non-blocking and BIO_do_accept() is
134called to await an incoming connection it is possible for
135BIO_should_io_special() with the reason BIO_RR_ACCEPT. If this happens
136then it is an indication that an accept attempt would block: the application
137should take appropriate action to wait until the underlying socket has
138accepted a connection and retry the call.
139
140BIO_set_accept_port(), BIO_get_accept_port(), BIO_set_nbio_accept(),
141BIO_set_accept_bios(), BIO_set_bind_mode(), BIO_get_bind_mode() and
142BIO_do_accept() are macros.
143
133=head1 RETURN VALUES 144=head1 RETURN VALUES
134 145
135TBA 146TBA
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod b/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
index fe1aa679d4..bcf7d8dcac 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_connect.pod
@@ -13,25 +13,27 @@ BIO_set_nbio, BIO_do_connect - connect BIO
13 13
14 BIO_METHOD * BIO_s_connect(void); 14 BIO_METHOD * BIO_s_connect(void);
15 15
16 #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) 16 BIO *BIO_new_connect(char *name);
17 #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
18 #define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
19 #define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
20 #define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
21 #define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
22 #define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2)
23 #define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port)
24 17
25 #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 18 long BIO_set_conn_hostname(BIO *b, char *name);
19 long BIO_set_conn_port(BIO *b, char *port);
20 long BIO_set_conn_ip(BIO *b, char *ip);
21 long BIO_set_conn_int_port(BIO *b, char *port);
22 char *BIO_get_conn_hostname(BIO *b);
23 char *BIO_get_conn_port(BIO *b);
24 char *BIO_get_conn_ip(BIO *b, dummy);
25 long BIO_get_conn_int_port(BIO *b, int port);
26 26
27 #define BIO_do_connect(b) BIO_do_handshake(b) 27 long BIO_set_nbio(BIO *b, long n);
28
29 int BIO_do_connect(BIO *b);
28 30
29=head1 DESCRIPTION 31=head1 DESCRIPTION
30 32
31BIO_s_connect() returns the connect BIO method. This is a wrapper 33BIO_s_connect() returns the connect BIO method. This is a wrapper
32round the platform's TCP/IP socket connection routines. 34round the platform's TCP/IP socket connection routines.
33 35
34Using connect BIOs TCP/IP connections can be made and data 36Using connect BIOs, TCP/IP connections can be made and data
35transferred using only BIO routines. In this way any platform 37transferred using only BIO routines. In this way any platform
36specific operations are hidden by the BIO abstraction. 38specific operations are hidden by the BIO abstraction.
37 39
@@ -54,7 +56,7 @@ BIO_get_fd() places the underlying socket in B<c> if it is not NULL,
54it also returns the socket . If B<c> is not NULL it should be of 56it also returns the socket . If B<c> is not NULL it should be of
55type (int *). 57type (int *).
56 58
57BIO_set_conn_hostname() uses the string B<name> to set the hostname 59BIO_set_conn_hostname() uses the string B<name> to set the hostname.
58The hostname can be an IP address. The hostname can also include the 60The hostname can be an IP address. The hostname can also include the
59port in the form hostname:port . It is also acceptable to use the 61port in the form hostname:port . It is also acceptable to use the
60form "hostname/any/other/path" or "hostname:port/any/other/path". 62form "hostname/any/other/path" or "hostname:port/any/other/path".
@@ -87,6 +89,9 @@ is set. Blocking I/O is the default. The call to BIO_set_nbio()
87should be made before the connection is established because 89should be made before the connection is established because
88non blocking I/O is set during the connect process. 90non blocking I/O is set during the connect process.
89 91
92BIO_new_connect() combines BIO_new() and BIO_set_conn_hostname() into
93a single call: that is it creates a new connect BIO with B<name>.
94
90BIO_do_connect() attempts to connect the supplied BIO. It returns 1 95BIO_do_connect() attempts to connect the supplied BIO. It returns 1
91if the connection was established successfully. A zero or negative 96if the connection was established successfully. A zero or negative
92value is returned if the connection could not be established, the 97value is returned if the connection could not be established, the
@@ -123,6 +128,11 @@ then this is an indication that a connection attempt would block,
123the application should then take appropriate action to wait until 128the application should then take appropriate action to wait until
124the underlying socket has connected and retry the call. 129the underlying socket has connected and retry the call.
125 130
131BIO_set_conn_hostname(), BIO_set_conn_port(), BIO_set_conn_ip(),
132BIO_set_conn_int_port(), BIO_get_conn_hostname(), BIO_get_conn_port(),
133BIO_get_conn_ip(), BIO_get_conn_int_port(), BIO_set_nbio() and
134BIO_do_connect() are macros.
135
126=head1 RETURN VALUES 136=head1 RETURN VALUES
127 137
128BIO_s_connect() returns the connect BIO method. 138BIO_s_connect() returns the connect BIO method.
diff --git a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod b/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
index 253185185c..1c8d3a9110 100644
--- a/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
+++ b/src/lib/libssl/src/doc/crypto/BIO_s_socket.pod
@@ -8,10 +8,10 @@ BIO_s_socket, BIO_new_socket - socket BIO
8 8
9 #include <openssl/bio.h> 9 #include <openssl/bio.h>
10 10
11 BIO_METHOD * BIO_s_socket(void); 11 BIO_METHOD *BIO_s_socket(void);
12 12
13 #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) 13 long BIO_set_fd(BIO *b, int fd, long close_flag);
14 #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) 14 long BIO_get_fd(BIO *b, int *c);
15 15
16 BIO *BIO_new_socket(int sock, int close_flag); 16 BIO *BIO_new_socket(int sock, int close_flag);
17 17
@@ -27,10 +27,10 @@ If the close flag is set then the socket is shut down and closed
27when the BIO is freed. 27when the BIO is freed.
28 28
29BIO_set_fd() sets the socket of BIO B<b> to B<fd> and the close 29BIO_set_fd() sets the socket of BIO B<b> to B<fd> and the close
30flag to B<c>. 30flag to B<close_flag>.
31 31
32BIO_get_fd() places the socket in B<c> if it is not NULL, it also 32BIO_get_fd() places the socket in B<c> if it is not NULL, it also
33returns the socket . If B<c> is not NULL it should be of type (int *). 33returns the socket. If B<c> is not NULL it should be of type (int *).
34 34
35BIO_new_socket() returns a socket BIO using B<sock> and B<close_flag>. 35BIO_new_socket() returns a socket BIO using B<sock> and B<close_flag>.
36 36
@@ -44,6 +44,8 @@ platforms sockets are not file descriptors and use distinct I/O routines,
44Windows is one such platform. Any code mixing the two will not work on 44Windows is one such platform. Any code mixing the two will not work on
45all platforms. 45all platforms.
46 46
47BIO_set_fd() and BIO_get_fd() are macros.
48
47=head1 RETURN VALUES 49=head1 RETURN VALUES
48 50
49BIO_s_socket() returns the socket BIO method. 51BIO_s_socket() returns the socket BIO method.
diff --git a/src/lib/libssl/src/doc/crypto/BN_add.pod b/src/lib/libssl/src/doc/crypto/BN_add.pod
index 7baed2d492..88c7a799ee 100644
--- a/src/lib/libssl/src/doc/crypto/BN_add.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_add.pod
@@ -2,8 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul, BN_exp, 5BN_add, BN_sub, BN_mul, BN_sqr, BN_div, BN_mod, BN_nnmod, BN_mod_add,
6BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs 6BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_exp, BN_mod_exp, BN_gcd -
7arithmetic operations on BIGNUMs
7 8
8=head1 SYNOPSIS 9=head1 SYNOPSIS
9 10
@@ -15,16 +16,26 @@ BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs
15 16
16 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 17 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
17 18
19 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
20
18 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, 21 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
19 BN_CTX *ctx); 22 BN_CTX *ctx);
20 23
21 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
22
23 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 24 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
24 25
25 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, 26 int BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
27
28 int BN_mod_add(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
29 BN_CTX *ctx);
30
31 int BN_mod_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
32 BN_CTX *ctx);
33
34 int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
26 BN_CTX *ctx); 35 BN_CTX *ctx);
27 36
37 int BN_mod_sqr(BIGNUM *r, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
38
28 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); 39 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
29 40
30 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 41 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
@@ -34,45 +45,59 @@ BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs
34 45
35=head1 DESCRIPTION 46=head1 DESCRIPTION
36 47
37BN_add() adds B<a> and B<b> and places the result in B<r> (C<r=a+b>). 48BN_add() adds I<a> and I<b> and places the result in I<r> (C<r=a+b>).
38B<r> may be the same B<BIGNUM> as B<a> or B<b>. 49I<r> may be the same B<BIGNUM> as I<a> or I<b>.
39 50
40BN_sub() subtracts B<b> from B<a> and places the result in B<r> (C<r=a-b>). 51BN_sub() subtracts I<b> from I<a> and places the result in I<r> (C<r=a-b>).
41 52
42BN_mul() multiplies B<a> and B<b> and places the result in B<r> (C<r=a*b>). 53BN_mul() multiplies I<a> and I<b> and places the result in I<r> (C<r=a*b>).
43B<r> may be the same B<BIGNUM> as B<a> or B<b>. 54I<r> may be the same B<BIGNUM> as I<a> or I<b>.
44For multiplication by powers of 2, use L<BN_lshift(3)|BN_lshift(3)>. 55For multiplication by powers of 2, use L<BN_lshift(3)|BN_lshift(3)>.
45 56
46BN_div() divides B<a> by B<d> and places the result in B<dv> and the 57BN_sqr() takes the square of I<a> and places the result in I<r>
47remainder in B<rem> (C<dv=a/d, rem=a%d>). Either of B<dv> and B<rem> may 58(C<r=a^2>). I<r> and I<a> may be the same B<BIGNUM>.
48be NULL, in which case the respective value is not returned. 59This function is faster than BN_mul(r,a,a).
60
61BN_div() divides I<a> by I<d> and places the result in I<dv> and the
62remainder in I<rem> (C<dv=a/d, rem=a%d>). Either of I<dv> and I<rem> may
63be B<NULL>, in which case the respective value is not returned.
64The result is rounded towards zero; thus if I<a> is negative, the
65remainder will be zero or negative.
49For division by powers of 2, use BN_rshift(3). 66For division by powers of 2, use BN_rshift(3).
50 67
51BN_sqr() takes the square of B<a> and places the result in B<r> 68BN_mod() corresponds to BN_div() with I<dv> set to B<NULL>.
52(C<r=a^2>). B<r> and B<a> may be the same B<BIGNUM>. 69
53This function is faster than BN_mul(r,a,a). 70BN_nnmod() reduces I<a> modulo I<m> and places the non-negative
71remainder in I<r>.
72
73BN_mod_add() adds I<a> to I<b> modulo I<m> and places the non-negative
74result in I<r>.
75
76BN_mod_sub() subtracts I<b> from I<a> modulo I<m> and places the
77non-negative result in I<r>.
54 78
55BN_mod() find the remainder of B<a> divided by B<m> and places it in 79BN_mod_mul() multiplies I<a> by I<b> and finds the non-negative
56B<rem> (C<rem=a%m>). 80remainder respective to modulus I<m> (C<r=(a*b) mod m>). I<r> may be
81the same B<BIGNUM> as I<a> or I<b>. For more efficient algorithms for
82repeated computations using the same modulus, see
83L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)> and
84L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>.
57 85
58BN_mod_mul() multiplies B<a> by B<b> and finds the remainder when 86BN_mod_sqr() takes the square of I<a> modulo B<m> and places the
59divided by B<m> (C<r=(a*b)%m>). B<r> may be the same B<BIGNUM> as B<a> 87result in I<r>.
60or B<b>. For a more efficient algorithm, see
61L<BN_mod_mul_montgomery(3)|BN_mod_mul_montgomery(3)>; for repeated
62computations using the same modulus, see L<BN_mod_mul_reciprocal(3)|BN_mod_mul_reciprocal(3)>.
63 88
64BN_exp() raises B<a> to the B<p>-th power and places the result in B<r> 89BN_exp() raises I<a> to the I<p>-th power and places the result in I<r>
65(C<r=a^p>). This function is faster than repeated applications of 90(C<r=a^p>). This function is faster than repeated applications of
66BN_mul(). 91BN_mul().
67 92
68BN_mod_exp() computes B<a> to the B<p>-th power modulo B<m> (C<r=a^p % 93BN_mod_exp() computes I<a> to the I<p>-th power modulo I<m> (C<r=a^p %
69m>). This function uses less time and space than BN_exp(). 94m>). This function uses less time and space than BN_exp().
70 95
71BN_gcd() computes the greatest common divisor of B<a> and B<b> and 96BN_gcd() computes the greatest common divisor of I<a> and I<b> and
72places the result in B<r>. B<r> may be the same B<BIGNUM> as B<a> or 97places the result in I<r>. I<r> may be the same B<BIGNUM> as I<a> or
73B<b>. 98I<b>.
74 99
75For all functions, B<ctx> is a previously allocated B<BN_CTX> used for 100For all functions, I<ctx> is a previously allocated B<BN_CTX> used for
76temporary variables; see L<BN_CTX_new(3)|BN_CTX_new(3)>. 101temporary variables; see L<BN_CTX_new(3)|BN_CTX_new(3)>.
77 102
78Unless noted otherwise, the result B<BIGNUM> must be different from 103Unless noted otherwise, the result B<BIGNUM> must be different from
@@ -91,9 +116,11 @@ L<BN_add_word(3)|BN_add_word(3)>, L<BN_set_bit(3)|BN_set_bit(3)>
91 116
92=head1 HISTORY 117=head1 HISTORY
93 118
94BN_add(), BN_sub(), BN_div(), BN_sqr(), BN_mod(), BN_mod_mul(), 119BN_add(), BN_sub(), BN_sqr(), BN_div(), BN_mod(), BN_mod_mul(),
95BN_mod_exp() and BN_gcd() are available in all versions of SSLeay and 120BN_mod_exp() and BN_gcd() are available in all versions of SSLeay and
96OpenSSL. The B<ctx> argument to BN_mul() was added in SSLeay 121OpenSSL. The I<ctx> argument to BN_mul() was added in SSLeay
970.9.1b. BN_exp() appeared in SSLeay 0.9.0. 1220.9.1b. BN_exp() appeared in SSLeay 0.9.0.
123BN_nnmod(), BN_mod_add(), BN_mod_sub(), and BN_mod_sqr() were added in
124OpenSSL 0.9.7.
98 125
99=cut 126=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
index 4f78574ed0..a4b17ca60a 100644
--- a/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_bn2bin.pod
@@ -49,7 +49,7 @@ with a leading '-' for negative numbers, to the B<BIO> or B<FILE>
49B<fp>. 49B<fp>.
50 50
51BN_bn2mpi() and BN_mpi2bn() convert B<BIGNUM>s from and to a format 51BN_bn2mpi() and BN_mpi2bn() convert B<BIGNUM>s from and to a format
52that consists of the number's length in bytes represented as a 3-byte 52that consists of the number's length in bytes represented as a 4-byte
53big-endian number, and the number itself in big-endian format, where 53big-endian number, and the number itself in big-endian format, where
54the most significant bit signals a negative number (the representation 54the most significant bit signals a negative number (the representation
55of numbers with the MSB set is prefixed with null byte). 55of numbers with the MSB set is prefixed with null byte).
diff --git a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
index f3cee924b9..6b16351b92 100644
--- a/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_mod_mul_montgomery.pod
@@ -36,22 +36,23 @@ using the same modulus.
36BN_MONT_CTX_new() allocates and initializes a B<BN_MONT_CTX> structure. 36BN_MONT_CTX_new() allocates and initializes a B<BN_MONT_CTX> structure.
37BN_MONT_CTX_init() initializes an existing uninitialized B<BN_MONT_CTX>. 37BN_MONT_CTX_init() initializes an existing uninitialized B<BN_MONT_CTX>.
38 38
39BN_MONT_CTX_set() sets up the B<mont> structure from the modulus B<m> 39BN_MONT_CTX_set() sets up the I<mont> structure from the modulus I<m>
40by precomputing its inverse and a value R. 40by precomputing its inverse and a value R.
41 41
42BN_MONT_CTX_copy() copies the B<BN_MONT_CTX> B<from> to B<to>. 42BN_MONT_CTX_copy() copies the B<BN_MONT_CTX> I<from> to I<to>.
43 43
44BN_MONT_CTX_free() frees the components of the B<BN_MONT_CTX>, and, if 44BN_MONT_CTX_free() frees the components of the B<BN_MONT_CTX>, and, if
45it was created by BN_MONT_CTX_new(), also the structure itself. 45it was created by BN_MONT_CTX_new(), also the structure itself.
46 46
47BN_mod_mul_montgomery() computes Mont(B<a>,B<b>):=B<a>*B<b>*R^-1 and places 47BN_mod_mul_montgomery() computes Mont(I<a>,I<b>):=I<a>*I<b>*R^-1 and places
48the result in B<r>. 48the result in I<r>.
49 49
50BN_from_montgomery() performs the Montgomery reduction B<r> = B<a>*R^-1. 50BN_from_montgomery() performs the Montgomery reduction I<r> = I<a>*R^-1.
51 51
52BN_to_montgomery() computes Mont(B<a>,R^2), i.e. B<a>*R. 52BN_to_montgomery() computes Mont(I<a>,R^2), i.e. I<a>*R.
53Note that I<a> must be non-negative and smaller than the modulus.
53 54
54For all functions, B<ctx> is a previously allocated B<BN_CTX> used for 55For all functions, I<ctx> is a previously allocated B<BN_CTX> used for
55temporary variables. 56temporary variables.
56 57
57The B<BN_MONT_CTX> structure is defined as follows: 58The B<BN_MONT_CTX> structure is defined as follows:
@@ -79,6 +80,11 @@ BN_MONT_CTX_init() and BN_MONT_CTX_free() have no return values.
79For the other functions, 1 is returned for success, 0 on error. 80For the other functions, 1 is returned for success, 0 on error.
80The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. 81The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
81 82
83=head1 WARNING
84
85The inputs must be reduced modulo B<m>, otherwise the result will be
86outside the expected range.
87
82=head1 SEE ALSO 88=head1 SEE ALSO
83 89
84L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>, 90L<bn(3)|bn(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<BN_add(3)|BN_add(3)>,
diff --git a/src/lib/libssl/src/doc/crypto/BN_rand.pod b/src/lib/libssl/src/doc/crypto/BN_rand.pod
index 5406552ba4..18301a396a 100644
--- a/src/lib/libssl/src/doc/crypto/BN_rand.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_rand.pod
@@ -14,6 +14,8 @@ BN_rand, BN_pseudo_rand - generate pseudo-random number
14 14
15 int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 15 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
16 16
17 int BN_pseudo_rand_range(BIGNUM *rnd, int bits, int top, int bottom);
18
17=head1 DESCRIPTION 19=head1 DESCRIPTION
18 20
19BN_rand() generates a cryptographically strong pseudo-random number of 21BN_rand() generates a cryptographically strong pseudo-random number of
@@ -31,6 +33,8 @@ protocols, but usually not for key generation etc.
31 33
32BN_rand_range() generates a cryptographically strong pseudo-random 34BN_rand_range() generates a cryptographically strong pseudo-random
33number B<rnd> in the range 0 <lt>= B<rnd> E<lt> B<range>. 35number B<rnd> in the range 0 <lt>= B<rnd> E<lt> B<range>.
36BN_pseudo_rand_range() does the same, but is based on BN_pseudo_rand(),
37and hence numbers generated by it are not necessarily unpredictable.
34 38
35The PRNG must be seeded prior to calling BN_rand() or BN_rand_range(). 39The PRNG must be seeded prior to calling BN_rand() or BN_rand_range().
36 40
@@ -49,5 +53,6 @@ L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)>
49BN_rand() is available in all versions of SSLeay and OpenSSL. 53BN_rand() is available in all versions of SSLeay and OpenSSL.
50BN_pseudo_rand() was added in OpenSSL 0.9.5. The B<top> == -1 case 54BN_pseudo_rand() was added in OpenSSL 0.9.5. The B<top> == -1 case
51and the function BN_rand_range() were added in OpenSSL 0.9.6a. 55and the function BN_rand_range() were added in OpenSSL 0.9.6a.
56BN_pseudo_rand_range() was added in OpenSSL 0.9.6c.
52 57
53=cut 58=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_swap.pod b/src/lib/libssl/src/doc/crypto/BN_swap.pod
new file mode 100644
index 0000000000..79efaa1446
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/BN_swap.pod
@@ -0,0 +1,23 @@
1=pod
2
3=head1 NAME
4
5BN_swap - exchange BIGNUMs
6
7=head1 SYNOPSIS
8
9 #include <openssl/bn.h>
10
11 void BN_swap(BIGNUM *a, BIGNUM *b);
12
13=head1 DESCRIPTION
14
15BN_swap() exchanges the values of I<a> and I<b>.
16
17L<bn(3)|bn(3)>
18
19=head1 HISTORY
20
21BN_swap was added in OpenSSL 0.9.7.
22
23=cut
diff --git a/src/lib/libssl/src/doc/crypto/BN_zero.pod b/src/lib/libssl/src/doc/crypto/BN_zero.pod
index 2f33876498..3c64a65697 100644
--- a/src/lib/libssl/src/doc/crypto/BN_zero.pod
+++ b/src/lib/libssl/src/doc/crypto/BN_zero.pod
@@ -12,7 +12,7 @@ operations
12 int BN_zero(BIGNUM *a); 12 int BN_zero(BIGNUM *a);
13 int BN_one(BIGNUM *a); 13 int BN_one(BIGNUM *a);
14 14
15 BIGNUM *BN_value_one(void); 15 const BIGNUM *BN_value_one(void);
16 16
17 int BN_set_word(BIGNUM *a, unsigned long w); 17 int BN_set_word(BIGNUM *a, unsigned long w);
18 unsigned long BN_get_word(BIGNUM *a); 18 unsigned long BN_get_word(BIGNUM *a);
diff --git a/src/lib/libssl/src/doc/crypto/DH_set_method.pod b/src/lib/libssl/src/doc/crypto/DH_set_method.pod
index 62088eea1b..d990bf8786 100644
--- a/src/lib/libssl/src/doc/crypto/DH_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/DSA_set_method.pod b/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
index c56dfd0f47..36a1052d27 100644
--- a/src/lib/libssl/src/doc/crypto/DSA_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/ERR_get_error.pod b/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
index 3551bacb8d..9fdedbcb91 100644
--- a/src/lib/libssl/src/doc/crypto/ERR_get_error.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_BytesToKey.pod b/src/lib/libssl/src/doc/crypto/EVP_BytesToKey.pod
new file mode 100644
index 0000000000..5ce4add082
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_DigestInit.pod b/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
index fefc858f7e..acd4d0167a 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_DigestInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_EncryptInit.pod b/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
index 9afe2396e2..371b6a2287 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_EncryptInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_SignInit.pod b/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod
index d5ce245ecd..b1ac129430 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_SignInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/EVP_VerifyInit.pod b/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod
index 736a0f4a82..80c656fde8 100644
--- a/src/lib/libssl/src/doc/crypto/EVP_VerifyInit.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod b/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
index 68ea723259..c39ac35e78 100644
--- a/src/lib/libssl/src/doc/crypto/OPENSSL_VERSION_NUMBER.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/RAND_egd.pod b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
index 71cab3ca04..62adbe19b2 100644
--- a/src/lib/libssl/src/doc/crypto/RAND_egd.pod
+++ b/src/lib/libssl/src/doc/crypto/RAND_egd.pod
@@ -11,6 +11,8 @@ RAND_egd - query entropy gathering daemon
11 int RAND_egd(const char *path); 11 int RAND_egd(const char *path);
12 int RAND_egd_bytes(const char *path, int bytes); 12 int RAND_egd_bytes(const char *path, int bytes);
13 13
14 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
15
14=head1 DESCRIPTION 16=head1 DESCRIPTION
15 17
16RAND_egd() queries the entropy gathering daemon EGD on socket B<path>. 18RAND_egd() queries the entropy gathering daemon EGD on socket B<path>.
@@ -27,6 +29,11 @@ be generated, it is not necessary to request the full amount 255 bytes from
27the EGD socket. This can be advantageous, since the amount of entropy 29the EGD socket. This can be advantageous, since the amount of entropy
28that can be retrieved from EGD over time is limited. 30that can be retrieved from EGD over time is limited.
29 31
32RAND_query_egd_bytes() performs the actual query of the EGD daemon on socket
33B<path>. If B<buf> is given, B<bytes> bytes are queried and written into
34B<buf>. If B<buf> is NULL, B<bytes> bytes are queried and used to seed the
35OpenSSL built-in PRNG using L<RAND_add(3)|RAND_add(3)>.
36
30=head1 NOTES 37=head1 NOTES
31 38
32On systems without /dev/*random devices providing entropy from the kernel, 39On systems without /dev/*random devices providing entropy from the kernel,
@@ -47,12 +54,19 @@ http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/prngd.html .
47PRNGD does employ an internal PRNG itself and can therefore never run 54PRNGD does employ an internal PRNG itself and can therefore never run
48out of entropy. 55out of entropy.
49 56
57OpenSSL automatically queries EGD when entropy is requested via RAND_bytes()
58or the status is checked via RAND_status() for the first time, if the socket
59is located at /var/run/egd-pool, /dev/egd-pool or /etc/egd-pool.
60
50=head1 RETURN VALUE 61=head1 RETURN VALUE
51 62
52RAND_egd() and RAND_egd_bytes() return the number of bytes read from the 63RAND_egd() and RAND_egd_bytes() return the number of bytes read from the
53daemon on success, and -1 if the connection failed or the daemon did not 64daemon on success, and -1 if the connection failed or the daemon did not
54return enough data to fully seed the PRNG. 65return enough data to fully seed the PRNG.
55 66
67RAND_query_egd_bytes() returns the number of bytes read from the daemon on
68success, and -1 if the connection failed. The PRNG state is not considered.
69
56=head1 SEE ALSO 70=head1 SEE ALSO
57 71
58L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, 72L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>,
@@ -64,4 +78,8 @@ RAND_egd() is available since OpenSSL 0.9.5.
64 78
65RAND_egd_bytes() is available since OpenSSL 0.9.6. 79RAND_egd_bytes() is available since OpenSSL 0.9.6.
66 80
81RAND_query_egd_bytes() is available since OpenSSL 0.9.7.
82
83The automatic query of /var/run/egd-pool et al was added in OpenSSL 0.9.7.
84
67=cut 85=cut
diff --git a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod b/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
index 0e0f0a764c..11bc0b3459 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_generate_key.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/RSA_public_encrypt.pod b/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
index 23861c0004..8022a23f99 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_public_encrypt.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/RSA_set_method.pod b/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
index b672712292..14917dd35f 100644
--- a/src/lib/libssl/src/doc/crypto/RSA_set_method.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/blowfish.pod b/src/lib/libssl/src/doc/crypto/blowfish.pod
index 65b8be388c..ed71334f56 100644
--- a/src/lib/libssl/src/doc/crypto/blowfish.pod
+++ b/src/lib/libssl/src/doc/crypto/blowfish.pod
@@ -27,7 +27,7 @@ BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blowfish encryption
27 27
28=head1 DESCRIPTION 28=head1 DESCRIPTION
29 29
30This library implements the Blowfish cipher, which is invented and described 30This library implements the Blowfish cipher, which was invented and described
31by Counterpane (see http://www.counterpane.com/blowfish.html ). 31by Counterpane (see http://www.counterpane.com/blowfish.html ).
32 32
33Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. 33Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data.
@@ -57,7 +57,7 @@ for the same message. B<ivec> may be initialized with anything, but the
57recipient needs to know what it was initialized with, or it won't be able 57recipient needs to know what it was initialized with, or it won't be able
58to decrypt. Some programs and protocols simplify this, like SSH, where 58to decrypt. Some programs and protocols simplify this, like SSH, where
59B<ivec> is simply initialized to zero. 59B<ivec> is simply initialized to zero.
60BF_cbc_encrypt() operates of data that is a multiple of 8 bytes long, while 60BF_cbc_encrypt() operates on data that is a multiple of 8 bytes long, while
61BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable 61BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt an variable
62number of bytes (the amount does not have to be an exact multiple of 8). The 62number of bytes (the amount does not have to be an exact multiple of 8). The
63purpose of the latter two is to simulate stream ciphers, and therefore, they 63purpose of the latter two is to simulate stream ciphers, and therefore, they
diff --git a/src/lib/libssl/src/doc/crypto/bn.pod b/src/lib/libssl/src/doc/crypto/bn.pod
index d183028d61..210dfeac08 100644
--- a/src/lib/libssl/src/doc/crypto/bn.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/bn_internal.pod b/src/lib/libssl/src/doc/crypto/bn_internal.pod
index 8da244aed4..d6f3cfe2ee 100644
--- a/src/lib/libssl/src/doc/crypto/bn_internal.pod
+++ b/src/lib/libssl/src/doc/crypto/bn_internal.pod
@@ -34,9 +34,9 @@ library internal functions
34 int nb); 34 int nb);
35 void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); 35 void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
36 void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, 36 void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
37 BN_ULONG *tmp); 37 int dna,int dnb,BN_ULONG *tmp);
38 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, 38 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
39 int tn, int n, BN_ULONG *tmp); 39 int n, int tna,int tnb, BN_ULONG *tmp);
40 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, 40 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
41 int n2, BN_ULONG *tmp); 41 int n2, BN_ULONG *tmp);
42 void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, 42 void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l,
@@ -152,14 +152,15 @@ bn_mul_low_normal(B<r>, B<a>, B<b>, B<n>) operates on the B<n> word
152arrays B<r>, B<a> and B<b>. It computes the B<n> low words of 152arrays B<r>, B<a> and B<b>. It computes the B<n> low words of
153B<a>*B<b> and places the result in B<r>. 153B<a>*B<b> and places the result in B<r>.
154 154
155bn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<t>) operates on the B<n2> 155bn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<dna>, B<dnb>, B<t>) operates
156word arrays B<a> and B<b> and the 2*B<n2> word arrays B<r> and B<t>. 156on the word arrays B<a> and B<b> of length B<n2>+B<dna> and B<n2>+B<dnb>
157B<n2> must be a power of 2. It computes B<a>*B<b> and places the 157(B<dna> and B<dnb> are currently allowed to be 0 or negative) and the 2*B<n2>
158result in B<r>. 158word arrays B<r> and B<t>. B<n2> must be a power of 2. It computes
159B<a>*B<b> and places the result in B<r>.
159 160
160bn_mul_part_recursive(B<r>, B<a>, B<b>, B<tn>, B<n>, B<tmp>) operates 161bn_mul_part_recursive(B<r>, B<a>, B<b>, B<n>, B<tna>, B<tnb, B<tmp>)
161on the B<n>+B<tn> word arrays B<a> and B<b> and the 4*B<n> word arrays 162operates on the word arrays B<a> and B<b> of length B<n>+B<tna> and
162B<r> and B<tmp>. 163B<n>+B<tnb> and the 4*B<n> word arrays B<r> and B<tmp>.
163 164
164bn_mul_low_recursive(B<r>, B<a>, B<b>, B<n2>, B<tmp>) operates on the 165bn_mul_low_recursive(B<r>, B<a>, B<b>, B<n2>, B<tmp>) operates on the
165B<n2> word arrays B<r> and B<tmp> and the B<n2>/2 word arrays B<a> 166B<n2> word arrays B<r> and B<tmp> and the B<n2>/2 word arrays B<a>
diff --git a/src/lib/libssl/src/doc/crypto/crypto.pod b/src/lib/libssl/src/doc/crypto/crypto.pod
index 07ba7e5bc9..c12eec1409 100644
--- a/src/lib/libssl/src/doc/crypto/crypto.pod
+++ b/src/lib/libssl/src/doc/crypto/crypto.pod
@@ -46,7 +46,8 @@ L<sha(3)|sha(3)>
46 46
47=item AUXILIARY FUNCTIONS 47=item AUXILIARY FUNCTIONS
48 48
49L<err(3)|err(3)>, L<threads(3)|threads(3)>, L<rand(3)|rand(3)> 49L<err(3)|err(3)>, L<threads(3)|threads(3)>, L<rand(3)|rand(3)>,
50L<OPENSSL_VERSION_NUMBER(3)|OPENSSL_VERSION_NUMBER(3)>
50 51
51=item INPUT/OUTPUT, DATA ENCODING 52=item INPUT/OUTPUT, DATA ENCODING
52 53
diff --git a/src/lib/libssl/src/doc/crypto/des.pod b/src/lib/libssl/src/doc/crypto/des.pod
index 99080391b1..528c73acac 100644
--- a/src/lib/libssl/src/doc/crypto/des.pod
+++ b/src/lib/libssl/src/doc/crypto/des.pod
@@ -2,113 +2,105 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5des_random_key, des_set_key, des_key_sched, des_set_key_checked, 5DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked,
6des_set_key_unchecked, des_set_odd_parity, des_is_weak_key, 6DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key,
7des_ecb_encrypt, des_ecb2_encrypt, des_ecb3_encrypt, des_ncbc_encrypt, 7DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt,
8des_cfb_encrypt, des_ofb_encrypt, des_pcbc_encrypt, des_cfb64_encrypt, 8DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt,
9des_ofb64_encrypt, des_xcbc_encrypt, des_ede2_cbc_encrypt, 9DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt,
10des_ede2_cfb64_encrypt, des_ede2_ofb64_encrypt, des_ede3_cbc_encrypt, 10DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt,
11des_ede3_cbcm_encrypt, des_ede3_cfb64_encrypt, des_ede3_ofb64_encrypt, 11DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt,
12des_read_password, des_read_2passwords, des_read_pw_string, 12DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys,
13des_cbc_cksum, des_quad_cksum, des_string_to_key, des_string_to_2keys, 13DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write - DES encryption
14des_fcrypt, des_crypt, des_enc_read, des_enc_write - DES encryption
15 14
16=head1 SYNOPSIS 15=head1 SYNOPSIS
17 16
18 #include <openssl/des.h> 17 #include <openssl/des.h>
19 18
20 void des_random_key(des_cblock *ret); 19 void DES_random_key(DES_cblock *ret);
21 20
22 int des_set_key(const_des_cblock *key, des_key_schedule schedule); 21 int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
23 int des_key_sched(const_des_cblock *key, des_key_schedule schedule); 22 int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
24 int des_set_key_checked(const_des_cblock *key, 23 int DES_set_key_checked(const_DES_cblock *key,
25 des_key_schedule schedule); 24 DES_key_schedule *schedule);
26 void des_set_key_unchecked(const_des_cblock *key, 25 void DES_set_key_unchecked(const_DES_cblock *key,
27 des_key_schedule schedule); 26 DES_key_schedule *schedule);
28 27
29 void des_set_odd_parity(des_cblock *key); 28 void DES_set_odd_parity(DES_cblock *key);
30 int des_is_weak_key(const_des_cblock *key); 29 int DES_is_weak_key(const_DES_cblock *key);
31 30
32 void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, 31 void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
33 des_key_schedule ks, int enc); 32 DES_key_schedule *ks, int enc);
34 void des_ecb2_encrypt(const_des_cblock *input, des_cblock *output, 33 void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output,
35 des_key_schedule ks1, des_key_schedule ks2, int enc); 34 DES_key_schedule *ks1, DES_key_schedule *ks2, int enc);
36 void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, 35 void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
37 des_key_schedule ks1, des_key_schedule ks2, 36 DES_key_schedule *ks1, DES_key_schedule *ks2,
38 des_key_schedule ks3, int enc); 37 DES_key_schedule *ks3, int enc);
39 38
40 void des_ncbc_encrypt(const unsigned char *input, unsigned char *output, 39 void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
41 long length, des_key_schedule schedule, des_cblock *ivec, 40 long length, DES_key_schedule *schedule, DES_cblock *ivec,
42 int enc); 41 int enc);
43 void des_cfb_encrypt(const unsigned char *in, unsigned char *out, 42 void DES_cfb_encrypt(const unsigned char *in, unsigned char *out,
44 int numbits, long length, des_key_schedule schedule, 43 int numbits, long length, DES_key_schedule *schedule,
45 des_cblock *ivec, int enc); 44 DES_cblock *ivec, int enc);
46 void des_ofb_encrypt(const unsigned char *in, unsigned char *out, 45 void DES_ofb_encrypt(const unsigned char *in, unsigned char *out,
47 int numbits, long length, des_key_schedule schedule, 46 int numbits, long length, DES_key_schedule *schedule,
48 des_cblock *ivec); 47 DES_cblock *ivec);
49 void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, 48 void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
50 long length, des_key_schedule schedule, des_cblock *ivec, 49 long length, DES_key_schedule *schedule, DES_cblock *ivec,
51 int enc); 50 int enc);
52 void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, 51 void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
53 long length, des_key_schedule schedule, des_cblock *ivec, 52 long length, DES_key_schedule *schedule, DES_cblock *ivec,
54 int *num, int enc); 53 int *num, int enc);
55 void des_ofb64_encrypt(const unsigned char *in, unsigned char *out, 54 void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
56 long length, des_key_schedule schedule, des_cblock *ivec, 55 long length, DES_key_schedule *schedule, DES_cblock *ivec,
57 int *num); 56 int *num);
58 57
59 void des_xcbc_encrypt(const unsigned char *input, unsigned char *output, 58 void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
60 long length, des_key_schedule schedule, des_cblock *ivec, 59 long length, DES_key_schedule *schedule, DES_cblock *ivec,
61 const_des_cblock *inw, const_des_cblock *outw, int enc); 60 const_DES_cblock *inw, const_DES_cblock *outw, int enc);
62 61
63 void des_ede2_cbc_encrypt(const unsigned char *input, 62 void DES_ede2_cbc_encrypt(const unsigned char *input,
64 unsigned char *output, long length, des_key_schedule ks1, 63 unsigned char *output, long length, DES_key_schedule *ks1,
65 des_key_schedule ks2, des_cblock *ivec, int enc); 64 DES_key_schedule *ks2, DES_cblock *ivec, int enc);
66 void des_ede2_cfb64_encrypt(const unsigned char *in, 65 void DES_ede2_cfb64_encrypt(const unsigned char *in,
67 unsigned char *out, long length, des_key_schedule ks1, 66 unsigned char *out, long length, DES_key_schedule *ks1,
68 des_key_schedule ks2, des_cblock *ivec, int *num, int enc); 67 DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc);
69 void des_ede2_ofb64_encrypt(const unsigned char *in, 68 void DES_ede2_ofb64_encrypt(const unsigned char *in,
70 unsigned char *out, long length, des_key_schedule ks1, 69 unsigned char *out, long length, DES_key_schedule *ks1,
71 des_key_schedule ks2, des_cblock *ivec, int *num); 70 DES_key_schedule *ks2, DES_cblock *ivec, int *num);
72 71
73 void des_ede3_cbc_encrypt(const unsigned char *input, 72 void DES_ede3_cbc_encrypt(const unsigned char *input,
74 unsigned char *output, long length, des_key_schedule ks1, 73 unsigned char *output, long length, DES_key_schedule *ks1,
75 des_key_schedule ks2, des_key_schedule ks3, des_cblock *ivec, 74 DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec,
76 int enc); 75 int enc);
77 void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, 76 void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
78 long length, des_key_schedule ks1, des_key_schedule ks2, 77 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
79 des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2, 78 DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2,
80 int enc); 79 int enc);
81 void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, 80 void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
82 long length, des_key_schedule ks1, des_key_schedule ks2, 81 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
83 des_key_schedule ks3, des_cblock *ivec, int *num, int enc); 82 DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc);
84 void des_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, 83 void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
85 long length, des_key_schedule ks1, 84 long length, DES_key_schedule *ks1,
86 des_key_schedule ks2, des_key_schedule ks3, 85 DES_key_schedule *ks2, DES_key_schedule *ks3,
87 des_cblock *ivec, int *num); 86 DES_cblock *ivec, int *num);
88 87
89 int des_read_password(des_cblock *key, const char *prompt, int verify); 88 DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
90 int des_read_2passwords(des_cblock *key1, des_cblock *key2, 89 long length, DES_key_schedule *schedule,
91 const char *prompt, int verify); 90 const_DES_cblock *ivec);
92 int des_read_pw_string(char *buf, int length, const char *prompt, 91 DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
93 int verify); 92 long length, int out_count, DES_cblock *seed);
94 93 void DES_string_to_key(const char *str, DES_cblock *key);
95 DES_LONG des_cbc_cksum(const unsigned char *input, des_cblock *output, 94 void DES_string_to_2keys(const char *str, DES_cblock *key1,
96 long length, des_key_schedule schedule, 95 DES_cblock *key2);
97 const_des_cblock *ivec); 96
98 DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], 97 char *DES_fcrypt(const char *buf, const char *salt, char *ret);
99 long length, int out_count, des_cblock *seed); 98 char *DES_crypt(const char *buf, const char *salt);
100 void des_string_to_key(const char *str, des_cblock *key); 99
101 void des_string_to_2keys(const char *str, des_cblock *key1, 100 int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
102 des_cblock *key2); 101 DES_cblock *iv);
103 102 int DES_enc_write(int fd, const void *buf, int len,
104 char *des_fcrypt(const char *buf, const char *salt, char *ret); 103 DES_key_schedule *sched, DES_cblock *iv);
105 char *des_crypt(const char *buf, const char *salt);
106 char *crypt(const char *buf, const char *salt);
107
108 int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
109 des_cblock *iv);
110 int des_enc_write(int fd, const void *buf, int len,
111 des_key_schedule sched, des_cblock *iv);
112 104
113=head1 DESCRIPTION 105=head1 DESCRIPTION
114 106
@@ -116,56 +108,52 @@ This library contains a fast implementation of the DES encryption
116algorithm. 108algorithm.
117 109
118There are two phases to the use of DES encryption. The first is the 110There are two phases to the use of DES encryption. The first is the
119generation of a I<des_key_schedule> from a key, the second is the 111generation of a I<DES_key_schedule> from a key, the second is the
120actual encryption. A DES key is of type I<des_cblock>. This type is 112actual encryption. A DES key is of type I<DES_cblock>. This type is
121consists of 8 bytes with odd parity. The least significant bit in 113consists of 8 bytes with odd parity. The least significant bit in
122each byte is the parity bit. The key schedule is an expanded form of 114each byte is the parity bit. The key schedule is an expanded form of
123the key; it is used to speed the encryption process. 115the key; it is used to speed the encryption process.
124 116
125des_random_key() generates a random key. The PRNG must be seeded 117DES_random_key() generates a random key. The PRNG must be seeded
126prior to using this function (see L<rand(3)|rand(3)>; for backward 118prior to using this function (see L<rand(3)|rand(3)>). If the PRNG
127compatibility the function des_random_seed() is available as well). 119could not generate a secure key, 0 is returned.
128If the PRNG could not generate a secure key, 0 is returned. In
129earlier versions of the library, des_random_key() did not generate
130secure keys.
131 120
132Before a DES key can be used, it must be converted into the 121Before a DES key can be used, it must be converted into the
133architecture dependent I<des_key_schedule> via the 122architecture dependent I<DES_key_schedule> via the
134des_set_key_checked() or des_set_key_unchecked() function. 123DES_set_key_checked() or DES_set_key_unchecked() function.
135 124
136des_set_key_checked() will check that the key passed is of odd parity 125DES_set_key_checked() will check that the key passed is of odd parity
137and is not a week or semi-weak key. If the parity is wrong, then -1 126and is not a week or semi-weak key. If the parity is wrong, then -1
138is returned. If the key is a weak key, then -2 is returned. If an 127is returned. If the key is a weak key, then -2 is returned. If an
139error is returned, the key schedule is not generated. 128error is returned, the key schedule is not generated.
140 129
141des_set_key() (called des_key_sched() in the MIT library) works like 130DES_set_key() works like
142des_set_key_checked() if the I<des_check_key> flag is non-zero, 131DES_set_key_checked() if the I<DES_check_key> flag is non-zero,
143otherwise like des_set_key_unchecked(). These functions are available 132otherwise like DES_set_key_unchecked(). These functions are available
144for compatibility; it is recommended to use a function that does not 133for compatibility; it is recommended to use a function that does not
145depend on a global variable. 134depend on a global variable.
146 135
147des_set_odd_parity() (called des_fixup_key_parity() in the MIT 136DES_set_odd_parity() sets the parity of the passed I<key> to odd.
148library) sets the parity of the passed I<key> to odd.
149 137
150des_is_weak_key() returns 1 is the passed key is a weak key, 0 if it 138DES_is_weak_key() returns 1 is the passed key is a weak key, 0 if it
151is ok. The probability that a randomly generated key is weak is 139is ok. The probability that a randomly generated key is weak is
1521/2^52, so it is not really worth checking for them. 1401/2^52, so it is not really worth checking for them.
153 141
154The following routines mostly operate on an input and output stream of 142The following routines mostly operate on an input and output stream of
155I<des_cblock>s. 143I<DES_cblock>s.
156 144
157des_ecb_encrypt() is the basic DES encryption routine that encrypts or 145DES_ecb_encrypt() is the basic DES encryption routine that encrypts or
158decrypts a single 8-byte I<des_cblock> in I<electronic code book> 146decrypts a single 8-byte I<DES_cblock> in I<electronic code book>
159(ECB) mode. It always transforms the input data, pointed to by 147(ECB) mode. It always transforms the input data, pointed to by
160I<input>, into the output data, pointed to by the I<output> argument. 148I<input>, into the output data, pointed to by the I<output> argument.
161If the I<encrypt> argument is non-zero (DES_ENCRYPT), the I<input> 149If the I<encrypt> argument is non-zero (DES_ENCRYPT), the I<input>
162(cleartext) is encrypted in to the I<output> (ciphertext) using the 150(cleartext) is encrypted in to the I<output> (ciphertext) using the
163key_schedule specified by the I<schedule> argument, previously set via 151key_schedule specified by the I<schedule> argument, previously set via
164I<des_set_key>. If I<encrypt> is zero (DES_DECRYPT), the I<input> (now 152I<DES_set_key>. If I<encrypt> is zero (DES_DECRYPT), the I<input> (now
165ciphertext) is decrypted into the I<output> (now cleartext). Input 153ciphertext) is decrypted into the I<output> (now cleartext). Input
166and output may overlap. des_ecb_encrypt() does not return a value. 154and output may overlap. DES_ecb_encrypt() does not return a value.
167 155
168des_ecb3_encrypt() encrypts/decrypts the I<input> block by using 156DES_ecb3_encrypt() encrypts/decrypts the I<input> block by using
169three-key Triple-DES encryption in ECB mode. This involves encrypting 157three-key Triple-DES encryption in ECB mode. This involves encrypting
170the input with I<ks1>, decrypting with the key schedule I<ks2>, and 158the input with I<ks1>, decrypting with the key schedule I<ks2>, and
171then encrypting with I<ks3>. This routine greatly reduces the chances 159then encrypting with I<ks3>. This routine greatly reduces the chances
@@ -173,10 +161,10 @@ of brute force breaking of DES and has the advantage of if I<ks1>,
173I<ks2> and I<ks3> are the same, it is equivalent to just encryption 161I<ks2> and I<ks3> are the same, it is equivalent to just encryption
174using ECB mode and I<ks1> as the key. 162using ECB mode and I<ks1> as the key.
175 163
176The macro des_ecb2_encrypt() is provided to perform two-key Triple-DES 164The macro DES_ecb2_encrypt() is provided to perform two-key Triple-DES
177encryption by using I<ks1> for the final encryption. 165encryption by using I<ks1> for the final encryption.
178 166
179des_ncbc_encrypt() encrypts/decrypts using the I<cipher-block-chaining> 167DES_ncbc_encrypt() encrypts/decrypts using the I<cipher-block-chaining>
180(CBC) mode of DES. If the I<encrypt> argument is non-zero, the 168(CBC) mode of DES. If the I<encrypt> argument is non-zero, the
181routine cipher-block-chain encrypts the cleartext data pointed to by 169routine cipher-block-chain encrypts the cleartext data pointed to by
182the I<input> argument into the ciphertext pointed to by the I<output> 170the I<input> argument into the ciphertext pointed to by the I<output>
@@ -186,24 +174,24 @@ I<length> argument is not an integral multiple of eight bytes, the
186last block is copied to a temporary area and zero filled. The output 174last block is copied to a temporary area and zero filled. The output
187is always an integral multiple of eight bytes. 175is always an integral multiple of eight bytes.
188 176
189des_xcbc_encrypt() is RSA's DESX mode of DES. It uses I<inw> and 177DES_xcbc_encrypt() is RSA's DESX mode of DES. It uses I<inw> and
190I<outw> to 'whiten' the encryption. I<inw> and I<outw> are secret 178I<outw> to 'whiten' the encryption. I<inw> and I<outw> are secret
191(unlike the iv) and are as such, part of the key. So the key is sort 179(unlike the iv) and are as such, part of the key. So the key is sort
192of 24 bytes. This is much better than CBC DES. 180of 24 bytes. This is much better than CBC DES.
193 181
194des_ede3_cbc_encrypt() implements outer triple CBC DES encryption with 182DES_ede3_cbc_encrypt() implements outer triple CBC DES encryption with
195three keys. This means that each DES operation inside the CBC mode is 183three keys. This means that each DES operation inside the CBC mode is
196really an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL. 184really an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL.
197 185
198The des_ede2_cbc_encrypt() macro implements two-key Triple-DES by 186The DES_ede2_cbc_encrypt() macro implements two-key Triple-DES by
199reusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>. 187reusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>.
200This form of Triple-DES is used by the RSAREF library. 188This form of Triple-DES is used by the RSAREF library.
201 189
202des_pcbc_encrypt() encrypt/decrypts using the propagating cipher block 190DES_pcbc_encrypt() encrypt/decrypts using the propagating cipher block
203chaining mode used by Kerberos v4. Its parameters are the same as 191chaining mode used by Kerberos v4. Its parameters are the same as
204des_ncbc_encrypt(). 192DES_ncbc_encrypt().
205 193
206des_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This 194DES_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This
207method takes an array of characters as input and outputs and array of 195method takes an array of characters as input and outputs and array of
208characters. It does not require any padding to 8 character groups. 196characters. It does not require any padding to 8 character groups.
209Note: the I<ivec> variable is changed and the new changed value needs to 197Note: the I<ivec> variable is changed and the new changed value needs to
@@ -211,7 +199,7 @@ be passed to the next call to this function. Since this function runs
211a complete DES ECB encryption per I<numbits>, this function is only 199a complete DES ECB encryption per I<numbits>, this function is only
212suggested for use when sending small numbers of characters. 200suggested for use when sending small numbers of characters.
213 201
214des_cfb64_encrypt() 202DES_cfb64_encrypt()
215implements CFB mode of DES with 64bit feedback. Why is this 203implements CFB mode of DES with 64bit feedback. Why is this
216useful you ask? Because this routine will allow you to encrypt an 204useful you ask? Because this routine will allow you to encrypt an
217arbitrary number of bytes, no 8 byte padding. Each call to this 205arbitrary number of bytes, no 8 byte padding. Each call to this
@@ -219,10 +207,10 @@ routine will encrypt the input bytes to output and then update ivec
219and num. num contains 'how far' we are though ivec. If this does 207and num. num contains 'how far' we are though ivec. If this does
220not make much sense, read more about cfb mode of DES :-). 208not make much sense, read more about cfb mode of DES :-).
221 209
222des_ede3_cfb64_encrypt() and des_ede2_cfb64_encrypt() is the same as 210DES_ede3_cfb64_encrypt() and DES_ede2_cfb64_encrypt() is the same as
223des_cfb64_encrypt() except that Triple-DES is used. 211DES_cfb64_encrypt() except that Triple-DES is used.
224 212
225des_ofb_encrypt() encrypts using output feedback mode. This method 213DES_ofb_encrypt() encrypts using output feedback mode. This method
226takes an array of characters as input and outputs and array of 214takes an array of characters as input and outputs and array of
227characters. It does not require any padding to 8 character groups. 215characters. It does not require any padding to 8 character groups.
228Note: the I<ivec> variable is changed and the new changed value needs to 216Note: the I<ivec> variable is changed and the new changed value needs to
@@ -230,39 +218,22 @@ be passed to the next call to this function. Since this function runs
230a complete DES ECB encryption per numbits, this function is only 218a complete DES ECB encryption per numbits, this function is only
231suggested for use when sending small numbers of characters. 219suggested for use when sending small numbers of characters.
232 220
233des_ofb64_encrypt() is the same as des_cfb64_encrypt() using Output 221DES_ofb64_encrypt() is the same as DES_cfb64_encrypt() using Output
234Feed Back mode. 222Feed Back mode.
235 223
236des_ede3_ofb64_encrypt() and des_ede2_ofb64_encrypt() is the same as 224DES_ede3_ofb64_encrypt() and DES_ede2_ofb64_encrypt() is the same as
237des_ofb64_encrypt(), using Triple-DES. 225DES_ofb64_encrypt(), using Triple-DES.
238 226
239The following functions are included in the DES library for 227The following functions are included in the DES library for
240compatibility with the MIT Kerberos library. des_read_pw_string() 228compatibility with the MIT Kerberos library.
241is also available under the name EVP_read_pw_string(). 229
242 230DES_cbc_cksum() produces an 8 byte checksum based on the input stream
243des_read_pw_string() writes the string specified by I<prompt> to
244standard output, turns echo off and reads in input string from the
245terminal. The string is returned in I<buf>, which must have space for
246at least I<length> bytes. If I<verify> is set, the user is asked for
247the password twice and unless the two copies match, an error is
248returned. A return code of -1 indicates a system error, 1 failure due
249to use interaction, and 0 is success.
250
251des_read_password() does the same and converts the password to a DES
252key by calling des_string_to_key(); des_read_2password() operates in
253the same way as des_read_password() except that it generates two keys
254by using the des_string_to_2key() function. des_string_to_key() is
255available for backward compatibility with the MIT library. New
256applications should use a cryptographic hash function. The same
257applies for des_string_to_2key().
258
259des_cbc_cksum() produces an 8 byte checksum based on the input stream
260(via CBC encryption). The last 4 bytes of the checksum are returned 231(via CBC encryption). The last 4 bytes of the checksum are returned
261and the complete 8 bytes are placed in I<output>. This function is 232and the complete 8 bytes are placed in I<output>. This function is
262used by Kerberos v4. Other applications should use 233used by Kerberos v4. Other applications should use
263L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead. 234L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead.
264 235
265des_quad_cksum() is a Kerberos v4 function. It returns a 4 byte 236DES_quad_cksum() is a Kerberos v4 function. It returns a 4 byte
266checksum from the input bytes. The algorithm can be iterated over the 237checksum from the input bytes. The algorithm can be iterated over the
267input, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> is 238input, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> is
268non-NULL, the 8 bytes generated by each pass are written into 239non-NULL, the 8 bytes generated by each pass are written into
@@ -270,19 +241,19 @@ I<output>.
270 241
271The following are DES-based transformations: 242The following are DES-based transformations:
272 243
273des_fcrypt() is a fast version of the Unix crypt(3) function. This 244DES_fcrypt() is a fast version of the Unix crypt(3) function. This
274version takes only a small amount of space relative to other fast 245version takes only a small amount of space relative to other fast
275crypt() implementations. This is different to the normal crypt in 246crypt() implementations. This is different to the normal crypt in
276that the third parameter is the buffer that the return value is 247that the third parameter is the buffer that the return value is
277written into. It needs to be at least 14 bytes long. This function 248written into. It needs to be at least 14 bytes long. This function
278is thread safe, unlike the normal crypt. 249is thread safe, unlike the normal crypt.
279 250
280des_crypt() is a faster replacement for the normal system crypt(). 251DES_crypt() is a faster replacement for the normal system crypt().
281This function calls des_fcrypt() with a static array passed as the 252This function calls DES_fcrypt() with a static array passed as the
282third parameter. This emulates the normal non-thread safe semantics 253third parameter. This emulates the normal non-thread safe semantics
283of crypt(3). 254of crypt(3).
284 255
285des_enc_write() writes I<len> bytes to file descriptor I<fd> from 256DES_enc_write() writes I<len> bytes to file descriptor I<fd> from
286buffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default) 257buffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default)
287using I<sched> for the key and I<iv> as a starting vector. The actual 258using I<sched> for the key and I<iv> as a starting vector. The actual
288data send down I<fd> consists of 4 bytes (in network byte order) 259data send down I<fd> consists of 4 bytes (in network byte order)
@@ -290,40 +261,40 @@ containing the length of the following encrypted data. The encrypted
290data then follows, padded with random data out to a multiple of 8 261data then follows, padded with random data out to a multiple of 8
291bytes. 262bytes.
292 263
293des_enc_read() is used to read I<len> bytes from file descriptor 264DES_enc_read() is used to read I<len> bytes from file descriptor
294I<fd> into buffer I<buf>. The data being read from I<fd> is assumed to 265I<fd> into buffer I<buf>. The data being read from I<fd> is assumed to
295have come from des_enc_write() and is decrypted using I<sched> for 266have come from DES_enc_write() and is decrypted using I<sched> for
296the key schedule and I<iv> for the initial vector. 267the key schedule and I<iv> for the initial vector.
297 268
298B<Warning:> The data format used by des_enc_write() and des_enc_read() 269B<Warning:> The data format used by DES_enc_write() and DES_enc_read()
299has a cryptographic weakness: When asked to write more than MAXWRITE 270has a cryptographic weakness: When asked to write more than MAXWRITE
300bytes, des_enc_write() will split the data into several chunks that 271bytes, DES_enc_write() will split the data into several chunks that
301are all encrypted using the same IV. So don't use these functions 272are all encrypted using the same IV. So don't use these functions
302unless you are sure you know what you do (in which case you might not 273unless you are sure you know what you do (in which case you might not
303want to use them anyway). They cannot handle non-blocking sockets. 274want to use them anyway). They cannot handle non-blocking sockets.
304des_enc_read() uses an internal state and thus cannot be used on 275DES_enc_read() uses an internal state and thus cannot be used on
305multiple files. 276multiple files.
306 277
307I<des_rw_mode> is used to specify the encryption mode to use with 278I<DES_rw_mode> is used to specify the encryption mode to use with
308des_enc_read() and des_end_write(). If set to I<DES_PCBC_MODE> (the 279DES_enc_read() and DES_end_write(). If set to I<DES_PCBC_MODE> (the
309default), des_pcbc_encrypt is used. If set to I<DES_CBC_MODE> 280default), DES_pcbc_encrypt is used. If set to I<DES_CBC_MODE>
310des_cbc_encrypt is used. 281DES_cbc_encrypt is used.
311 282
312=head1 NOTES 283=head1 NOTES
313 284
314Single-key DES is insecure due to its short key size. ECB mode is 285Single-key DES is insecure due to its short key size. ECB mode is
315not suitable for most applications; see L<des_modes(7)|des_modes(7)>. 286not suitable for most applications; see L<DES_modes(7)|DES_modes(7)>.
316 287
317The L<evp(3)|evp(3)> library provides higher-level encryption functions. 288The L<evp(3)|evp(3)> library provides higher-level encryption functions.
318 289
319=head1 BUGS 290=head1 BUGS
320 291
321des_3cbc_encrypt() is flawed and must not be used in applications. 292DES_3cbc_encrypt() is flawed and must not be used in applications.
322 293
323des_cbc_encrypt() does not modify B<ivec>; use des_ncbc_encrypt() 294DES_cbc_encrypt() does not modify B<ivec>; use DES_ncbc_encrypt()
324instead. 295instead.
325 296
326des_cfb_encrypt() and des_ofb_encrypt() operates on input of 8 bits. 297DES_cfb_encrypt() and DES_ofb_encrypt() operates on input of 8 bits.
327What this means is that if you set numbits to 12, and length to 2, the 298What this means is that if you set numbits to 12, and length to 2, the
328first 12 bits will come from the 1st input byte and the low half of 299first 12 bits will come from the 1st input byte and the low half of
329the second input byte. The second 12 bits will have the low 8 bits 300the second input byte. The second 12 bits will have the low 8 bits
@@ -333,8 +304,9 @@ implemented this way because most people will be using a multiple of 8
333and because once you get into pulling bytes input bytes apart things 304and because once you get into pulling bytes input bytes apart things
334get ugly! 305get ugly!
335 306
336des_read_pw_string() is the most machine/OS dependent function and 307DES_string_to_key() is available for backward compatibility with the
337normally generates the most problems when porting this code. 308MIT library. New applications should use a cryptographic hash function.
309The same applies for DES_string_to_2key().
338 310
339=head1 CONFORMING TO 311=head1 CONFORMING TO
340 312
@@ -349,10 +321,20 @@ crypt(3), L<des_modes(7)|des_modes(7)>, L<evp(3)|evp(3)>, L<rand(3)|rand(3)>
349 321
350=head1 HISTORY 322=head1 HISTORY
351 323
324In OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoid
325clashes with older versions of libdes. Compatibility des_ functions
326are provided for a short while, as well as crypt().
327Declarations for these are in <openssl/des_old.h>. There is no DES_
328variant for des_random_seed().
329This will happen to other functions
330as well if they are deemed redundant (des_random_seed() just calls
331RAND_seed() and is present for backward compatibility only), buggy or
332already scheduled for removal.
333
352des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(), 334des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(),
353des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(), 335des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(),
354des_quad_cksum(), des_random_key(), des_read_password() and 336des_quad_cksum(), des_random_key() and des_string_to_key()
355des_string_to_key() are available in the MIT Kerberos library; 337are available in the MIT Kerberos library;
356des_check_key_parity(), des_fixup_key_parity() and des_is_weak_key() 338des_check_key_parity(), des_fixup_key_parity() and des_is_weak_key()
357are available in newer versions of that library. 339are available in newer versions of that library.
358 340
diff --git a/src/lib/libssl/src/doc/crypto/hmac.pod b/src/lib/libssl/src/doc/crypto/hmac.pod
index 631f40377e..3cc29dfc83 100644
--- a/src/lib/libssl/src/doc/crypto/hmac.pod
+++ b/src/lib/libssl/src/doc/crypto/hmac.pod
@@ -13,11 +13,16 @@ authentication code
13 int key_len, const unsigned char *d, int n, 13 int key_len, const unsigned char *d, int n,
14 unsigned char *md, unsigned int *md_len); 14 unsigned char *md, unsigned int *md_len);
15 15
16 void HMAC_CTX_init(HMAC_CTX *ctx);
17
16 void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, 18 void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
17 const EVP_MD *md); 19 const EVP_MD *md);
20 void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
21 const EVP_MD *md);
18 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); 22 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
19 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 23 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
20 24
25 void HMAC_CTX_cleanup(HMAC_CTX *ctx);
21 void HMAC_cleanup(HMAC_CTX *ctx); 26 void HMAC_cleanup(HMAC_CTX *ctx);
22 27
23=head1 DESCRIPTION 28=head1 DESCRIPTION
@@ -39,13 +44,31 @@ B<evp_md> can be EVP_sha1(), EVP_ripemd160() etc.
39B<key> and B<evp_md> may be B<NULL> if a key and hash function have 44B<key> and B<evp_md> may be B<NULL> if a key and hash function have
40been set in a previous call to HMAC_Init() for that B<HMAC_CTX>. 45been set in a previous call to HMAC_Init() for that B<HMAC_CTX>.
41 46
42HMAC_cleanup() erases the key and other data from the B<HMAC_CTX>. 47HMAC_CTX_init() initialises a B<HMAC_CTX> before first use. It must be
48called.
49
50HMAC_CTX_cleanup() erases the key and other data from the B<HMAC_CTX>
51and releases any associated resources. It must be called when an
52B<HMAC_CTX> is no longer required.
53
54HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back
55compatibility with 0.9.6b, it is deprecated.
43 56
44The following functions may be used if the message is not completely 57The following functions may be used if the message is not completely
45stored in memory: 58stored in memory:
46 59
47HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash 60HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash
48function B<evp_md> and the key B<key> which is B<key_len> bytes long. 61function B<evp_md> and the key B<key> which is B<key_len> bytes
62long. It is deprecated and only included for backward compatibility
63with OpenSSL 0.9.6b.
64
65HMAC_Init_ex() initializes or reuses a B<HMAC_CTX> structure to use
66the function B<evp_md> and key B<key>. Either can be NULL, in which
67case the existing one will be reused. HMAC_CTX_init() must have been
68called before the first use of an B<HMAC_CTX> in this
69function. B<N.B. HMAC_Init() had this undocumented behaviour in
70previous versions of OpenSSL - failure to switch to HMAC_Init_ex() in
71programs that expect it will cause them to stop working>.
49 72
50HMAC_Update() can be called repeatedly with chunks of the message to 73HMAC_Update() can be called repeatedly with chunks of the message to
51be authenticated (B<len> bytes at B<data>). 74be authenticated (B<len> bytes at B<data>).
@@ -57,8 +80,8 @@ must have space for the hash function output.
57 80
58HMAC() returns a pointer to the message authentication code. 81HMAC() returns a pointer to the message authentication code.
59 82
60HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() do not 83HMAC_CTX_init(), HMAC_Init_ex(), HMAC_Update(), HMAC_Final() and
61return values. 84HMAC_CTX_cleanup() do not return values.
62 85
63=head1 CONFORMING TO 86=head1 CONFORMING TO
64 87
diff --git a/src/lib/libssl/src/doc/crypto/lhash.pod b/src/lib/libssl/src/doc/crypto/lhash.pod
index 4e87aee824..0bac11421e 100644
--- a/src/lib/libssl/src/doc/crypto/lhash.pod
+++ b/src/lib/libssl/src/doc/crypto/lhash.pod
@@ -2,43 +2,108 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, 5lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_error - dynamic hash table
6lh_doall_arg, lh_error - dynamic hash table
7 6
8=head1 SYNOPSIS 7=head1 SYNOPSIS
9 8
10 #include <openssl/lhash.h> 9 #include <openssl/lhash.h>
11 10
12 LHASH *lh_new(unsigned long (*hash)(/*void *a*/), 11 LHASH *lh_new(LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE compare);
13 int (*compare)(/*void *a,void *b*/));
14 void lh_free(LHASH *table); 12 void lh_free(LHASH *table);
15 13
16 void *lh_insert(LHASH *table, void *data); 14 void *lh_insert(LHASH *table, void *data);
17 void *lh_delete(LHASH *table, void *data); 15 void *lh_delete(LHASH *table, void *data);
18 void *lh_retrieve(LHASH *table, void *data); 16 void *lh_retrieve(LHASH *table, void *data);
19 17
20 void lh_doall(LHASH *table, void (*func)(/*void *b*/)); 18 void lh_doall(LHASH *table, LHASH_DOALL_FN_TYPE func);
21 void lh_doall_arg(LHASH *table, void (*func)(/*void *a,void *b*/), 19 void lh_doall_arg(LHASH *table, LHASH_DOALL_ARG_FN_TYPE func,
22 void *arg); 20 void *arg);
23 21
24 int lh_error(LHASH *table); 22 int lh_error(LHASH *table);
25 23
24 typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
25 typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
26 typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
27 typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *);
28
26=head1 DESCRIPTION 29=head1 DESCRIPTION
27 30
28This library implements dynamic hash tables. The hash table entries 31This library implements dynamic hash tables. The hash table entries
29can be arbitrary structures. Usually they consist of key and value 32can be arbitrary structures. Usually they consist of key and value
30fields. 33fields.
31 34
32lh_new() creates a new B<LHASH> structure. B<hash> takes a pointer to 35lh_new() creates a new B<LHASH> structure to store arbitrary data
33the structure and returns an unsigned long hash value of its key 36entries, and provides the 'hash' and 'compare' callbacks to be used in
34field. The hash value is normally truncated to a power of 2, so make 37organising the table's entries. The B<hash> callback takes a pointer
35sure that your hash function returns well mixed low order 38to a table entry as its argument and returns an unsigned long hash
36bits. B<compare> takes two arguments, and returns 0 if their keys are 39value for its key field. The hash value is normally truncated to a
37equal, non-zero otherwise. 40power of 2, so make sure that your hash function returns well mixed
41low order bits. The B<compare> callback takes two arguments (pointers
42to two hash table entries), and returns 0 if their keys are equal,
43non-zero otherwise. If your hash table will contain items of some
44particular type and the B<hash> and B<compare> callbacks hash/compare
45these types, then the B<DECLARE_LHASH_HASH_FN> and
46B<IMPLEMENT_LHASH_COMP_FN> macros can be used to create callback
47wrappers of the prototypes required by lh_new(). These provide
48per-variable casts before calling the type-specific callbacks written
49by the application author. These macros, as well as those used for
50the "doall" callbacks, are defined as;
51
52 #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
53 unsigned long f_name##_LHASH_HASH(const void *);
54 #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
55 unsigned long f_name##_LHASH_HASH(const void *arg) { \
56 o_type a = (o_type)arg; \
57 return f_name(a); }
58 #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
59
60 #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
61 int f_name##_LHASH_COMP(const void *, const void *);
62 #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
63 int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
64 o_type a = (o_type)arg1; \
65 o_type b = (o_type)arg2; \
66 return f_name(a,b); }
67 #define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
68
69 #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
70 void f_name##_LHASH_DOALL(const void *);
71 #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
72 void f_name##_LHASH_DOALL(const void *arg) { \
73 o_type a = (o_type)arg; \
74 f_name(a); }
75 #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
76
77 #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
78 void f_name##_LHASH_DOALL_ARG(const void *, const void *);
79 #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
80 void f_name##_LHASH_DOALL_ARG(const void *arg1, const void *arg2) { \
81 o_type a = (o_type)arg1; \
82 a_type b = (a_type)arg2; \
83 f_name(a,b); }
84 #define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
85
86An example of a hash table storing (pointers to) structures of type 'STUFF'
87could be defined as follows;
88
89 /* Calculates the hash value of 'tohash' (implemented elsewhere) */
90 unsigned long STUFF_hash(const STUFF *tohash);
91 /* Orders 'arg1' and 'arg2' (implemented elsewhere) */
92 int STUFF_cmp(const STUFF *arg1, const STUFF *arg2);
93 /* Create the type-safe wrapper functions for use in the LHASH internals */
94 static IMPLEMENT_LHASH_HASH_FN(STUFF_hash, const STUFF *)
95 static IMPLEMENT_LHASH_COMP_FN(STUFF_cmp, const STUFF *);
96 /* ... */
97 int main(int argc, char *argv[]) {
98 /* Create the new hash table using the hash/compare wrappers */
99 LHASH *hashtable = lh_new(LHASH_HASH_FN(STUFF_hash),
100 LHASH_COMP_FN(STUFF_cmp));
101 /* ... */
102 }
38 103
39lh_free() frees the B<LHASH> structure B<table>. Allocated hash table 104lh_free() frees the B<LHASH> structure B<table>. Allocated hash table
40entries will not be freed; consider using lh_doall() to deallocate any 105entries will not be freed; consider using lh_doall() to deallocate any
41remaining entries in the hash table. 106remaining entries in the hash table (see below).
42 107
43lh_insert() inserts the structure pointed to by B<data> into B<table>. 108lh_insert() inserts the structure pointed to by B<data> into B<table>.
44If there already is an entry with the same key, the old value is 109If there already is an entry with the same key, the old value is
@@ -52,23 +117,53 @@ a structure with the key field(s) set; the function will return a
52pointer to a fully populated structure. 117pointer to a fully populated structure.
53 118
54lh_doall() will, for every entry in the hash table, call B<func> with 119lh_doall() will, for every entry in the hash table, call B<func> with
55the data item as parameters. 120the data item as its parameter. For lh_doall() and lh_doall_arg(),
56This function can be quite useful when used as follows: 121function pointer casting should be avoided in the callbacks (see
57 void cleanup(STUFF *a) 122B<NOTE>) - instead, either declare the callbacks to match the
58 { STUFF_free(a); } 123prototype required in lh_new() or use the declare/implement macros to
59 lh_doall(hash,cleanup); 124create type-safe wrappers that cast variables prior to calling your
60 lh_free(hash); 125type-specific callbacks. An example of this is illustrated here where
61This can be used to free all the entries. lh_free() then cleans up the 126the callback is used to cleanup resources for items in the hash table
62'buckets' that point to nothing. When doing this, be careful if you 127prior to the hashtable itself being deallocated:
63delete entries from the hash table in B<func>: the table may decrease 128
64in size, moving item that you are currently on down lower in the hash 129 /* Cleans up resources belonging to 'a' (this is implemented elsewhere) */
65table. This could cause some entries to be skipped. The best 130 void STUFF_cleanup(STUFF *a);
66solution to this problem is to set hash-E<gt>down_load=0 before you 131 /* Implement a prototype-compatible wrapper for "STUFF_cleanup" */
67start. This will stop the hash table ever being decreased in size. 132 IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF *)
68 133 /* ... then later in the code ... */
69lh_doall_arg() is the same as lh_doall() except that B<func> will 134 /* So to run "STUFF_cleanup" against all items in a hash table ... */
70be called with B<arg> as the second argument. 135 lh_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup));
71 136 /* Then the hash table itself can be deallocated */
137 lh_free(hashtable);
138
139When doing this, be careful if you delete entries from the hash table
140in your callbacks: the table may decrease in size, moving the item
141that you are currently on down lower in the hash table - this could
142cause some entries to be skipped during the iteration. The second
143best solution to this problem is to set hash-E<gt>down_load=0 before
144you start (which will stop the hash table ever decreasing in size).
145The best solution is probably to avoid deleting items from the hash
146table inside a "doall" callback!
147
148lh_doall_arg() is the same as lh_doall() except that B<func> will be
149called with B<arg> as the second argument and B<func> should be of
150type B<LHASH_DOALL_ARG_FN_TYPE> (a callback prototype that is passed
151both the table entry and an extra argument). As with lh_doall(), you
152can instead choose to declare your callback with a prototype matching
153the types you are dealing with and use the declare/implement macros to
154create compatible wrappers that cast variables before calling your
155type-specific callbacks. An example of this is demonstrated here
156(printing all hash table entries to a BIO that is provided by the
157caller):
158
159 /* Prints item 'a' to 'output_bio' (this is implemented elsewhere) */
160 void STUFF_print(const STUFF *a, BIO *output_bio);
161 /* Implement a prototype-compatible wrapper for "STUFF_print" */
162 static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF_print, const STUFF *, BIO *)
163 /* ... then later in the code ... */
164 /* Print out the entire hashtable to a particular BIO */
165 lh_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), logging_bio);
166
72lh_error() can be used to determine if an error occurred in the last 167lh_error() can be used to determine if an error occurred in the last
73operation. lh_error() is a macro. 168operation. lh_error() is a macro.
74 169
@@ -91,6 +186,45 @@ otherwise.
91 186
92lh_free(), lh_doall() and lh_doall_arg() return no values. 187lh_free(), lh_doall() and lh_doall_arg() return no values.
93 188
189=head1 NOTE
190
191The various LHASH macros and callback types exist to make it possible
192to write type-safe code without resorting to function-prototype
193casting - an evil that makes application code much harder to
194audit/verify and also opens the window of opportunity for stack
195corruption and other hard-to-find bugs. It also, apparently, violates
196ANSI-C.
197
198The LHASH code regards table entries as constant data. As such, it
199internally represents lh_insert()'d items with a "const void *"
200pointer type. This is why callbacks such as those used by lh_doall()
201and lh_doall_arg() declare their prototypes with "const", even for the
202parameters that pass back the table items' data pointers - for
203consistency, user-provided data is "const" at all times as far as the
204LHASH code is concerned. However, as callers are themselves providing
205these pointers, they can choose whether they too should be treating
206all such parameters as constant.
207
208As an example, a hash table may be maintained by code that, for
209reasons of encapsulation, has only "const" access to the data being
210indexed in the hash table (ie. it is returned as "const" from
211elsewhere in their code) - in this case the LHASH prototypes are
212appropriate as-is. Conversely, if the caller is responsible for the
213life-time of the data in question, then they may well wish to make
214modifications to table item passed back in the lh_doall() or
215lh_doall_arg() callbacks (see the "STUFF_cleanup" example above). If
216so, the caller can either cast the "const" away (if they're providing
217the raw callbacks themselves) or use the macros to declare/implement
218the wrapper functions without "const" types.
219
220Callers that only have "const" access to data they're indexing in a
221table, yet declare callbacks without constant types (or cast the
222"const" away themselves), are therefore creating their own risks/bugs
223without being encouraged to do so by the API. On a related note,
224those auditing code should pay special attention to any instances of
225DECLARE/IMPLEMENT_LHASH_DOALL_[ARG_]_FN macros that provide types
226without any "const" qualifiers.
227
94=head1 BUGS 228=head1 BUGS
95 229
96lh_insert() returns B<NULL> both for success and error. 230lh_insert() returns B<NULL> both for success and error.
@@ -131,7 +265,7 @@ generating hashes that are the same for different values. It is
131probably worth changing your hash function if this is the case because 265probably worth changing your hash function if this is the case because
132even if your hash table has 10 items in a 'bucket', it can be searched 266even if your hash table has 10 items in a 'bucket', it can be searched
133with 10 B<unsigned long> compares and 10 linked list traverses. This 267with 10 B<unsigned long> compares and 10 linked list traverses. This
134will be much less expensive that 10 calls to you compare function. 268will be much less expensive that 10 calls to your compare function.
135 269
136lh_strhash() is a demo string hashing function: 270lh_strhash() is a demo string hashing function:
137 271
diff --git a/src/lib/libssl/src/doc/crypto/pem.pod b/src/lib/libssl/src/doc/crypto/pem.pod
new file mode 100644
index 0000000000..a4f8cc3337
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/pem.pod
@@ -0,0 +1,476 @@
1=pod
2
3=head1 NAME
4
5PEM - PEM routines
6
7=head1 SYNOPSIS
8
9 #include <openssl/pem.h>
10
11 EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x,
12 pem_password_cb *cb, void *u);
13
14 EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x,
15 pem_password_cb *cb, void *u);
16
17 int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
18 unsigned char *kstr, int klen,
19 pem_password_cb *cb, void *u);
20
21 int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
22 unsigned char *kstr, int klen,
23 pem_password_cb *cb, void *u);
24
25 int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
26 char *kstr, int klen,
27 pem_password_cb *cb, void *u);
28
29 int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
30 char *kstr, int klen,
31 pem_password_cb *cb, void *u);
32
33 int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
34 char *kstr, int klen,
35 pem_password_cb *cb, void *u);
36
37 int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
38 char *kstr, int klen,
39 pem_password_cb *cb, void *u);
40
41 EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x,
42 pem_password_cb *cb, void *u);
43
44 EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x,
45 pem_password_cb *cb, void *u);
46
47 int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x);
48 int PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x);
49
50 RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x,
51 pem_password_cb *cb, void *u);
52
53 RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **x,
54 pem_password_cb *cb, void *u);
55
56 int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
57 unsigned char *kstr, int klen,
58 pem_password_cb *cb, void *u);
59
60 int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
61 unsigned char *kstr, int klen,
62 pem_password_cb *cb, void *u);
63
64 RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x,
65 pem_password_cb *cb, void *u);
66
67 RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **x,
68 pem_password_cb *cb, void *u);
69
70 int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x);
71
72 int PEM_write_RSAPublicKey(FILE *fp, RSA *x);
73
74 RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x,
75 pem_password_cb *cb, void *u);
76
77 RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **x,
78 pem_password_cb *cb, void *u);
79
80 int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);
81
82 int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x);
83
84 DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x,
85 pem_password_cb *cb, void *u);
86
87 DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **x,
88 pem_password_cb *cb, void *u);
89
90 int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc,
91 unsigned char *kstr, int klen,
92 pem_password_cb *cb, void *u);
93
94 int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
95 unsigned char *kstr, int klen,
96 pem_password_cb *cb, void *u);
97
98 DSA *PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x,
99 pem_password_cb *cb, void *u);
100
101 DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **x,
102 pem_password_cb *cb, void *u);
103
104 int PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x);
105
106 int PEM_write_DSA_PUBKEY(FILE *fp, DSA *x);
107
108 DSA *PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
109
110 DSA *PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
111
112 int PEM_write_bio_DSAparams(BIO *bp, DSA *x);
113
114 int PEM_write_DSAparams(FILE *fp, DSA *x);
115
116 DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u);
117
118 DH *PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u);
119
120 int PEM_write_bio_DHparams(BIO *bp, DH *x);
121
122 int PEM_write_DHparams(FILE *fp, DH *x);
123
124 X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
125
126 X509 *PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
127
128 int PEM_write_bio_X509(BIO *bp, X509 *x);
129
130 int PEM_write_X509(FILE *fp, X509 *x);
131
132 X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
133
134 X509 *PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
135
136 int PEM_write_bio_X509_AUX(BIO *bp, X509 *x);
137
138 int PEM_write_X509_AUX(FILE *fp, X509 *x);
139
140 X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x,
141 pem_password_cb *cb, void *u);
142
143 X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **x,
144 pem_password_cb *cb, void *u);
145
146 int PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x);
147
148 int PEM_write_X509_REQ(FILE *fp, X509_REQ *x);
149
150 int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x);
151
152 int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
153
154 X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x,
155 pem_password_cb *cb, void *u);
156 X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **x,
157 pem_password_cb *cb, void *u);
158 int PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x);
159 int PEM_write_X509_CRL(FILE *fp, X509_CRL *x);
160
161 PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u);
162
163 PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u);
164
165 int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x);
166
167 int PEM_write_PKCS7(FILE *fp, PKCS7 *x);
168
169 NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp,
170 NETSCAPE_CERT_SEQUENCE **x,
171 pem_password_cb *cb, void *u);
172
173 NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp,
174 NETSCAPE_CERT_SEQUENCE **x,
175 pem_password_cb *cb, void *u);
176
177 int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE *x);
178
179 int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x);
180
181=head1 DESCRIPTION
182
183The PEM functions read or write structures in PEM format. In
184this sense PEM format is simply base64 encoded data surrounded
185by header lines.
186
187For more details about the meaning of arguments see the
188B<PEM FUNCTION ARGUMENTS> section.
189
190Each operation has four functions associated with it. For
191clarity the term "B<foobar> functions" will be used to collectively
192refer to the PEM_read_bio_foobar(), PEM_read_foobar(),
193PEM_write_bio_foobar() and PEM_write_foobar() functions.
194
195The B<PrivateKey> functions read or write a private key in
196PEM format using an EVP_PKEY structure. The write routines use
197"traditional" private key format and can handle both RSA and DSA
198private keys. The read functions can additionally transparently
199handle PKCS#8 format encrypted and unencrypted keys too.
200
201PEM_write_bio_PKCS8PrivateKey() and PEM_write_PKCS8PrivateKey()
202write a private key in an EVP_PKEY structure in PKCS#8
203EncryptedPrivateKeyInfo format using PKCS#5 v2.0 password based encryption
204algorithms. The B<cipher> argument specifies the encryption algoritm to
205use: unlike all other PEM routines the encryption is applied at the
206PKCS#8 level and not in the PEM headers. If B<cipher> is NULL then no
207encryption is used and a PKCS#8 PrivateKeyInfo structure is used instead.
208
209PEM_write_bio_PKCS8PrivateKey_nid() and PEM_write_PKCS8PrivateKey_nid()
210also write out a private key as a PKCS#8 EncryptedPrivateKeyInfo however
211it uses PKCS#5 v1.5 or PKCS#12 encryption algorithms instead. The algorithm
212to use is specified in the B<nid> parameter and should be the NID of the
213corresponding OBJECT IDENTIFIER (see NOTES section).
214
215The B<PUBKEY> functions process a public key using an EVP_PKEY
216structure. The public key is encoded as a SubjectPublicKeyInfo
217structure.
218
219The B<RSAPrivateKey> functions process an RSA private key using an
220RSA structure. It handles the same formats as the B<PrivateKey>
221functions but an error occurs if the private key is not RSA.
222
223The B<RSAPublicKey> functions process an RSA public key using an
224RSA structure. The public key is encoded using a PKCS#1 RSAPublicKey
225structure.
226
227The B<RSA_PUBKEY> functions also process an RSA public key using
228an RSA structure. However the public key is encoded using a
229SubjectPublicKeyInfo structure and an error occurs if the public
230key is not RSA.
231
232The B<DSAPrivateKey> functions process a DSA private key using a
233DSA structure. It handles the same formats as the B<PrivateKey>
234functions but an error occurs if the private key is not DSA.
235
236The B<DSA_PUBKEY> functions process a DSA public key using
237a DSA structure. The public key is encoded using a
238SubjectPublicKeyInfo structure and an error occurs if the public
239key is not DSA.
240
241The B<DSAparams> functions process DSA parameters using a DSA
242structure. The parameters are encoded using a foobar structure.
243
244The B<DHparams> functions process DH parameters using a DH
245structure. The parameters are encoded using a PKCS#3 DHparameter
246structure.
247
248The B<X509> functions process an X509 certificate using an X509
249structure. They will also process a trusted X509 certificate but
250any trust settings are discarded.
251
252The B<X509_AUX> functions process a trusted X509 certificate using
253an X509 structure.
254
255The B<X509_REQ> and B<X509_REQ_NEW> functions process a PKCS#10
256certificate request using an X509_REQ structure. The B<X509_REQ>
257write functions use B<CERTIFICATE REQUEST> in the header whereas
258the B<X509_REQ_NEW> functions use B<NEW CERTIFICATE REQUEST>
259(as required by some CAs). The B<X509_REQ> read functions will
260handle either form so there are no B<X509_REQ_NEW> read functions.
261
262The B<X509_CRL> functions process an X509 CRL using an X509_CRL
263structure.
264
265The B<PKCS7> functions process a PKCS#7 ContentInfo using a PKCS7
266structure.
267
268The B<NETSCAPE_CERT_SEQUENCE> functions process a Netscape Certificate
269Sequence using a NETSCAPE_CERT_SEQUENCE structure.
270
271=head1 PEM FUNCTION ARGUMENTS
272
273The PEM functions have many common arguments.
274
275The B<bp> BIO parameter (if present) specifies the BIO to read from
276or write to.
277
278The B<fp> FILE parameter (if present) specifies the FILE pointer to
279read from or write to.
280
281The PEM read functions all take an argument B<TYPE **x> and return
282a B<TYPE *> pointer. Where B<TYPE> is whatever structure the function
283uses. If B<x> is NULL then the parameter is ignored. If B<x> is not
284NULL but B<*x> is NULL then the structure returned will be written
285to B<*x>. If neither B<x> nor B<*x> is NULL then an attempt is made
286to reuse the structure at B<*x> (but see BUGS and EXAMPLES sections).
287Irrespective of the value of B<x> a pointer to the structure is always
288returned (or NULL if an error occurred).
289
290The PEM functions which write private keys take an B<enc> parameter
291which specifies the encryption algorithm to use, encryption is done
292at the PEM level. If this parameter is set to NULL then the private
293key is written in unencrypted form.
294
295The B<cb> argument is the callback to use when querying for the pass
296phrase used for encrypted PEM structures (normally only private keys).
297
298For the PEM write routines if the B<kstr> parameter is not NULL then
299B<klen> bytes at B<kstr> are used as the passphrase and B<cb> is
300ignored.
301
302If the B<cb> parameters is set to NULL and the B<u> parameter is not
303NULL then the B<u> parameter is interpreted as a null terminated string
304to use as the passphrase. If both B<cb> and B<u> are NULL then the
305default callback routine is used which will typically prompt for the
306passphrase on the current terminal with echoing turned off.
307
308The default passphrase callback is sometimes inappropriate (for example
309in a GUI application) so an alternative can be supplied. The callback
310routine has the following form:
311
312 int cb(char *buf, int size, int rwflag, void *u);
313
314B<buf> is the buffer to write the passphrase to. B<size> is the maximum
315length of the passphrase (i.e. the size of buf). B<rwflag> is a flag
316which is set to 0 when reading and 1 when writing. A typical routine
317will ask the user to verify the passphrase (for example by prompting
318for it twice) if B<rwflag> is 1. The B<u> parameter has the same
319value as the B<u> parameter passed to the PEM routine. It allows
320arbitrary data to be passed to the callback by the application
321(for example a window handle in a GUI application). The callback
322B<must> return the number of characters in the passphrase or 0 if
323an error occurred.
324
325=head1 EXAMPLES
326
327Although the PEM routines take several arguments in almost all applications
328most of them are set to 0 or NULL.
329
330Read a certificate in PEM format from a BIO:
331
332 X509 *x;
333 x = PEM_read_bio(bp, NULL, 0, NULL);
334 if (x == NULL)
335 {
336 /* Error */
337 }
338
339Alternative method:
340
341 X509 *x = NULL;
342 if (!PEM_read_bio_X509(bp, &x, 0, NULL))
343 {
344 /* Error */
345 }
346
347Write a certificate to a BIO:
348
349 if (!PEM_write_bio_X509(bp, x))
350 {
351 /* Error */
352 }
353
354Write an unencrypted private key to a FILE pointer:
355
356 if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL))
357 {
358 /* Error */
359 }
360
361Write a private key (using traditional format) to a BIO using
362triple DES encryption, the pass phrase is prompted for:
363
364 if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, NULL))
365 {
366 /* Error */
367 }
368
369Write a private key (using PKCS#8 format) to a BIO using triple
370DES encryption, using the pass phrase "hello":
371
372 if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, "hello"))
373 {
374 /* Error */
375 }
376
377Read a private key from a BIO using the pass phrase "hello":
378
379 key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello");
380 if (key == NULL)
381 {
382 /* Error */
383 }
384
385Read a private key from a BIO using a pass phrase callback:
386
387 key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
388 if (key == NULL)
389 {
390 /* Error */
391 }
392
393Skeleton pass phrase callback:
394
395 int pass_cb(char *buf, int size, int rwflag, void *u);
396 {
397 int len;
398 char *tmp;
399 /* We'd probably do something else if 'rwflag' is 1 */
400 printf("Enter pass phrase for \"%s\"\n", u);
401
402 /* get pass phrase, length 'len' into 'tmp' */
403 tmp = "hello";
404 len = strlen(tmp);
405
406 if (len <= 0) return 0;
407 /* if too long, truncate */
408 if (len > size) len = size;
409 memcpy(buf, tmp, len);
410 return len;
411 }
412
413=head1 NOTES
414
415The old B<PrivateKey> write routines are retained for compatibility.
416New applications should write private keys using the
417PEM_write_bio_PKCS8PrivateKey() or PEM_write_PKCS8PrivateKey() routines
418because they are more secure (they use an iteration count of 2048 whereas
419the traditional routines use a count of 1) unless compatibility with older
420versions of OpenSSL is important.
421
422The B<PrivateKey> read routines can be used in all applications because
423they handle all formats transparently.
424
425A frequent cause of problems is attempting to use the PEM routines like
426this:
427
428 X509 *x;
429 PEM_read_bio_X509(bp, &x, 0, NULL);
430
431this is a bug because an attempt will be made to reuse the data at B<x>
432which is an uninitialised pointer.
433
434=head1 PEM ENCRYPTION FORMAT
435
436This old B<PrivateKey> routines use a non standard technique for encryption.
437
438The private key (or other data) takes the following form:
439
440 -----BEGIN RSA PRIVATE KEY-----
441 Proc-Type: 4,ENCRYPTED
442 DEK-Info: DES-EDE3-CBC,3F17F5316E2BAC89
443
444 ...base64 encoded data...
445 -----END RSA PRIVATE KEY-----
446
447The line beginning DEK-Info contains two comma separated pieces of information:
448the encryption algorithm name as used by EVP_get_cipherbyname() and an 8
449byte B<salt> encoded as a set of hexadecimal digits.
450
451After this is the base64 encoded encrypted data.
452
453The encryption key is determined using EVP_bytestokey(), using B<salt> and an
454iteration count of 1. The IV used is the value of B<salt> and *not* the IV
455returned by EVP_bytestokey().
456
457=head1 BUGS
458
459The PEM read routines in some versions of OpenSSL will not correctly reuse
460an existing structure. Therefore the following:
461
462 PEM_read_bio(bp, &x, 0, NULL);
463
464where B<x> already contains a valid certificate, may not work, whereas:
465
466 X509_free(x);
467 x = PEM_read_bio(bp, NULL, 0, NULL);
468
469is guaranteed to work.
470
471=head1 RETURN CODES
472
473The read routines return either a pointer to the structure read or NULL
474is an error occurred.
475
476The write routines return 1 for success or 0 for failure.
diff --git a/src/lib/libssl/src/doc/crypto/rsa.pod b/src/lib/libssl/src/doc/crypto/rsa.pod
index ef0d4df205..09ad30cab1 100644
--- a/src/lib/libssl/src/doc/crypto/rsa.pod
+++ b/src/lib/libssl/src/doc/crypto/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/libssl/src/doc/crypto/threads.pod b/src/lib/libssl/src/doc/crypto/threads.pod
index bc7ff9b705..afa45cd76c 100644
--- a/src/lib/libssl/src/doc/crypto/threads.pod
+++ b/src/lib/libssl/src/doc/crypto/threads.pod
@@ -53,8 +53,10 @@ OpenSSL can safely be used in multi-threaded applications provided
53that at least two callback functions are set. 53that at least two callback functions are set.
54 54
55locking_function(int mode, int n, const char *file, int line) is 55locking_function(int mode, int n, const char *file, int line) is
56needed to perform locking on shared data structures. Multi-threaded 56needed to perform locking on shared data structures.
57applications will crash at random if it is not set. 57(Note that OpenSSL uses a number of global data structures that
58will be implicitly shared whenever multiple threads use OpenSSL.)
59Multi-threaded applications will crash at random if it is not set.
58 60
59locking_function() must be able to handle up to CRYPTO_num_locks() 61locking_function() must be able to handle up to CRYPTO_num_locks()
60different mutex locks. It sets the B<n>-th lock if B<mode> & 62different mutex locks. It sets the B<n>-th lock if B<mode> &
diff --git a/src/lib/libssl/src/doc/crypto/ui.pod b/src/lib/libssl/src/doc/crypto/ui.pod
new file mode 100644
index 0000000000..2b3535a746
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ui.pod
@@ -0,0 +1,194 @@
1=pod
2
3=head1 NAME
4
5UI_new, UI_new_method, UI_free, UI_add_input_string, UI_dup_input_string,
6UI_add_verify_string, UI_dup_verify_string, UI_add_input_boolean,
7UI_dup_input_boolean, UI_add_info_string, UI_dup_info_string,
8UI_add_error_string, UI_dup_error_string, UI_construct_prompt
9UI_add_user_data, UI_get0_user_data, UI_get0_result, UI_process,
10UI_ctrl, UI_set_default_method, UI_get_default_method, UI_get_method,
11UI_set_method, UI_OpenSSL, ERR_load_UI_strings - New User Interface
12
13=head1 SYNOPSIS
14
15 #include <openssl/ui.h>
16
17 typedef struct ui_st UI;
18 typedef struct ui_method_st UI_METHOD;
19
20 UI *UI_new(void);
21 UI *UI_new_method(const UI_METHOD *method);
22 void UI_free(UI *ui);
23
24 int UI_add_input_string(UI *ui, const char *prompt, int flags,
25 char *result_buf, int minsize, int maxsize);
26 int UI_dup_input_string(UI *ui, const char *prompt, int flags,
27 char *result_buf, int minsize, int maxsize);
28 int UI_add_verify_string(UI *ui, const char *prompt, int flags,
29 char *result_buf, int minsize, int maxsize, const char *test_buf);
30 int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
31 char *result_buf, int minsize, int maxsize, const char *test_buf);
32 int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
33 const char *ok_chars, const char *cancel_chars,
34 int flags, char *result_buf);
35 int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
36 const char *ok_chars, const char *cancel_chars,
37 int flags, char *result_buf);
38 int UI_add_info_string(UI *ui, const char *text);
39 int UI_dup_info_string(UI *ui, const char *text);
40 int UI_add_error_string(UI *ui, const char *text);
41 int UI_dup_error_string(UI *ui, const char *text);
42
43 /* These are the possible flags. They can be or'ed together. */
44 #define UI_INPUT_FLAG_ECHO 0x01
45 #define UI_INPUT_FLAG_DEFAULT_PWD 0x02
46
47 char *UI_construct_prompt(UI *ui_method,
48 const char *object_desc, const char *object_name);
49
50 void *UI_add_user_data(UI *ui, void *user_data);
51 void *UI_get0_user_data(UI *ui);
52
53 const char *UI_get0_result(UI *ui, int i);
54
55 int UI_process(UI *ui);
56
57 int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)());
58 #define UI_CTRL_PRINT_ERRORS 1
59 #define UI_CTRL_IS_REDOABLE 2
60
61 void UI_set_default_method(const UI_METHOD *meth);
62 const UI_METHOD *UI_get_default_method(void);
63 const UI_METHOD *UI_get_method(UI *ui);
64 const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
65
66 UI_METHOD *UI_OpenSSL(void);
67
68=head1 DESCRIPTION
69
70UI stands for User Interface, and is general purpose set of routines to
71prompt the user for text-based information. Through user-written methods
72(see L<ui_create(3)|ui_create(3)>), prompting can be done in any way
73imaginable, be it plain text prompting, through dialog boxes or from a
74cell phone.
75
76All the functions work through a context of the type UI. This context
77contains all the information needed to prompt correctly as well as a
78reference to a UI_METHOD, which is an ordered vector of functions that
79carry out the actual prompting.
80
81The first thing to do is to create a UI with UI_new() or UI_new_method(),
82then add information to it with the UI_add or UI_dup functions. Also,
83user-defined random data can be passed down to the underlying method
84through calls to UI_add_user_data. The default UI method doesn't care
85about these data, but other methods might. Finally, use UI_process()
86to actually perform the prompting and UI_get0_result() to find the result
87to the prompt.
88
89A UI can contain more than one prompt, which are performed in the given
90sequence. Each prompt gets an index number which is returned by the
91UI_add and UI_dup functions, and has to be used to get the corresponding
92result with UI_get0_result().
93
94The functions are as follows:
95
96UI_new() creates a new UI using the default UI method. When done with
97this UI, it should be freed using UI_free().
98
99UI_new_method() creates a new UI using the given UI method. When done with
100this UI, it should be freed using UI_free().
101
102UI_OpenSSL() returns the built-in UI method (note: not the default one,
103since the default can be changed. See further on). This method is the
104most machine/OS dependent part of OpenSSL and normally generates the
105most problems when porting.
106
107UI_free() removes a UI from memory, along with all other pieces of memory
108that's connected to it, like duplicated input strings, results and others.
109
110UI_add_input_string() and UI_add_verify_string() add a prompt to the UI,
111as well as flags and a result buffer and the desired minimum and maximum
112sizes of the result. The given information is used to prompt for
113information, for example a password, and to verify a password (i.e. having
114the user enter it twice and check that the same string was entered twice).
115UI_add_verify_string() takes and extra argument that should be a pointer
116to the result buffer of the input string that it's supposed to verify, or
117verification will fail.
118
119UI_add_input_boolean() adds a prompt to the UI that's supposed to be answered
120in a boolean way, with a single character for yes and a different character
121for no. A set of characters that can be used to cancel the prompt is given
122as well. The prompt itself is really divided in two, one part being the
123descriptive text (given through the I<prompt> argument) and one describing
124the possible answers (given through the I<action_desc> argument).
125
126UI_add_info_string() and UI_add_error_string() add strings that are shown at
127the same time as the prompt for extra information or to show an error string.
128The difference between the two is only conceptual. With the builtin method,
129there's no technical difference between them. Other methods may make a
130difference between them, however.
131
132The flags currently supported are UI_INPUT_FLAG_ECHO, which is relevant for
133UI_add_input_string() and will have the users response be echoed (when
134prompting for a password, this flag should obviously not be used, and
135UI_INPUT_FLAG_DEFAULT_PWD, which means that a default password of some
136sort will be used (completely depending on the application and the UI
137method).
138
139UI_dup_input_string(), UI_dup_verify_string(), UI_dup_input_boolean(),
140UI_dup_info_string() and UI_dup_error_string() are basically the same
141as their UI_add counterparts, except that they make their own copies
142of all strings.
143
144UI_construct_prompt() is a helper function that can be used to create
145a prompt from two pieces of information: an description and a name.
146The default constructor (if there is none provided by the method used)
147creates a string "Enter I<description> for I<name>:". With the
148description "pass phrase" and the file name "foo.key", that becomes
149"Enter pass phrase for foo.key:". Other methods may create whatever
150string and may include encodings that will be processed by the other
151method functions.
152
153UI_add_user_data() adds a piece of memory for the method to use at any
154time. The builtin UI method doesn't care about this info. Note that several
155calls to this function doesn't add data, it replaces the previous blob
156with the one given as argument.
157
158UI_get0_user_data() retrieves the data that has last been given to the
159UI with UI_add_user_data().
160
161UI_get0_result() returns a pointer to the result buffer associated with
162the information indexed by I<i>.
163
164UI_process() goes through the information given so far, does all the printing
165and prompting and returns.
166
167UI_ctrl() adds extra control for the application author. For now, it
168understands two commands: UI_CTRL_PRINT_ERRORS, which makes UI_process()
169print the OpenSSL error stack as part of processing the UI, and
170UI_CTRL_IS_REDOABLE, which returns a flag saying if the used UI can
171be used again or not.
172
173UI_set_default_method() changes the default UI method to the one given.
174
175UI_get_default_method() returns a pointer to the current default UI method.
176
177UI_get_method() returns the UI method associated with a given UI.
178
179UI_set_method() changes the UI method associated with a given UI.
180
181=head1 SEE ALSO
182
183L<ui_create(3)|ui_create(3)>, L<ui_compat(3)|ui_compat(3)>
184
185=head1 HISTORY
186
187The UI section was first introduced in OpenSSL 0.9.7.
188
189=head1 AUTHOR
190
191Richard Levitte (richard@levitte.org) for the OpenSSL project
192(http://www.openssl.org).
193
194=cut
diff --git a/src/lib/libssl/src/doc/crypto/ui_compat.pod b/src/lib/libssl/src/doc/crypto/ui_compat.pod
new file mode 100644
index 0000000000..9ab3c69bf2
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/ui_compat.pod
@@ -0,0 +1,55 @@
1=pod
2
3=head1 NAME
4
5des_read_password, des_read_2passwords, des_read_pw_string, des_read_pw -
6Compatibility user interface functions
7
8=head1 SYNOPSIS
9
10 int des_read_password(DES_cblock *key,const char *prompt,int verify);
11 int des_read_2passwords(DES_cblock *key1,DES_cblock *key2,
12 const char *prompt,int verify);
13
14 int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
15 int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
16
17=head1 DESCRIPTION
18
19The DES library contained a few routines to prompt for passwords. These
20aren't necessarely dependent on DES, and have therefore become part of the
21UI compatibility library.
22
23des_read_pw() writes the string specified by I<prompt> to standard output
24turns echo off and reads an input string from the terminal. The string is
25returned in I<buf>, which must have spac for at least I<size> bytes.
26If I<verify> is set, the user is asked for the password twice and unless
27the two copies match, an error is returned. The second password is stored
28in I<buff>, which must therefore also be at least I<size> bytes. A return
29code of -1 indicates a system error, 1 failure due to use interaction, and
300 is success. All other functions described here use des_read_pw() to do
31the work.
32
33des_read_pw_string() is a variant of des_read_pw() that provides a buffer
34for you if I<verify> is set.
35
36des_read_password() calls des_read_pw() and converts the password to a
37DES key by calling DES_string_to_key(); des_read_2password() operates in
38the same way as des_read_password() except that it generates two keys
39by using the DES_string_to_2key() function.
40
41=head1 NOTES
42
43des_read_pw_string() is available in the MIT Kerberos library as well, and
44is also available under the name EVP_read_pw_string().
45
46=head1 SEE ALSO
47
48L<ui(3)|ui(3)>, L<ui_create(3)|ui_create(3)>
49
50=head1 AUTHOR
51
52Richard Levitte (richard@levitte.org) for the OpenSSL project
53(http://www.openssl.org).
54
55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
new file mode 100644
index 0000000000..2a98739114
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_COMP_add_compression_method.pod
@@ -0,0 +1,70 @@
1=pod
2
3=head1 NAME
4
5SSL_COMP_add_compression_method - handle SSL/TLS integrated compression methods
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);
12
13=head1 DESCRIPTION
14
15SSL_COMP_add_compression_method() adds the compression method B<cm> with
16the identifier B<id> to the list of available compression methods. This
17list is globally maintained for all SSL operations within this application.
18It cannot be set for specific SSL_CTX or SSL objects.
19
20=head1 NOTES
21
22The TLS standard (or SSLv3) allows the integration of compression methods
23into the communication. The TLS RFC does however not specify compression
24methods or their corresponding identifiers, so there is currently no compatible
25way to integrate compression with unknown peers. It is therefore currently not
26recommended to integrate compression into applications. Applications for
27non-public use may agree on certain compression methods. Using different
28compression methods with the same identifier will lead to connection failure.
29
30An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1)
31will unconditionally send the list of all compression methods enabled with
32SSL_COMP_add_compression_method() to the server during the handshake.
33Unlike the mechanisms to set a cipher list, there is no method available to
34restrict the list of compression method on a per connection basis.
35
36An OpenSSL server will match the identifiers listed by a client against
37its own compression methods and will unconditionally activate compression
38when a matching identifier is found. There is no way to restrict the list
39of compression methods supported on a per connection basis.
40
41The OpenSSL library has the compression methods B<COMP_rle()> and (when
42especially enabled during compilation) B<COMP_zlib()> available.
43
44=head1 WARNINGS
45
46Once the identities of the compression methods for the TLS protocol have
47been standardized, the compression API will most likely be changed. Using
48it in the current state is not recommended.
49
50=head1 RETURN VALUES
51
52SSL_COMP_add_compression_method() may return the following values:
53
54=over 4
55
56=item 1
57
58The operation succeeded.
59
60=item 0
61
62The operation failed. Check the error queue to find out the reason.
63
64=back
65
66=head1 SEE ALSO
67
68L<ssl(3)|ssl(3)>
69
70=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
index 21a9db0e2a..ee28f5ccc3 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_add_extra_chain_cert.pod
@@ -33,6 +33,7 @@ error stack to find out the reason for failure otherwise.
33 33
34L<ssl(3)|ssl(3)>, 34L<ssl(3)|ssl(3)>,
35L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 35L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
36L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
36L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)> 37L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
37 38
38=cut 39=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
new file mode 100644
index 0000000000..fb6adcf50c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_ctrl.pod
@@ -0,0 +1,34 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_ctrl, SSL_CTX_callback_ctrl, SSL_ctrl, SSL_callback_ctrl - internal handling functions for SSL_CTX and SSL objects
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
12 long SSL_CTX_callback_ctrl(SSL_CTX *, int cmd, void (*fp)());
13
14 long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
15 long SSL_callback_ctrl(SSL *, int cmd, void (*fp)());
16
17=head1 DESCRIPTION
18
19The SSL_*_ctrl() family of functions is used to manipulate settings of
20the SSL_CTX and SSL objects. Depending on the command B<cmd> the arguments
21B<larg>, B<parg>, or B<fp> are evaluated. These functions should never
22be called directly. All functionalities needed are made available via
23other functions or macros.
24
25=head1 RETURN VALUES
26
27The return values of the SSL*_ctrl() functions depend on the command
28supplied via the B<cmd> parameter.
29
30=head1 SEE ALSO
31
32L<ssl(3)|ssl(3)>
33
34=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
index c716cde164..55e592f5f8 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_free.pod
@@ -24,6 +24,8 @@ the certificates and keys.
24 24
25SSL_CTX_free() does not provide diagnostic information. 25SSL_CTX_free() does not provide diagnostic information.
26 26
27=head1 SEE ALSO
28
27L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)> 29L<SSL_CTX_new(3)|SSL_CTX_new(3)>, L<ssl(3)|ssl(3)>
28 30
29=cut 31=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
index 0f63537e78..84a799fc71 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_load_verify_locations.pod
@@ -58,7 +58,7 @@ failure.
58In server mode, when requesting a client certificate, the server must send 58In server mode, when requesting a client certificate, the server must send
59the list of CAs of which it will accept client certificates. This list 59the list of CAs of which it will accept client certificates. This list
60is not influenced by the contents of B<CAfile> or B<CApath> and must 60is not influenced by the contents of B<CAfile> or B<CApath> and must
61explicitely be set using the 61explicitly be set using the
62L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)> 62L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>
63family of functions. 63family of functions.
64 64
@@ -118,7 +118,7 @@ L<ssl(3)|ssl(3)>,
118L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>, 118L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
119L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>, 119L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
120L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 120L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
121L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)> 121L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
122 122L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>
123 123
124=cut 124=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
index 1dae8b0bdd..465220a75c 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_new.pod
@@ -59,10 +59,6 @@ choice when compatibility is a concern.
59 59
60=back 60=back
61 61
62If a generic method is used, it is necessary to explicitly set client or
63server mode with L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
64or SSL_set_accept_state().
65
66The list of protocols available can later be limited using the SSL_OP_NO_SSLv2, 62The list of protocols available can later be limited using the SSL_OP_NO_SSLv2,
67SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1 options of the B<SSL_CTX_set_options()> or 63SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1 options of the B<SSL_CTX_set_options()> or
68B<SSL_set_options()> functions. Using these options it is possible to choose 64B<SSL_set_options()> functions. Using these options it is possible to choose
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
index b6f15b4404..6e0ef00632 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_sess_set_get_cb.pod
@@ -70,12 +70,16 @@ proposed by the client. The get_session_cb() is always called, also when
70session caching was disabled. The get_session_cb() is passed the 70session caching was disabled. The get_session_cb() is passed the
71B<ssl> connection, the session id of length B<length> at the memory location 71B<ssl> connection, the session id of length B<length> at the memory location
72B<data>. With the parameter B<copy> the callback can require the 72B<data>. With the parameter B<copy> the callback can require the
73SSL engine to increment the reference count of the SSL_SESSION object. 73SSL engine to increment the reference count of the SSL_SESSION object,
74Normally the reference count is not incremented and therefore the
75session must not be explicitly freed with
76L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
74 77
75=head1 SEE ALSO 78=head1 SEE ALSO
76 79
77L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>, 80L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
78L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 81L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
79L<SSL_CTX_flush_sessions(3)|<SSL_CTX_flush_sessions(3)> 82L<SSL_CTX_flush_sessions(3)|<SSL_CTX_flush_sessions(3)>,
83L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
80 84
81=cut 85=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
new file mode 100644
index 0000000000..81286ee650
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_store.pod
@@ -0,0 +1,57 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_store, SSL_CTX_get_cert_store - manipulate X509 certificate verification storage
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store);
12 X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx);
13
14=head1 DESCRIPTION
15
16SSL_CTX_set_cert_store() sets/replaces the certificate verification storage
17of B<ctx> to/with B<store>. If another X505_STORE object is currently
18set in B<ctx>, it will be X509_STORE_free()ed.
19
20SSL_CTX_get_cert_store() returns a pointer to the current certificate
21verification storage.
22
23=head1 NOTES
24
25In order to verify the certificates presented by the peer, trusted CA
26certificates must be accessed. These CA certificates are made available
27via lookup methods, handled inside the X509_STORE. From the X509_STORE
28the X509_STORE_CTX used when verifying certificates is created.
29
30Typically the trusted certificate store is handled indirectly via using
31L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>.
32Using the SSL_CTX_set_cert_store() and SSL_CTX_get_cert_store() functions
33it is possible to manipulate the X509_STORE object beyond the
34L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
35call.
36
37Currently no detailed documentation on how to use the X509_STORE
38object is available. Not all members of the X509_STORE are used when
39the verification takes place. So will e.g. the verify_callback() be
40overridden with the verify_callback() set via the
41L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)> family of functions.
42This document must therefore be updated when documentation about the
43X509_STORE object and its handling becomes available.
44
45=head1 RETURN VALUES
46
47SSL_CTX_set_cert_store() does not return diagnostic output.
48
49SSL_CTX_get_cert_store() returns the current setting.
50
51=head1 SEE ALSO
52
53L<ssl(3)|ssl(3)>,
54L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
55L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
56
57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
new file mode 100644
index 0000000000..c0f4f85708
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cert_verify_callback.pod
@@ -0,0 +1,75 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_cert_verify_callback - set peer certificate verification procedure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *,void *), void *arg);
12
13=head1 DESCRIPTION
14
15SSL_CTX_set_cert_verify_callback() sets the verification callback function for
16I<ctx>. SSL objects that are created from I<ctx> inherit the setting valid at
17the time when L<SSL_new(3)|SSL_new(3)> is called.
18
19=head1 NOTES
20
21Whenever a certificate is verified during a SSL/TLS handshake, a verification
22function is called. If the application does not explicitly specify a
23verification callback function, the built-in verification function is used.
24If a verification callback I<callback> is specified via
25SSL_CTX_set_cert_verify_callback(), the supplied callback function is called
26instead. By setting I<callback> to NULL, the default behaviour is restored.
27
28When the verification must be performed, I<callback> will be called with
29the arguments callback(X509_STORE_CTX *x509_store_ctx, void *arg). The
30argument I<arg> is specified by the application when setting I<callback>.
31
32I<callback> should return 1 to indicate verification success and 0 to
33indicate verification failure. If SSL_VERIFY_PEER is set and I<callback>
34returns 0, the handshake will fail. As the verification procedure may
35allow to continue the connection in case of failure (by always returning 1)
36the verification result must be set in any case using the B<error>
37member of I<x509_store_ctx> so that the calling application will be informed
38about the detailed result of the verification procedure!
39
40Within I<x509_store_ctx>, I<callback> has access to the I<verify_callback>
41function set using L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>.
42
43=head1 WARNINGS
44
45Do not mix the verification callback described in this function with the
46B<verify_callback> function called during the verification process. The
47latter is set using the L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
48family of functions.
49
50Providing a complete verification procedure including certificate purpose
51settings etc is a complex task. The built-in procedure is quite powerful
52and in most cases it should be sufficient to modify its behaviour using
53the B<verify_callback> function.
54
55=head1 BUGS
56
57=head1 RETURN VALUES
58
59SSL_CTX_set_cert_verify_callback() does not provide diagnostic information.
60
61=head1 SEE ALSO
62
63L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
64L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
65L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
66
67=head1 HISTORY
68
69Previous to OpenSSL 0.9.7, the I<arg> argument to B<SSL_CTX_set_cert_verify_callback>
70was ignored, and I<callback> was called simply as
71 int (*callback)(X509_STORE_CTX *)
72To compile software written for previous versions of OpenSSL, a dummy
73argument will have to be added to I<callback>.
74
75=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
index 9a29eeeb95..ed64f64157 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_cipher_list.pod
@@ -34,9 +34,25 @@ a necessary condition. On the client side, the inclusion into the list is
34also sufficient. On the server side, additional restrictions apply. All ciphers 34also sufficient. On the server side, additional restrictions apply. All ciphers
35have additional requirements. ADH ciphers don't need a certificate, but 35have additional requirements. ADH ciphers don't need a certificate, but
36DH-parameters must have been set. All other ciphers need a corresponding 36DH-parameters must have been set. All other ciphers need a corresponding
37certificate and key. A RSA cipher can only be chosen, when a RSA certificate is 37certificate and key.
38available, the respective is valid for DSA ciphers. Ciphers using EDH need 38
39a certificate and key and DH-parameters. 39A RSA cipher can only be chosen, when a RSA certificate is available.
40RSA export ciphers with a keylength of 512 bits for the RSA key require
41a temporary 512 bit RSA key, as typically the supplied key has a length
42of 1024 bit (see
43L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
44RSA ciphers using EDH need a certificate and key and additional DH-parameters
45(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
46
47A DSA cipher can only be chosen, when a DSA certificate is available.
48DSA ciphers always use DH key exchange and therefore need DH-parameters
49(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
50
51When these conditions are not met for any cipher in the list (e.g. a
52client only supports export RSA ciphers with a asymmetric key length
53of 512 bits and the server is not configured to use temporary RSA
54keys), the "no shared cipher" (SSL_R_NO_SHARED_CIPHER) error is generated
55and the handshake will fail.
40 56
41=head1 RETURN VALUES 57=head1 RETURN VALUES
42 58
@@ -47,6 +63,8 @@ could be selected and 0 on complete failure.
47 63
48L<ssl(3)|ssl(3)>, L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, 64L<ssl(3)|ssl(3)>, L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
49L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 65L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
66L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
67L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
50L<ciphers(1)|ciphers(1)> 68L<ciphers(1)|ciphers(1)>
51 69
52=cut 70=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
new file mode 100644
index 0000000000..53e1827713
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_client_cert_cb.pod
@@ -0,0 +1,90 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - handle client certificate callback function
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
12 int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
13 int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
14
15=head1 DESCRIPTION
16
17SSL_CTX_set_client_cert_cb() sets the B<client_cert_cb()> callback, that is
18called when a client certificate is requested by a server.
19When B<client_cert_cb()> is NULL, not callback function is used.
20
21SSL_CTX_get_client_cert_cb() returns a pointer to the currently set callback
22function.
23
24client_cert_cb() is the application defined callback. If it wants to
25set a certificate, a certificate/private key combination must be set
26using the B<x509> and B<pkey> arguments and "1" must be returned. The
27certificate will be installed into B<ssl>, see the NOTES and BUGS sections.
28If no certificate should be set, "0" has to be returned and the default
29certificate will be sent. A fatal error can be indicated by returning
30a negative value, in which case the handshake will be canceled.
31
32=head1 NOTES
33
34During a handshake (or renegotiation) a server may request a certificate
35from the client. A client certificate must only be sent, when the server
36did send the request.
37
38When no callback function is set, an OpenSSL client will send the certificate
39that was set using the
40L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)> family of functions.
41The TLS standard requires that only a certificate is sent, if it matches
42the list of acceptable CAs sent by the server. This constraint is
43violated by the default behavior of the OpenSSL library. Using the
44callback function it is possible to implement a proper selection routine
45or to allow a user interaction to choose the certificate to be sent.
46The callback function can obtain the list of acceptable CAs using the
47L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)> function.
48
49If a callback function is defined, the callback function will be called.
50If the callback function returns a certificate, the OpenSSL library
51will try to load the private key and certificate data into the SSL
52object using SSL_use_certificate() and SSL_use_private_key() functions.
53Thus it will permanently override the certificate and key previously
54installed and will not be reset by calling L<SSL_clear(3)|SSL_clear(3)>.
55If the callback returns no certificate, the OpenSSL library will send
56the certificate previously installed for the SSL_CTX object or the specific
57certificate of the SSL object, if available.
58
59=head1 BUGS
60
61The client_cert_cb() cannot return a complete certificate chain, it can
62only return one client certificate. If the chain only has a length of 2,
63the root CA certificate may be omitted according to the TLS standard and
64thus a standard conforming answer can be sent to the server. For a
65longer chain, the client must send the complete chain (with the option
66to leave out the root CA certificate). This can only be accomplished by
67either adding the intermediate CA certificates into the trusted
68certificate store for the SSL_CTX object (resulting in having to add
69CA certificates that otherwise maybe would not be trusted), or by adding
70the chain certificates using the
71L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
72function, which is only available for the SSL_CTX object as a whole and that
73therefore probably can only apply for one client certificate, making
74the concept of the callback function (to allow the choice from several
75certificates) questionable.
76
77Once the SSL object has been used in conjunction with the callback function,
78the certificate will be set for the SSL object and will not be cleared
79even when L<SSL_clear(3)|SSL_clear(3)> is being called. It is therefore
80mandatory to destroy the SSL object using L<SSL_free(3)|SSL_free(3)>
81and create a new one to return to the previous state.
82
83=head1 SEE ALSO
84
85L<ssl(3)|ssl(3)>, L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
86L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
87L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
88L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
89
90=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
index a5343a1cf3..2b87f01ca1 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_default_passwd_cb.pod
@@ -40,6 +40,12 @@ then keep it in memory and use it several times. In the last case, the
40password could be stored into the B<userdata> storage and the 40password could be stored into the B<userdata> storage and the
41pem_passwd_cb() only returns the password already stored. 41pem_passwd_cb() only returns the password already stored.
42 42
43When asking for the password interactively, pem_passwd_cb() can use
44B<rwflag> to check, whether an item shall be encrypted (rwflag=1).
45In this case the password dialog may ask for the same password twice
46for comparison in order to catch typos, that would make decryption
47impossible.
48
43Other items in PEM formatting (certificates) can also be encrypted, it is 49Other items in PEM formatting (certificates) can also be encrypted, it is
44however not usual, as certificate information is considered public. 50however not usual, as certificate information is considered public.
45 51
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
new file mode 100644
index 0000000000..798e8443a7
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_generate_session_id.pod
@@ -0,0 +1,150 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_generate_session_id, SSL_set_generate_session_id, SSL_has_matching_session_id - manipulate generation of SSL session IDs (server only)
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
12 unsigned int *id_len);
13
14 int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);
15 int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB, cb);
16 int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
17 unsigned int id_len);
18
19=head1 DESCRIPTION
20
21SSL_CTX_set_generate_session_id() sets the callback function for generating
22new session ids for SSL/TLS sessions for B<ctx> to be B<cb>.
23
24SSL_set_generate_session_id() sets the callback function for generating
25new session ids for SSL/TLS sessions for B<ssl> to be B<cb>.
26
27SSL_has_matching_session_id() checks, whether a session with id B<id>
28(of length B<id_len>) is already contained in the internal session cache
29of the parent context of B<ssl>.
30
31=head1 NOTES
32
33When a new session is established between client and server, the server
34generates a session id. The session id is an arbitrary sequence of bytes.
35The length of the session id is 16 bytes for SSLv2 sessions and between
361 and 32 bytes for SSLv3/TLSv1. The session id is not security critical
37but must be unique for the server. Additionally, the session id is
38transmitted in the clear when reusing the session so it must not contain
39sensitive information.
40
41Without a callback being set, an OpenSSL server will generate a unique
42session id from pseudo random numbers of the maximum possible length.
43Using the callback function, the session id can be changed to contain
44additional information like e.g. a host id in order to improve load balancing
45or external caching techniques.
46
47The callback function receives a pointer to the memory location to put
48B<id> into and a pointer to the maximum allowed length B<id_len>. The
49buffer at location B<id> is only guaranteed to have the size B<id_len>.
50The callback is only allowed to generate a shorter id and reduce B<id_len>;
51the callback B<must never> increase B<id_len> or write to the location
52B<id> exceeding the given limit.
53
54If a SSLv2 session id is generated and B<id_len> is reduced, it will be
55restored after the callback has finished and the session id will be padded
56with 0x00. It is not recommended to change the B<id_len> for SSLv2 sessions.
57The callback can use the L<SSL_get_version(3)|SSL_get_version(3)> function
58to check, whether the session is of type SSLv2.
59
60The location B<id> is filled with 0x00 before the callback is called, so the
61callback may only fill part of the possible length and leave B<id_len>
62untouched while maintaining reproducibility.
63
64Since the sessions must be distinguished, session ids must be unique.
65Without the callback a random number is used, so that the probability
66of generating the same session id is extremely small (2^128 possible ids
67for an SSLv2 session, 2^256 for SSLv3/TLSv1). In order to assure the
68uniqueness of the generated session id, the callback must call
69SSL_has_matching_session_id() and generate another id if a conflict occurs.
70If an id conflict is not resolved, the handshake will fail.
71If the application codes e.g. a unique host id, a unique process number, and
72a unique sequence number into the session id, uniqueness could easily be
73achieved without randomness added (it should however be taken care that
74no confidential information is leaked this way). If the application can not
75guarantee uniqueness, it is recommended to use the maximum B<id_len> and
76fill in the bytes not used to code special information with random data
77to avoid collisions.
78
79SSL_has_matching_session_id() will only query the internal session cache,
80not the external one. Since the session id is generated before the
81handshake is completed, it is not immediately added to the cache. If
82another thread is using the same internal session cache, a race condition
83can occur in that another thread generates the same session id.
84Collisions can also occur when using an external session cache, since
85the external cache is not tested with SSL_has_matching_session_id()
86and the same race condition applies.
87
88When calling SSL_has_matching_session_id() for an SSLv2 session with
89reduced B<id_len>, the match operation will be performed using the
90fixed length required and with a 0x00 padded id.
91
92The callback must return 0 if it cannot generate a session id for whatever
93reason and return 1 on success.
94
95=head1 EXAMPLES
96
97The callback function listed will generate a session id with the
98server id given, and will fill the rest with pseudo random bytes:
99
100 const char session_id_prefix = "www-18";
101
102 #define MAX_SESSION_ID_ATTEMPTS 10
103 static int generate_session_id(const SSL *ssl, unsigned char *id,
104 unsigned int *id_len)
105 {
106 unsigned int count = 0;
107 const char *version;
108
109 version = SSL_get_version(ssl);
110 if (!strcmp(version, "SSLv2"))
111 /* we must not change id_len */;
112
113 do {
114 RAND_pseudo_bytes(id, *id_len);
115 /* Prefix the session_id with the required prefix. NB: If our
116 * prefix is too long, clip it - but there will be worse effects
117 * anyway, eg. the server could only possibly create 1 session
118 * ID (ie. the prefix!) so all future session negotiations will
119 * fail due to conflicts. */
120 memcpy(id, session_id_prefix,
121 (strlen(session_id_prefix) < *id_len) ?
122 strlen(session_id_prefix) : *id_len);
123 }
124 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
125 (++count < MAX_SESSION_ID_ATTEMPTS));
126 if(count >= MAX_SESSION_ID_ATTEMPTS)
127 return 0;
128 return 1;
129 }
130
131
132=head1 RETURN VALUES
133
134SSL_CTX_set_generate_session_id() and SSL_set_generate_session_id()
135always return 1.
136
137SSL_has_matching_session_id() returns 1 if another session with the
138same id is already in the cache.
139
140=head1 SEE ALSO
141
142L<ssl(3)|ssl(3)>, L<SSL_get_version(3)|SSL_get_version(3)>
143
144=head1 HISTORY
145
146SSL_CTX_set_generate_session_id(), SSL_set_generate_session_id()
147and SSL_has_matching_session_id() have been introduced in
148OpenSSL 0.9.7.
149
150=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
new file mode 100644
index 0000000000..63d0b8d33f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_info_callback.pod
@@ -0,0 +1,153 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback - handle information callback for SSL connections
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)());
12 void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))();
13
14 void SSL_set_info_callback(SSL *ssl, void (*callback)());
15 void (*SSL_get_info_callback(SSL *ssl))();
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_info_callback() sets the B<callback> function, that can be used to
20obtain state information for SSL objects created from B<ctx> during connection
21setup and use. The setting for B<ctx> is overridden from the setting for
22a specific SSL object, if specified.
23When B<callback> is NULL, not callback function is used.
24
25SSL_set_info_callback() sets the B<callback> function, that can be used to
26obtain state information for B<ssl> during connection setup and use.
27When B<callback> is NULL, the callback setting currently valid for
28B<ctx> is used.
29
30SSL_CTX_get_info_callback() returns a pointer to the currently set information
31callback function for B<ctx>.
32
33SSL_get_info_callback() returns a pointer to the currently set information
34callback function for B<ssl>.
35
36=head1 NOTES
37
38When setting up a connection and during use, it is possible to obtain state
39information from the SSL/TLS engine. When set, an information callback function
40is called whenever the state changes, an alert appears, or an error occurs.
41
42The callback function is called as B<callback(SSL *ssl, int where, int ret)>.
43The B<where> argument specifies information about where (in which context)
44the callback function was called. If B<ret> is 0, an error condition occurred.
45If an alert is handled, SSL_CB_ALERT is set and B<ret> specifies the alert
46information.
47
48B<where> is a bitmask made up of the following bits:
49
50=over 4
51
52=item SSL_CB_LOOP
53
54Callback has been called to indicate state change inside a loop.
55
56=item SSL_CB_EXIT
57
58Callback has been called to indicate error exit of a handshake function.
59(May be soft error with retry option for non-blocking setups.)
60
61=item SSL_CB_READ
62
63Callback has been called during read operation.
64
65=item SSL_CB_WRITE
66
67Callback has been called during write operation.
68
69=item SSL_CB_ALERT
70
71Callback has been called due to an alert being sent or received.
72
73=item SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
74
75=item SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
76
77=item SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
78
79=item SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
80
81=item SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
82
83=item SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
84
85=item SSL_CB_HANDSHAKE_START
86
87Callback has been called because a new handshake is started.
88
89=item SSL_CB_HANDSHAKE_DONE 0x20
90
91Callback has been called because a handshake is finished.
92
93=back
94
95The current state information can be obtained using the
96L<SSL_state_string(3)|SSL_state_string(3)> family of functions.
97
98The B<ret> information can be evaluated using the
99L<SSL_alert_type_string(3)|SSL_alert_type_string(3)> family of functions.
100
101=head1 RETURN VALUES
102
103SSL_set_info_callback() does not provide diagnostic information.
104
105SSL_get_info_callback() returns the current setting.
106
107=head1 EXAMPLES
108
109The following example callback function prints state strings, information
110about alerts being handled and error messages to the B<bio_err> BIO.
111
112 void apps_ssl_info_callback(SSL *s, int where, int ret)
113 {
114 const char *str;
115 int w;
116
117 w=where& ~SSL_ST_MASK;
118
119 if (w & SSL_ST_CONNECT) str="SSL_connect";
120 else if (w & SSL_ST_ACCEPT) str="SSL_accept";
121 else str="undefined";
122
123 if (where & SSL_CB_LOOP)
124 {
125 BIO_printf(bio_err,"%s:%s\n",str,SSL_state_string_long(s));
126 }
127 else if (where & SSL_CB_ALERT)
128 {
129 str=(where & SSL_CB_READ)?"read":"write";
130 BIO_printf(bio_err,"SSL3 alert %s:%s:%s\n",
131 str,
132 SSL_alert_type_string_long(ret),
133 SSL_alert_desc_string_long(ret));
134 }
135 else if (where & SSL_CB_EXIT)
136 {
137 if (ret == 0)
138 BIO_printf(bio_err,"%s:failed in %s\n",
139 str,SSL_state_string_long(s));
140 else if (ret < 0)
141 {
142 BIO_printf(bio_err,"%s:error in %s\n",
143 str,SSL_state_string_long(s));
144 }
145 }
146 }
147
148=head1 SEE ALSO
149
150L<ssl(3)|ssl(3)>, L<SSL_state_string(3)|SSL_state_string(3)>,
151L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>
152
153=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
new file mode 100644
index 0000000000..da68cb9fc2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_max_cert_list.pod
@@ -0,0 +1,77 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_max_cert_list, SSL_CTX_get_max_cert_list, SSL_set_max_cert_list, SSL_get_max_cert_list, - manipulate allowed for the peer's certificate chain
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_CTX_set_max_cert_list(SSL_CTX *ctx, long size);
12 long SSL_CTX_get_max_cert_list(SSL_CTX *ctx);
13
14 long SSL_set_max_cert_list(SSL *ssl, long size);
15 long SSL_get_max_cert_list(SSL *ctx);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_max_cert_list() sets the maximum size allowed for the peer's
20certificate chain for all SSL objects created from B<ctx> to be <size> bytes.
21The SSL objects inherit the setting valid for B<ctx> at the time
22L<SSL_new(3)|SSL_new(3)> is being called.
23
24SSL_CTX_get_max_cert_list() returns the currently set maximum size for B<ctx>.
25
26SSL_set_max_cert_list() sets the maximum size allowed for the peer's
27certificate chain for B<ssl> to be <size> bytes. This setting stays valid
28until a new value is set.
29
30SSL_get_max_cert_list() returns the currently set maximum size for B<ssl>.
31
32=head1 NOTES
33
34During the handshake process, the peer may send a certificate chain.
35The TLS/SSL standard does not give any maximum size of the certificate chain.
36The OpenSSL library handles incoming data by a dynamically allocated buffer.
37In order to prevent this buffer from growing without bounds due to data
38received from a faulty or malicious peer, a maximum size for the certificate
39chain is set.
40
41The default value for the maximum certificate chain size is 100kB (30kB
42on the 16bit DOS platform). This should be sufficient for usual certificate
43chains (OpenSSL's default maximum chain length is 10, see
44L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>, and certificates
45without special extensions have a typical size of 1-2kB).
46
47For special applications it can be necessary to extend the maximum certificate
48chain size allowed to be sent by the peer, see e.g. the work on
49"Internet X.509 Public Key Infrastructure Proxy Certificate Profile"
50and "TLS Delegation Protocol" at http://www.ietf.org/ and
51http://www.globus.org/ .
52
53Under normal conditions it should never be necessary to set a value smaller
54than the default, as the buffer is handled dynamically and only uses the
55memory actually required by the data sent by the peer.
56
57If the maximum certificate chain size allowed is exceeded, the handshake will
58fail with a SSL_R_EXCESSIVE_MESSAGE_SIZE error.
59
60=head1 RETURN VALUES
61
62SSL_CTX_set_max_cert_list() and SSL_set_max_cert_list() return the previously
63set value.
64
65SSL_CTX_get_max_cert_list() and SSL_get_max_cert_list() return the currently
66set value.
67
68=head1 SEE ALSO
69
70L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>,
71L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
72
73=head1 HISTORY
74
75SSL*_set/get_max_cert_list() have been introduced in OpenSSL 0.9.7.
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
index 9a035bb4d1..9822544e5e 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_mode.pod
@@ -37,6 +37,9 @@ The following mode changes are available:
37Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success 37Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
38when just a single record has been written). When not set (the default), 38when just a single record has been written). When not set (the default),
39SSL_write() will only report success once the complete chunk was written. 39SSL_write() will only report success once the complete chunk was written.
40Once SSL_write() returns with r, r bytes have been successfully written
41and the next call to SSL_write() must only send the n-r bytes left,
42imitating the behaviour of write().
40 43
41=item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 44=item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
42 45
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
new file mode 100644
index 0000000000..a423932d0a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_msg_callback.pod
@@ -0,0 +1,97 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg, SSL_set_msg_callback, SSL_get_msg_callback_arg - install callback for observing protocol messages
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
12 void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
13
14 void SSL_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
15 void SSL_set_msg_callback_arg(SSL_CTX *ctx, void *arg);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_msg_callback() or SSL_set_msg_callback() can be used to
20define a message callback function I<cb> for observing all SSL/TLS
21protocol messages (such as handshake messages) that are received or
22sent. SSL_CTX_set_msg_callback_arg() and SSL_set_msg_callback_arg()
23can be used to set argument I<arg> to the callback function, which is
24available for arbitrary application use.
25
26SSL_CTX_set_msg_callback() and SSL_CTX_set_msg_callback_arg() specify
27default settings that will be copied to new B<SSL> objects by
28L<SSL_new(3)|SSL_new(3)>. SSL_set_msg_callback() and
29SSL_set_msg_callback_arg() modify the actual settings of an B<SSL>
30object. Using a B<0> pointer for I<cb> disables the message callback.
31
32When I<cb> is called by the SSL/TLS library for a protocol message,
33the function arguments have the following meaning:
34
35=over 4
36
37=item I<write_p>
38
39This flag is B<0> when a protocol message has been received and B<1>
40when a protocol message has been sent.
41
42=item I<version>
43
44The protocol version according to which the protocol message is
45interpreted by the library. Currently, this is one of
46B<SSL2_VERSION>, B<SSL3_VERSION> and B<TLS1_VERSION> (for SSL 2.0, SSL
473.0 and TLS 1.0, respectively).
48
49=item I<content_type>
50
51In the case of SSL 2.0, this is always B<0>. In the case of SSL 3.0
52or TLS 1.0, this is one of the B<ContentType> values defined in the
53protocol specification (B<change_cipher_spec(20)>, B<alert(21)>,
54B<handshake(22)>; but never B<application_data(23)> because the
55callback will only be called for protocol messages).
56
57=item I<buf>, I<len>
58
59I<buf> points to a buffer containing the protocol message, which
60consists of I<len> bytes. The buffer is no longer valid after the
61callback function has returned.
62
63=item I<ssl>
64
65The B<SSL> object that received or sent the message.
66
67=item I<arg>
68
69The user-defined argument optionally defined by
70SSL_CTX_set_msg_callback_arg() or SSL_set_msg_callback_arg().
71
72=head1 NOTES
73
74Protocol messages are passed to the callback function after decryption
75and fragment collection where applicable. (Thus record boundaries are
76not visible.)
77
78If processing a received protocol message results in an error,
79the callback function may not be called. For example, the callback
80function will never see messages that are considered too large to be
81processed.
82
83Due to automatic protocol version negotiation, I<version> is not
84necessarily the protocol version used by the sender of the message: If
85a TLS 1.0 ClientHello message is received by an SSL 3.0-only server,
86I<version> will be B<SSL3_VERSION>.
87
88=head1 SEE ALSO
89
90L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
91
92=head1 HISTORY
93
94SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(),
95SSL_set_msg_callback() and SSL_get_msg_callback_arg() were added in OpenSSL 0.9.7.
96
97=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
index 3dc7cc74ad..c10055c6e7 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_options.pod
@@ -17,10 +17,10 @@ SSL_CTX_set_options, SSL_set_options, SSL_CTX_get_options, SSL_get_options - man
17=head1 DESCRIPTION 17=head1 DESCRIPTION
18 18
19SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>. 19SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>.
20Options already set before are not cleared. 20Options already set before are not cleared!
21 21
22SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>. 22SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>.
23Options already set before are not cleared. 23Options already set before are not cleared!
24 24
25SSL_CTX_get_options() returns the options set for B<ctx>. 25SSL_CTX_get_options() returns the options set for B<ctx>.
26 26
@@ -32,7 +32,12 @@ The behaviour of the SSL library can be changed by setting several options.
32The options are coded as bitmasks and can be combined by a logical B<or> 32The options are coded as bitmasks and can be combined by a logical B<or>
33operation (|). Options can only be added but can never be reset. 33operation (|). Options can only be added but can never be reset.
34 34
35During a handshake, the option settings of the SSL object used. When 35SSL_CTX_set_options() and SSL_set_options() affect the (external)
36protocol behaviour of the SSL library. The (internal) behaviour of
37the API can be changed by using the similar
38L<SSL_CTX_set_modes(3)|SSL_CTX_set_modes(3)> and SSL_set_modes() functions.
39
40During a handshake, the option settings of the SSL object are used. When
36a new SSL object is created from a context using SSL_new(), the current 41a new SSL object is created from a context using SSL_new(), the current
37option setting is copied. Changes to B<ctx> do not affect already created 42option setting is copied. Changes to B<ctx> do not affect already created
38SSL objects. SSL_clear() does not affect the settings. 43SSL objects. SSL_clear() does not affect the settings.
@@ -95,38 +100,62 @@ doing a re-connect, always takes the first cipher in the cipher list.
95 100
96... 101...
97 102
98=item SSL_OP_TLS_ROLLBACK_BUG
99
100Disable version rollback attack detection.
101
102During the client key exchange, the client must send the same information
103about acceptable SSL/TLS protocol levels as during the first hello. Some
104clients violate this rule by adapting to the server's answer. (Example:
105the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
106only understands up to SSLv3. In this case the client must still use the
107same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
108to the server's answer and violate the version rollback protection.)
109
110=item SSL_OP_ALL 103=item SSL_OP_ALL
111 104
112All of the above bug workarounds. 105All of the above bug workarounds.
113 106
114=back 107=back
115 108
116It is save and recommended to use SSL_OP_ALL to enable the bug workaround 109It is safe and recommended to use B<SSL_OP_ALL> to enable the bug workaround
117options. 110options.
118 111
119The following B<modifying> options are available: 112The following B<modifying> options are available:
120 113
121=over 4 114=over 4
122 115
116=item SSL_OP_TLS_ROLLBACK_BUG
117
118Disable version rollback attack detection.
119
120During the client key exchange, the client must send the same information
121about acceptable SSL/TLS protocol levels as during the first hello. Some
122clients violate this rule by adapting to the server's answer. (Example:
123the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
124only understands up to SSLv3. In this case the client must still use the
125same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
126to the server's answer and violate the version rollback protection.)
127
123=item SSL_OP_SINGLE_DH_USE 128=item SSL_OP_SINGLE_DH_USE
124 129
125Always create a new key when using temporary DH parameters. 130Always create a new key when using temporary/ephemeral DH parameters
131(see L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
132This option must be used to prevent small subgroup attacks, when
133the DH parameters were not generated using "strong" primes
134(e.g. when using DSA-parameters, see L<dhparam(1)|dhparam(1)>).
135If "strong" primes were used, it is not strictly necessary to generate
136a new DH key during each handshake but it is also recommended.
137B<SSL_OP_SINGLE_DH_USE> should therefore be enabled whenever
138temporary/ephemeral DH parameters are used.
126 139
127=item SSL_OP_EPHEMERAL_RSA 140=item SSL_OP_EPHEMERAL_RSA
128 141
129Also use the temporary RSA key when doing RSA operations. 142Always use ephemeral (temporary) RSA key when doing RSA operations
143(see L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>).
144According to the specifications this is only done, when a RSA key
145can only be used for signature operations (namely under export ciphers
146with restricted RSA keylength). By setting this option, ephemeral
147RSA keys are always used. This option breaks compatibility with the
148SSL/TLS specifications and may lead to interoperability problems with
149clients and should therefore never be used. Ciphers with EDH (ephemeral
150Diffie-Hellman) key exchange should be used instead.
151
152=item SSL_OP_CIPHER_SERVER_PREFERENCE
153
154When choosing a cipher, use the server's preferences instead of the client
155preferences. When not set, the SSL server will always follow the clients
156preferences. When set, the SSLv3/TLSv1 server will choose following its
157own preferences. Because of the different protocol, for SSLv2 the server
158will send his list of preferences to the client and the client chooses.
130 159
131=item SSL_OP_PKCS1_CHECK_1 160=item SSL_OP_PKCS1_CHECK_1
132 161
@@ -142,11 +171,6 @@ If we accept a netscape connection, demand a client cert, have a
142non-self-sighed CA which does not have it's CA in netscape, and the 171non-self-sighed CA which does not have it's CA in netscape, and the
143browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta 172browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta
144 173
145=item SSL_OP_NON_EXPORT_FIRST
146
147On servers try to use non-export (stronger) ciphers first. This option does
148not work under all circumstances (in the code it is declared "broken").
149
150=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 174=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
151 175
152... 176...
@@ -163,6 +187,12 @@ Do not use the SSLv3 protocol.
163 187
164Do not use the TLSv1 protocol. 188Do not use the TLSv1 protocol.
165 189
190=item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
191
192When performing renegotiation as a server, always start a new session
193(i.e., session resumption requests are only accepted in the initial
194handshake). This option is not needed for clients.
195
166=back 196=back
167 197
168=head1 RETURN VALUES 198=head1 RETURN VALUES
@@ -174,10 +204,19 @@ SSL_CTX_get_options() and SSL_get_options() return the current bitmask.
174 204
175=head1 SEE ALSO 205=head1 SEE ALSO
176 206
177L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)> 207L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
208L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
209L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
210L<dhparam(1)|dhparam(1)>
178 211
179=head1 HISTORY 212=head1 HISTORY
180 213
181SSL_OP_TLS_ROLLBACK_BUG has been added in OpenSSL 0.9.6. 214B<SSL_OP_CIPHER_SERVER_PREFERENCE> and
215B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> have been added in
216OpenSSL 0.9.7.
217
218B<SSL_OP_TLS_ROLLBACK_BUG> has been added in OpenSSL 0.9.6 and was automatically
219enabled with B<SSL_OP_ALL>. As of 0.9.7, it is no longer included in B<SSL_OP_ALL>
220and must be explicitly set.
182 221
183=cut 222=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
new file mode 100644
index 0000000000..1d0526d59a
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_quiet_shutdown.pod
@@ -0,0 +1,63 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_quiet_shutdown, SSL_CTX_get_quiet_shutdown, SSL_set_quiet_shutdown, SSL_get_quiet_shutdown - manipulate shutdown behaviour
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);
12 int SSL_CTX_get_quiet_shutdown(SSL_CTX *ctx);
13
14 void SSL_set_quiet_shutdown(SSL *ssl, int mode);
15 int SSL_get_quiet_shutdown(SSL *ssl);
16
17=head1 DESCRIPTION
18
19SSL_CTX_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ctx> to be
20B<mode>. SSL objects created from B<ctx> inherit the B<mode> valid at the time
21L<SSL_new(3)|SSL_new(3)> is called. B<mode> may be 0 or 1.
22
23SSL_CTX_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ctx>.
24
25SSL_set_quiet_shutdown() sets the "quiet shutdown" flag for B<ssl> to be
26B<mode>. The setting stays valid until B<ssl> is removed with
27L<SSL_free(3)|SSL_free(3)> or SSL_set_quiet_shutdown() is called again.
28It is not changed when L<SSL_clear(3)|SSL_clear(3)> is called.
29B<mode> may be 0 or 1.
30
31SSL_get_quiet_shutdown() returns the "quiet shutdown" setting of B<ssl>.
32
33=head1 NOTES
34
35Normally when a SSL connection is finished, the parties must send out
36"close notify" alert messages using L<SSL_shutdown(3)|SSL_shutdown(3)>
37for a clean shutdown.
38
39When setting the "quiet shutdown" flag to 1, L<SSL_shutdown(3)|SSL_shutdown(3)>
40will set the internal flags to SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.
41(L<SSL_shutdown(3)|SSL_shutdown(3)> then behaves like
42L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> called with
43SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.)
44The session is thus considered to be shutdown, but no "close notify" alert
45is sent to the peer. This behaviour violates the TLS standard.
46
47The default is normal shutdown behaviour as described by the TLS standard.
48
49=head1 RETURN VALUES
50
51SSL_CTX_set_quiet_shutdown() and SSL_set_quiet_shutdown() do not return
52diagnostic information.
53
54SSL_CTX_get_quiet_shutdown() and SSL_get_quiet_shutdown return the current
55setting.
56
57=head1 SEE ALSO
58
59L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
60L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, L<SSL_new(3)|SSL_new(3)>,
61L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
62
63=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
index 8bbfc78720..9aa6c6b2e3 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_session_cache_mode.pod
@@ -97,6 +97,7 @@ SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
97=head1 SEE ALSO 97=head1 SEE ALSO
98 98
99L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>, 99L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
100L<SSL_session_reused(3)|SSL_session_reused(3)>,
100L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>, 101L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
101L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>, 102L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
102L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>, 103L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
index 21faed12d4..e3de27c473 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_timeout.pod
@@ -37,7 +37,10 @@ L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> is called, either
37directly by the application or automatically (see 37directly by the application or automatically (see
38L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>) 38L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>)
39 39
40The default value for session timeout is 300 seconds. 40The default value for session timeout is decided on a per protocol
41basis, see L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>.
42All currently supported protocols have the same default timeout value
43of 300 seconds.
41 44
42=head1 RETURN VALUES 45=head1 RETURN VALUES
43 46
@@ -50,6 +53,7 @@ SSL_CTX_get_timeout() returns the currently set timeout value.
50L<ssl(3)|ssl(3)>, 53L<ssl(3)|ssl(3)>,
51L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 54L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
52L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>, 55L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
53L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> 56L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
57L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
54 58
55=cut 59=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
new file mode 100644
index 0000000000..29d1f8a6fb
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_dh_callback.pod
@@ -0,0 +1,170 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_dh_callback, SSL_CTX_set_tmp_dh, SSL_set_tmp_dh_callback, SSL_set_tmp_dh - handle DH keys for ephemeral key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
12 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
13 long SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh);
14
15 void SSL_set_tmp_dh_callback(SSL_CTX *ctx,
16 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
17 long SSL_set_tmp_dh(SSL *ssl, DH *dh)
18
19 DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength));
20
21=head1 DESCRIPTION
22
23SSL_CTX_set_tmp_dh_callback() sets the callback function for B<ctx> to be
24used when a DH parameters are required to B<tmp_dh_callback>.
25The callback is inherited by all B<ssl> objects created from B<ctx>.
26
27SSL_CTX_set_tmp_dh() sets DH parameters to be used to be B<dh>.
28The key is inherited by all B<ssl> objects created from B<ctx>.
29
30SSL_set_tmp_dh_callback() sets the callback only for B<ssl>.
31
32SSL_set_tmp_dh() sets the parameters only for B<ssl>.
33
34These functions apply to SSL/TLS servers only.
35
36=head1 NOTES
37
38When using a cipher with RSA authentication, an ephemeral DH key exchange
39can take place. Ciphers with DSA keys always use ephemeral DH keys as well.
40In these cases, the session data are negotiated using the
41ephemeral/temporary DH key and the key supplied and certified
42by the certificate chain is only used for signing.
43Anonymous ciphers (without a permanent server key) also use ephemeral DH keys.
44
45Using ephemeral DH key exchange yields forward secrecy, as the connection
46can only be decrypted, when the DH key is known. By generating a temporary
47DH key inside the server application that is lost when the application
48is left, it becomes impossible for an attacker to decrypt past sessions,
49even if he gets hold of the normal (certified) key, as this key was
50only used for signing.
51
52In order to perform a DH key exchange the server must use a DH group
53(DH parameters) and generate a DH key. The server will always generate a new
54DH key during the negotiation, when the DH parameters are supplied via
55callback and/or when the SSL_OP_SINGLE_DH_USE option of
56L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)> is set. It will
57immediately create a DH key, when DH parameters are supplied via
58SSL_CTX_set_tmp_dh() and SSL_OP_SINGLE_DH_USE is not set. In this case,
59it may happen that a key is generated on initialization without later
60being needed, while on the other hand the computer time during the
61negotiation is being saved.
62
63If "strong" primes were used to generate the DH parameters, it is not strictly
64necessary to generate a new key for each handshake but it does improve forward
65secrecy. If it is not assured, that "strong" primes were used (see especially
66the section about DSA parameters below), SSL_OP_SINGLE_DH_USE must be used
67in order to prevent small subgroup attacks. Always using SSL_OP_SINGLE_DH_USE
68has an impact on the computer time needed during negotiation, but it is not
69very large, so application authors/users should consider to always enable
70this option.
71
72As generating DH parameters is extremely time consuming, an application
73should not generate the parameters on the fly but supply the parameters.
74DH parameters can be reused, as the actual key is newly generated during
75the negotiation. The risk in reusing DH parameters is that an attacker
76may specialize on a very often used DH group. Applications should therefore
77generate their own DH parameters during the installation process using the
78openssl L<dhparam(1)|dhparam(1)> application. In order to reduce the computer
79time needed for this generation, it is possible to use DSA parameters
80instead (see L<dhparam(1)|dhparam(1)>), but in this case SSL_OP_SINGLE_DH_USE
81is mandatory.
82
83Application authors may compile in DH parameters. Files dh512.pem,
84dh1024.pem, dh2048.pem, and dh4096 in the 'apps' directory of current
85version of the OpenSSL distribution contain the 'SKIP' DH parameters,
86which use safe primes and were generated verifiably pseudo-randomly.
87These files can be converted into C code using the B<-C> option of the
88L<dhparam(1)|dhparam(1)> application.
89Authors may also generate their own set of parameters using
90L<dhparam(1)|dhparam(1)>, but a user may not be sure how the parameters were
91generated. The generation of DH parameters during installation is therefore
92recommended.
93
94An application may either directly specify the DH parameters or
95can supply the DH parameters via a callback function. The callback approach
96has the advantage, that the callback may supply DH parameters for different
97key lengths.
98
99The B<tmp_dh_callback> is called with the B<keylength> needed and
100the B<is_export> information. The B<is_export> flag is set, when the
101ephemeral DH key exchange is performed with an export cipher.
102
103=head1 EXAMPLES
104
105Handle DH parameters for key lengths of 512 and 1024 bits. (Error handling
106partly left out.)
107
108 ...
109 /* Set up ephemeral DH stuff */
110 DH *dh_512 = NULL;
111 DH *dh_1024 = NULL;
112 FILE *paramfile;
113
114 ...
115 /* "openssl dhparam -out dh_param_512.pem -2 512" */
116 paramfile = fopen("dh_param_512.pem", "r");
117 if (paramfile) {
118 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
119 fclose(paramfile);
120 }
121 /* "openssl dhparam -out dh_param_1024.pem -2 1024" */
122 paramfile = fopen("dh_param_1024.pem", "r");
123 if (paramfile) {
124 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
125 fclose(paramfile);
126 }
127 ...
128
129 /* "openssl dhparam -C -2 512" etc... */
130 DH *get_dh512() { ... }
131 DH *get_dh1024() { ... }
132
133 DH *tmp_dh_callback(SSL *s, int is_export, int keylength)
134 {
135 DH *dh_tmp=NULL;
136
137 switch (keylength) {
138 case 512:
139 if (!dh_512)
140 dh_512 = get_dh512();
141 dh_tmp = dh_512;
142 break;
143 case 1024:
144 if (!dh_1024)
145 dh_1024 = get_dh1024();
146 dh_tmp = dh_1024;
147 break;
148 default:
149 /* Generating a key on the fly is very costly, so use what is there */
150 setup_dh_parameters_like_above();
151 }
152 return(dh_tmp);
153 }
154
155=head1 RETURN VALUES
156
157SSL_CTX_set_tmp_dh_callback() and SSL_set_tmp_dh_callback() do not return
158diagnostic output.
159
160SSL_CTX_set_tmp_dh() and SSL_set_tmp_dh() do return 1 on success and 0
161on failure. Check the error queue to find out the reason of failure.
162
163=head1 SEE ALSO
164
165L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
166L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
167L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
168L<ciphers(1)|ciphers(1)>, L<dhparam(1)|dhparam(1)>
169
170=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
new file mode 100644
index 0000000000..f85775927d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod
@@ -0,0 +1,166 @@
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_tmp_rsa_callback, SSL_CTX_set_tmp_rsa, SSL_CTX_need_tmp_rsa, SSL_set_tmp_rsa_callback, SSL_set_tmp_rsa, SSL_need_tmp_rsa - handle RSA keys for ephemeral key exchange
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
12 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
13 long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa);
14 long SSL_CTX_need_tmp_rsa(SSL_CTX *ctx);
15
16 void SSL_set_tmp_rsa_callback(SSL_CTX *ctx,
17 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
18 long SSL_set_tmp_rsa(SSL *ssl, RSA *rsa)
19 long SSL_need_tmp_rsa(SSL *ssl)
20
21 RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
22
23=head1 DESCRIPTION
24
25SSL_CTX_set_tmp_rsa_callback() sets the callback function for B<ctx> to be
26used when a temporary/ephemeral RSA key is required to B<tmp_rsa_callback>.
27The callback is inherited by all SSL objects newly created from B<ctx>
28with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
29
30SSL_CTX_set_tmp_rsa() sets the temporary/ephemeral RSA key to be used to be
31B<rsa>. The key is inherited by all SSL objects newly created from B<ctx>
32with <SSL_new(3)|SSL_new(3)>. Already created SSL objects are not affected.
33
34SSL_CTX_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed
35for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
36with a keysize larger than 512 bits is installed.
37
38SSL_set_tmp_rsa_callback() sets the callback only for B<ssl>.
39
40SSL_set_tmp_rsa() sets the key only for B<ssl>.
41
42SSL_need_tmp_rsa() returns 1, if a temporary/ephemeral RSA key is needed,
43for RSA-based strength-limited 'exportable' ciphersuites because a RSA key
44with a keysize larger than 512 bits is installed.
45
46These functions apply to SSL/TLS servers only.
47
48=head1 NOTES
49
50When using a cipher with RSA authentication, an ephemeral RSA key exchange
51can take place. In this case the session data are negotiated using the
52ephemeral/temporary RSA key and the RSA key supplied and certified
53by the certificate chain is only used for signing.
54
55Under previous export restrictions, ciphers with RSA keys shorter (512 bits)
56than the usual key length of 1024 bits were created. To use these ciphers
57with RSA keys of usual length, an ephemeral key exchange must be performed,
58as the normal (certified) key cannot be directly used.
59
60Using ephemeral RSA key exchange yields forward secrecy, as the connection
61can only be decrypted, when the RSA key is known. By generating a temporary
62RSA key inside the server application that is lost when the application
63is left, it becomes impossible for an attacker to decrypt past sessions,
64even if he gets hold of the normal (certified) RSA key, as this key was
65used for signing only. The downside is that creating a RSA key is
66computationally expensive.
67
68Additionally, the use of ephemeral RSA key exchange is only allowed in
69the TLS standard, when the RSA key can be used for signing only, that is
70for export ciphers. Using ephemeral RSA key exchange for other purposes
71violates the standard and can break interoperability with clients.
72It is therefore strongly recommended to not use ephemeral RSA key
73exchange and use EDH (Ephemeral Diffie-Hellman) key exchange instead
74in order to achieve forward secrecy (see
75L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>).
76
77On OpenSSL servers ephemeral RSA key exchange is therefore disabled by default
78and must be explicitly enabled using the SSL_OP_EPHEMERAL_RSA option of
79L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, violating the TLS/SSL
80standard. When ephemeral RSA key exchange is required for export ciphers,
81it will automatically be used without this option!
82
83An application may either directly specify the key or can supply the key via
84a callback function. The callback approach has the advantage, that the
85callback may generate the key only in case it is actually needed. As the
86generation of a RSA key is however costly, it will lead to a significant
87delay in the handshake procedure. Another advantage of the callback function
88is that it can supply keys of different size (e.g. for SSL_OP_EPHEMERAL_RSA
89usage) while the explicit setting of the key is only useful for key size of
90512 bits to satisfy the export restricted ciphers and does give away key length
91if a longer key would be allowed.
92
93The B<tmp_rsa_callback> is called with the B<keylength> needed and
94the B<is_export> information. The B<is_export> flag is set, when the
95ephemeral RSA key exchange is performed with an export cipher.
96
97=head1 EXAMPLES
98
99Generate temporary RSA keys to prepare ephemeral RSA key exchange. As the
100generation of a RSA key costs a lot of computer time, they saved for later
101reuse. For demonstration purposes, two keys for 512 bits and 1024 bits
102respectively are generated.
103
104 ...
105 /* Set up ephemeral RSA stuff */
106 RSA *rsa_512 = NULL;
107 RSA *rsa_1024 = NULL;
108
109 rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL);
110 if (rsa_512 == NULL)
111 evaluate_error_queue();
112
113 rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL);
114 if (rsa_1024 == NULL)
115 evaluate_error_queue();
116
117 ...
118
119 RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength)
120 {
121 RSA *rsa_tmp=NULL;
122
123 switch (keylength) {
124 case 512:
125 if (rsa_512)
126 rsa_tmp = rsa_512;
127 else { /* generate on the fly, should not happen in this example */
128 rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL);
129 rsa_512 = rsa_tmp; /* Remember for later reuse */
130 }
131 break;
132 case 1024:
133 if (rsa_1024)
134 rsa_tmp=rsa_1024;
135 else
136 should_not_happen_in_this_example();
137 break;
138 default:
139 /* Generating a key on the fly is very costly, so use what is there */
140 if (rsa_1024)
141 rsa_tmp=rsa_1024;
142 else
143 rsa_tmp=rsa_512; /* Use at least a shorter key */
144 }
145 return(rsa_tmp);
146 }
147
148=head1 RETURN VALUES
149
150SSL_CTX_set_tmp_rsa_callback() and SSL_set_tmp_rsa_callback() do not return
151diagnostic output.
152
153SSL_CTX_set_tmp_rsa() and SSL_set_tmp_rsa() do return 1 on success and 0
154on failure. Check the error queue to find out the reason of failure.
155
156SSL_CTX_need_tmp_rsa() and SSL_need_tmp_rsa() return 1 if a temporary
157RSA key is needed and 0 otherwise.
158
159=head1 SEE ALSO
160
161L<ssl(3)|ssl(3)>, L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
162L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
163L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
164L<SSL_new(3)|SSL_new(3)>, L<ciphers(1)|ciphers(1)>
165
166=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
index fc0b76118f..5bb21ca535 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_set_verify.pod
@@ -59,14 +59,14 @@ The handshake will be continued regardless of the verification result.
59 59
60B<Server mode:> the server sends a client certificate request to the client. 60B<Server mode:> the server sends a client certificate request to the client.
61The certificate returned (if any) is checked. If the verification process 61The certificate returned (if any) is checked. If the verification process
62fails as indicated by B<verify_callback>, the TLS/SSL handshake is 62fails, the TLS/SSL handshake is
63immediately terminated with an alert message containing the reason for 63immediately terminated with an alert message containing the reason for
64the verification failure. 64the verification failure.
65The behaviour can be controlled by the additional 65The behaviour can be controlled by the additional
66SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE flags. 66SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE flags.
67 67
68B<Client mode:> the server certificate is verified. If the verification process 68B<Client mode:> the server certificate is verified. If the verification process
69fails as indicated by B<verify_callback>, the TLS/SSL handshake is 69fails, the TLS/SSL handshake is
70immediately terminated with an alert message containing the reason for 70immediately terminated with an alert message containing the reason for
71the verification failure. If no server certificate is sent, because an 71the verification failure. If no server certificate is sent, because an
72anonymous cipher is used, SSL_VERIFY_PEER is ignored. 72anonymous cipher is used, SSL_VERIFY_PEER is ignored.
@@ -92,6 +92,15 @@ B<Client mode:> ignored
92Exactly one of the B<mode> flags SSL_VERIFY_NONE and SSL_VERIFY_PEER must be 92Exactly one of the B<mode> flags SSL_VERIFY_NONE and SSL_VERIFY_PEER must be
93set at any time. 93set at any time.
94 94
95The actual verification procedure is performed either using the built-in
96verification procedure or using another application provided verification
97function set with
98L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>.
99The following descriptions apply in the case of the built-in procedure. An
100application provided procedure also has access to the verify depth information
101and the verify_callback() function, but the way this information is used
102may be different.
103
95SSL_CTX_set_verify_depth() and SSL_set_verify_depth() set the limit up 104SSL_CTX_set_verify_depth() and SSL_set_verify_depth() set the limit up
96to which depth certificates in a chain are used during the verification 105to which depth certificates in a chain are used during the verification
97procedure. If the certificate chain is longer than allowed, the certificates 106procedure. If the certificate chain is longer than allowed, the certificates
@@ -278,6 +287,7 @@ L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
278L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>, 287L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
279L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>, 288L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
280L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>, 289L<SSL_get_peer_certificate(3)|SSL_get_peer_certificate(3)>,
290L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
281L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>, 291L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
282L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)> 292L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>
283 293
diff --git a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
index 3b2fe6fc50..b8868f18bf 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_CTX_use_certificate.pod
@@ -149,6 +149,7 @@ L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_clear(3)|SSL_clear(3)>,
149L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>, 149L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>,
150L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>, 150L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
151L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>, 151L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
152L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
152L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)> 153L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>
153 154
154=cut 155=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
index df30ccbb32..558de01df9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_SESSION_free.pod
@@ -16,10 +16,40 @@ SSL_SESSION_free() decrements the reference count of B<session> and removes
16the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated 16the B<SSL_SESSION> structure pointed to by B<session> and frees up the allocated
17memory, if the the reference count has reached 0. 17memory, if the the reference count has reached 0.
18 18
19=head1 NOTES
20
21SSL_SESSION objects are allocated, when a TLS/SSL handshake operation
22is successfully completed. Depending on the settings, see
23L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
24the SSL_SESSION objects are internally referenced by the SSL_CTX and
25linked into its session cache. SSL objects may be using the SSL_SESSION object;
26as a session may be reused, several SSL objects may be using one SSL_SESSION
27object at the same time. It is therefore crucial to keep the reference
28count (usage information) correct and not delete a SSL_SESSION object
29that is still used, as this may lead to program failures due to
30dangling pointers. These failures may also appear delayed, e.g.
31when an SSL_SESSION object was completely freed as the reference count
32incorrectly became 0, but it is still referenced in the internal
33session cache and the cache list is processed during a
34L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)> operation.
35
36SSL_SESSION_free() must only be called for SSL_SESSION objects, for
37which the reference count was explicitly incremented (e.g.
38by calling SSL_get1_session(), see L<SSL_get_session(3)|SSL_get_session(3)>)
39or when the SSL_SESSION object was generated outside a TLS handshake
40operation, e.g. by using L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>.
41It must not be called on other SSL_SESSION objects, as this would cause
42incorrect reference counts and therefore program failures.
43
19=head1 RETURN VALUES 44=head1 RETURN VALUES
20 45
21SSL_SESSION_free() does not provide diagnostic information. 46SSL_SESSION_free() does not provide diagnostic information.
22 47
23L<ssl(3)|ssl(3)>, L<SSL_get_session(3)|SSL_get_session(3)> 48=head1 SEE ALSO
49
50L<ssl(3)|ssl(3)>, L<SSL_get_session(3)|SSL_get_session(3)>,
51L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
52L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
53 L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>
24 54
25=cut 55=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
index cd33b73aa3..ea3c2bcfe6 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_SESSION_get_time.pod
@@ -58,6 +58,7 @@ If any of the function is passed the NULL pointer for the session B<s>,
58=head1 SEE ALSO 58=head1 SEE ALSO
59 59
60L<ssl(3)|ssl(3)>, 60L<ssl(3)|ssl(3)>,
61L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)> 61L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
62L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
62 63
63=cut 64=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_accept.pod b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
index 86f980de41..ac6caf9baa 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_accept.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_accept.pod
@@ -37,11 +37,6 @@ nothing is to be done, but select() can be used to check for the required
37condition. When using a buffering BIO, like a BIO pair, data must be written 37condition. When using a buffering BIO, like a BIO pair, data must be written
38into or retrieved out of the BIO before being able to continue. 38into or retrieved out of the BIO before being able to continue.
39 39
40When using a generic method (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>), it
41is necessary to call SSL_set_accept_state()
42before calling SSL_accept() to explicitly switch the B<ssl> to server
43mode.
44
45=head1 RETURN VALUES 40=head1 RETURN VALUES
46 41
47The following return values can occur: 42The following return values can occur:
diff --git a/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
new file mode 100644
index 0000000000..94e28cc307
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_alert_type_string.pod
@@ -0,0 +1,228 @@
1=pod
2
3=head1 NAME
4
5SSL_alert_type_string, SSL_alert_type_string_long, SSL_alert_desc_string, SSL_alert_desc_string_long - get textual description of alert information
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_alert_type_string(int value);
12 const char *SSL_alert_type_string_long(int value);
13
14 const char *SSL_alert_desc_string(int value);
15 const char *SSL_alert_desc_string_long(int value);
16
17=head1 DESCRIPTION
18
19SSL_alert_type_string() returns a one letter string indicating the
20type of the alert specified by B<value>.
21
22SSL_alert_type_string_long() returns a string indicating the type of the alert
23specified by B<value>.
24
25SSL_alert_desc_string() returns a two letter string as a short form
26describing the reason of the alert specified by B<value>.
27
28SSL_alert_desc_string_long() returns a string describing the reason
29of the alert specified by B<value>.
30
31=head1 NOTES
32
33When one side of an SSL/TLS communication wants to inform the peer about
34a special situation, it sends an alert. The alert is sent as a special message
35and does not influence the normal data stream (unless its contents results
36in the communication being canceled).
37
38A warning alert is sent, when a non-fatal error condition occurs. The
39"close notify" alert is sent as a warning alert. Other examples for
40non-fatal errors are certificate errors ("certificate expired",
41"unsupported certificate"), for which a warning alert may be sent.
42(The sending party may however decide to send a fatal error.) The
43receiving side may cancel the connection on reception of a warning
44alert on it discretion.
45
46Several alert messages must be sent as fatal alert messages as specified
47by the TLS RFC. A fatal alert always leads to a connection abort.
48
49=head1 RETURN VALUES
50
51The following strings can occur for SSL_alert_type_string() or
52SSL_alert_type_string_long():
53
54=over 4
55
56=item "W"/"warning"
57
58=item "F"/"fatal"
59
60=item "U"/"unknown"
61
62This indicates that no support is available for this alert type.
63Probably B<value> does not contain a correct alert message.
64
65=back
66
67The following strings can occur for SSL_alert_desc_string() or
68SSL_alert_desc_string_long():
69
70=over 4
71
72=item "CN"/"close notify"
73
74The connection shall be closed. This is a warning alert.
75
76=item "UM"/"unexpected message"
77
78An inappropriate message was received. This alert is always fatal
79and should never be observed in communication between proper
80implementations.
81
82=item "BM"/"bad record mac"
83
84This alert is returned if a record is received with an incorrect
85MAC. This message is always fatal.
86
87=item "DF"/"decompression failure"
88
89The decompression function received improper input (e.g. data
90that would expand to excessive length). This message is always
91fatal.
92
93=item "HF"/"handshake failure"
94
95Reception of a handshake_failure alert message indicates that the
96sender was unable to negotiate an acceptable set of security
97parameters given the options available. This is a fatal error.
98
99=item "NC"/"no certificate"
100
101A client, that was asked to send a certificate, does not send a certificate
102(SSLv3 only).
103
104=item "BC"/"bad certificate"
105
106A certificate was corrupt, contained signatures that did not
107verify correctly, etc
108
109=item "UC"/"unsupported certificate"
110
111A certificate was of an unsupported type.
112
113=item "CR"/"certificate revoked"
114
115A certificate was revoked by its signer.
116
117=item "CE"/"certificate expired"
118
119A certificate has expired or is not currently valid.
120
121=item "CU"/"certificate unknown"
122
123Some other (unspecified) issue arose in processing the
124certificate, rendering it unacceptable.
125
126=item "IP"/"illegal parameter"
127
128A field in the handshake was out of range or inconsistent with
129other fields. This is always fatal.
130
131=item "DC"/"decryption failed"
132
133A TLSCiphertext decrypted in an invalid way: either it wasn't an
134even multiple of the block length or its padding values, when
135checked, weren't correct. This message is always fatal.
136
137=item "RO"/"record overflow"
138
139A TLSCiphertext record was received which had a length more than
1402^14+2048 bytes, or a record decrypted to a TLSCompressed record
141with more than 2^14+1024 bytes. This message is always fatal.
142
143=item "CA"/"unknown CA"
144
145A valid certificate chain or partial chain was received, but the
146certificate was not accepted because the CA certificate could not
147be located or couldn't be matched with a known, trusted CA. This
148message is always fatal.
149
150=item "AD"/"access denied"
151
152A valid certificate was received, but when access control was
153applied, the sender decided not to proceed with negotiation.
154This message is always fatal.
155
156=item "DE"/"decode error"
157
158A message could not be decoded because some field was out of the
159specified range or the length of the message was incorrect. This
160message is always fatal.
161
162=item "CY"/"decrypt error"
163
164A handshake cryptographic operation failed, including being
165unable to correctly verify a signature, decrypt a key exchange,
166or validate a finished message.
167
168=item "ER"/"export restriction"
169
170A negotiation not in compliance with export restrictions was
171detected; for example, attempting to transfer a 1024 bit
172ephemeral RSA key for the RSA_EXPORT handshake method. This
173message is always fatal.
174
175=item "PV"/"protocol version"
176
177The protocol version the client has attempted to negotiate is
178recognized, but not supported. (For example, old protocol
179versions might be avoided for security reasons). This message is
180always fatal.
181
182=item "IS"/"insufficient security"
183
184Returned instead of handshake_failure when a negotiation has
185failed specifically because the server requires ciphers more
186secure than those supported by the client. This message is always
187fatal.
188
189=item "IE"/"internal error"
190
191An internal error unrelated to the peer or the correctness of the
192protocol makes it impossible to continue (such as a memory
193allocation failure). This message is always fatal.
194
195=item "US"/"user canceled"
196
197This handshake is being canceled for some reason unrelated to a
198protocol failure. If the user cancels an operation after the
199handshake is complete, just closing the connection by sending a
200close_notify is more appropriate. This alert should be followed
201by a close_notify. This message is generally a warning.
202
203=item "NR"/"no renegotiation"
204
205Sent by the client in response to a hello request or by the
206server in response to a client hello after initial handshaking.
207Either of these would normally lead to renegotiation; when that
208is not appropriate, the recipient should respond with this alert;
209at that point, the original requester can decide whether to
210proceed with the connection. One case where this would be
211appropriate would be where a server has spawned a process to
212satisfy a request; the process might receive security parameters
213(key length, authentication, etc.) at startup and it might be
214difficult to communicate changes to these parameters after that
215point. This message is always a warning.
216
217=item "UK"/"unknown"
218
219This indicates that no description is available for this alert type.
220Probably B<value> does not contain a correct alert message.
221
222=back
223
224=head1 SEE ALSO
225
226L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
227
228=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_clear.pod b/src/lib/libssl/src/doc/ssl/SSL_clear.pod
index 8b735d81dc..8e077e31c9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_clear.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_clear.pod
@@ -25,6 +25,25 @@ if L<SSL_shutdown(3)|SSL_shutdown(3)> was not called for the connection
25or at least L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was used to 25or at least L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> was used to
26set the SSL_SENT_SHUTDOWN state. 26set the SSL_SENT_SHUTDOWN state.
27 27
28If a session was closed cleanly, the session object will be kept and all
29settings corresponding. This explicitly means, that e.g. the special method
30used during the session will be kept for the next handshake. So if the
31session was a TLSv1 session, a SSL client object will use a TLSv1 client
32method for the next handshake and a SSL server object will use a TLSv1
33server method, even if SSLv23_*_methods were chosen on startup. This
34will might lead to connection failures (see L<SSL_new(3)|SSL_new(3)>)
35for a description of the method's properties.
36
37=head1 WARNINGS
38
39SSL_clear() resets the SSL object to allow for another connection. The
40reset operation however keeps several settings of the last sessions
41(some of these settings were made automatically during the last
42handshake). It only makes sense when opening a new session (or reusing
43an old one) with the same peer that shares these settings.
44SSL_clear() is not a short form for the sequence
45L<SSL_free(3)|SSL_free(3)>; L<SSL_new(3)|SSL_new(3)>; .
46
28=head1 RETURN VALUES 47=head1 RETURN VALUES
29 48
30The following return values can occur: 49The following return values can occur:
@@ -44,6 +63,7 @@ The SSL_clear() operation was successful.
44 63
45L<SSL_new(3)|SSL_new(3)>, L<SSL_free(3)|SSL_free(3)>, 64L<SSL_new(3)|SSL_new(3)>, L<SSL_free(3)|SSL_free(3)>,
46L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 65L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
47L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, L<ssl(3)|ssl(3)> 66L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, L<ssl(3)|ssl(3)>,
67L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
48 68
49=cut 69=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_connect.pod b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
index bcc167745b..766f1876aa 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_connect.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_connect.pod
@@ -34,11 +34,6 @@ nothing is to be done, but select() can be used to check for the required
34condition. When using a buffering BIO, like a BIO pair, data must be written 34condition. When using a buffering BIO, like a BIO pair, data must be written
35into or retrieved out of the BIO before being able to continue. 35into or retrieved out of the BIO before being able to continue.
36 36
37When using a generic method (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>), it
38is necessary to call L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>
39before calling SSL_connect() to explicitly switch the B<ssl> to client
40mode.
41
42=head1 RETURN VALUES 37=head1 RETURN VALUES
43 38
44The following return values can occur: 39The following return values can occur:
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
new file mode 100644
index 0000000000..52d0227b19
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_SSL_CTX.pod
@@ -0,0 +1,26 @@
1=pod
2
3=head1 NAME
4
5SSL_get_SSL_CTX - get the SSL_CTX from which an SSL is created
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_SSL_CTX() returns a pointer to the SSL_CTX object, from which
16B<ssl> was created with L<SSL_new(3)|SSL_new(3)>.
17
18=head1 RETURN VALUES
19
20The pointer to the SSL_CTX object is returned.
21
22=head1 SEE ALSO
23
24L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>
25
26=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
index 40e01cf9c8..5693fdebb2 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_client_CA_list.pod
@@ -47,6 +47,7 @@ the server did not send a list of CAs (client mode).
47=head1 SEE ALSO 47=head1 SEE ALSO
48 48
49L<ssl(3)|ssl(3)>, 49L<ssl(3)|ssl(3)>,
50L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)> 50L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
51L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>
51 52
52=cut 53=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
new file mode 100644
index 0000000000..8d43b31345
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_default_timeout.pod
@@ -0,0 +1,41 @@
1=pod
2
3=head1 NAME
4
5SSL_get_default_timeout - get default session timeout value
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 long SSL_get_default_timeout(SSL *ssl);
12
13=head1 DESCRIPTION
14
15SSL_get_default_timeout() returns the default timeout value assigned to
16SSL_SESSION objects negotiated for the protocol valid for B<ssl>.
17
18=head1 NOTES
19
20Whenever a new session is negotiated, it is assigned a timeout value,
21after which it will not be accepted for session reuse. If the timeout
22value was not explicitly set using
23L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, the hardcoded default
24timeout for the protocol will be used.
25
26SSL_get_default_timeout() return this hardcoded value, which is 300 seconds
27for all currently supported protocols (SSLv2, SSLv3, and TLSv1).
28
29=head1 RETURN VALUES
30
31See description.
32
33=head1 SEE ALSO
34
35L<ssl(3)|ssl(3)>,
36L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
37L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
38L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
39L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>
40
41=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
index d95eec78aa..f700bf0ace 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_error.pod
@@ -69,13 +69,13 @@ to read data. This is mainly because TLS/SSL handshakes may occur at any
69time during the protocol (initiated by either the client or the server); 69time during the protocol (initiated by either the client or the server);
70SSL_read(), SSL_peek(), and SSL_write() will handle any pending handshakes. 70SSL_read(), SSL_peek(), and SSL_write() will handle any pending handshakes.
71 71
72=item SSL_ERROR_WANT_CONNECT 72=item SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT
73 73
74The operation did not complete; the same TLS/SSL I/O function should be 74The operation did not complete; the same TLS/SSL I/O function should be
75called again later. The underlying BIO was not connected yet to the peer 75called again later. The underlying BIO was not connected yet to the peer
76and the call would block in connect(). The SSL function should be 76and the call would block in connect()/accept(). The SSL function should be
77called again when the connection is established. This messages can only 77called again when the connection is established. These messages can only
78appear with a BIO_s_connect() BIO. 78appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively.
79In order to find out, when the connection has been successfully established, 79In order to find out, when the connection has been successfully established,
80on many platforms select() or poll() for writing on the socket file descriptor 80on many platforms select() or poll() for writing on the socket file descriptor
81can be used. 81can be used.
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
index 18d1db5183..60635a9660 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_peer_certificate.pod
@@ -19,7 +19,7 @@ peer presented. If the peer did not present a certificate, NULL is returned.
19 19
20Due to the protocol definition, a TLS/SSL server will always send a 20Due to the protocol definition, a TLS/SSL server will always send a
21certificate, if present. A client will only send a certificate when 21certificate, if present. A client will only send a certificate when
22explicitely requested to do so by the server (see 22explicitly requested to do so by the server (see
23L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher 23L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher
24is used, no certificates are sent. 24is used, no certificates are sent.
25 25
diff --git a/src/lib/libssl/src/doc/ssl/SSL_get_session.pod b/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
index a0266e2ac6..dd9aba40b6 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_get_session.pod
@@ -37,8 +37,16 @@ if the session is valid, it can be removed at any time due to timeout
37during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>. 37during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>.
38 38
39If the data is to be kept, SSL_get1_session() will increment the reference 39If the data is to be kept, SSL_get1_session() will increment the reference
40count and the session will stay in memory until explicitly freed with 40count, so that the session will not be implicitly removed by other operations
41L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, regardless of its state. 41but stays in memory. In order to remove the session
42L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> must be explicitly called once
43to decrement the reference count again.
44
45SSL_SESSION objects keep internal link information about the session cache
46list, when being inserted into one SSL_CTX object's session cache.
47One SSL_SESSION object, regardless of its reference count, must therefore
48only be used with one SSL_CTX object (and the SSL objects created
49from this SSL_CTX object).
42 50
43=head1 RETURN VALUES 51=head1 RETURN VALUES
44 52
diff --git a/src/lib/libssl/src/doc/ssl/SSL_new.pod b/src/lib/libssl/src/doc/ssl/SSL_new.pod
index 3b084e867d..25300e978f 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_new.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_new.pod
@@ -38,6 +38,7 @@ The return value points to an allocated SSL structure.
38 38
39L<SSL_free(3)|SSL_free(3)>, L<SSL_clear(3)|SSL_clear(3)>, 39L<SSL_free(3)|SSL_free(3)>, L<SSL_clear(3)|SSL_clear(3)>,
40L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, 40L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
41L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
41L<ssl(3)|ssl(3)> 42L<ssl(3)|ssl(3)>
42 43
43=cut 44=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_read.pod b/src/lib/libssl/src/doc/ssl/SSL_read.pod
index cc7aa1a547..f6c37f77e4 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_read.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_read.pod
@@ -25,11 +25,10 @@ the SSL_read() operation. The behaviour of SSL_read() depends on the
25underlying BIO. 25underlying BIO.
26 26
27For the transparent negotiation to succeed, the B<ssl> must have been 27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is not the case if a generic 28initialized to client or server mode. This is being done by calling
29method is being used (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>, so that
30L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state() 29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
31must be used before the first call to an SSL_read() or 30before the first call to an SSL_read() or L<SSL_write(3)|SSL_write(3)>
32L<SSL_write(3)|SSL_write(3)> function). 31function.
33 32
34SSL_read() works based on the SSL/TLS records. The data are received in 33SSL_read() works based on the SSL/TLS records. The data are received in
35records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a 34records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a
@@ -84,9 +83,20 @@ bytes actually read from the TLS/SSL connection.
84 83
85=item 0 84=item 0
86 85
87The read operation was not successful, probably because no data was 86The read operation was not successful. The reason may either be a clean
88available. Call SSL_get_error() with the return value B<ret> to find out, 87shutdown due to a "close notify" alert sent by the peer (in which case
89whether an error occurred. 88the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set
89(see L<SSL_shutdown(3)|SSL_shutdown(3)>,
90L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>). It is also possible, that
91the peer simply shut down the underlying transport and the shutdown is
92incomplete. Call SSL_get_error() with the return value B<ret> to find out,
93whether an error occurred or the connection was shut down cleanly
94(SSL_ERROR_ZERO_RETURN).
95
96SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
97only be detected, whether the underlying connection was closed. It cannot
98be checked, whether the closure was initiated by the peer or by something
99else.
90 100
91=item E<lt>0 101=item E<lt>0
92 102
@@ -102,6 +112,7 @@ L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_write(3)|SSL_write(3)>,
102L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>, 112L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
103L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)> 113L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>
104L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>, 114L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
115L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
105L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)> 116L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
106 117
107=cut 118=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
new file mode 100644
index 0000000000..bdb8a1fcd5
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_rstate_string.pod
@@ -0,0 +1,59 @@
1=pod
2
3=head1 NAME
4
5SSL_rstate_string, SSL_rstate_string_long - get textual description of state of an SSL object during read operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_rstate_string(SSL *ssl);
12 const char *SSL_rstate_string_long(SSL *ssl);
13
14=head1 DESCRIPTION
15
16SSL_rstate_string() returns a 2 letter string indicating the current read state
17of the SSL object B<ssl>.
18
19SSL_rstate_string_long() returns a string indicating the current read state of
20the SSL object B<ssl>.
21
22=head1 NOTES
23
24When performing a read operation, the SSL/TLS engine must parse the record,
25consisting of header and body. When working in a blocking environment,
26SSL_rstate_string[_long]() should always return "RD"/"read done".
27
28This function should only seldom be needed in applications.
29
30=head1 RETURN VALUES
31
32SSL_rstate_string() and SSL_rstate_string_long() can return the following
33values:
34
35=over 4
36
37=item "RH"/"read header"
38
39The header of the record is being evaluated.
40
41=item "RB"/"read body"
42
43The body of the record is being evaluated.
44
45=item "RD"/"read done"
46
47The record has been completely processed.
48
49=item "unknown"/"unknown"
50
51The read state is unknown. This should never happen.
52
53=back
54
55=head1 SEE ALSO
56
57L<ssl(3)|ssl(3)>
58
59=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod b/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
new file mode 100644
index 0000000000..da7d06264d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_session_reused.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5SSL_session_reused - query whether a reused session was negotiated during handshake
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_session_reused(SSL *ssl);
12
13=head1 DESCRIPTION
14
15Query, whether a reused session was negotiated during the handshake.
16
17=head1 NOTES
18
19During the negotiation, a client can propose to reuse a session. The server
20then looks up the session in its cache. If both client and server agree
21on the session, it will be reused and a flag is being set that can be
22queried by the application.
23
24=head1 RETURN VALUES
25
26The following return values can occur:
27
28=over 4
29
30=item 0
31
32A new session was negotiated.
33
34=item 1
35
36A session was reused.
37
38=back
39
40=head1 SEE ALSO
41
42L<ssl(3)|ssl(3)>, L<SSL_set_session(3)|SSL_set_session(3)>,
43L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
44
45=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
index a8c4463c64..7adf8adfed 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_connect_state.pod
@@ -14,9 +14,9 @@ SSL_set_connect_state, SSL_get_accept_state - prepare SSL object to work in clie
14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17SSL_set_connect_state() B<ssl> to work in client mode. 17SSL_set_connect_state() sets B<ssl> to work in client mode.
18 18
19SSL_set_accept_state() B<ssl> to work in server mode. 19SSL_set_accept_state() sets B<ssl> to work in server mode.
20 20
21=head1 NOTES 21=head1 NOTES
22 22
@@ -27,12 +27,17 @@ server connections. (The method might have been changed with
27L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or 27L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or
28SSL_set_ssl_method().) 28SSL_set_ssl_method().)
29 29
30In order to successfully accomplish the handshake, the SSL routines need 30When beginning a new handshake, the SSL engine must know whether it must
31to know whether they should act in server or client mode. If the generic 31call the connect (client) or accept (server) routines. Even though it may
32method was used, this is not clear from the method itself and must be set 32be clear from the method chosen, whether client or server mode was
33with either SSL_set_connect_state() or SSL_set_accept_state(). If these 33requested, the handshake routines must be explicitly set.
34routines are not called, the default value set when L<SSL_new(3)|SSL_new(3)> 34
35is called is server mode. 35When using the L<SSL_connect(3)|SSL_connect(3)> or
36L<SSL_accept(3)|SSL_accept(3)> routines, the correct handshake
37routines are automatically set. When performing a transparent negotiation
38using L<SSL_write(3)|SSL_write(3)> or L<SSL_read(3)|SSL_read(3)>, the
39handshake routines must be explicitly set in advance using either
40SSL_set_connect_state() or SSL_set_accept_state().
36 41
37=head1 RETURN VALUES 42=head1 RETURN VALUES
38 43
@@ -42,6 +47,8 @@ information.
42=head1 SEE ALSO 47=head1 SEE ALSO
43 48
44L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>, 49L<ssl(3)|ssl(3)>, L<SSL_new(3)|SSL_new(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,
50L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>,
51L<SSL_write(3)|SSL_write(3)>, L<SSL_read(3)|SSL_read(3)>,
45L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> 52L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>
46 53
47=cut 54=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_session.pod b/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
index c4f7878579..5f54714ad8 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_session.pod
@@ -16,12 +16,21 @@ SSL_set_session() sets B<session> to be used when the TLS/SSL connection
16is to be established. SSL_set_session() is only useful for TLS/SSL clients. 16is to be established. SSL_set_session() is only useful for TLS/SSL clients.
17When the session is set, the reference count of B<session> is incremented 17When the session is set, the reference count of B<session> is incremented
18by 1. If the session is not reused, the reference count is decremented 18by 1. If the session is not reused, the reference count is decremented
19again during SSL_connect(). 19again during SSL_connect(). Whether the session was reused can be queried
20with the L<SSL_session_reused(3)|SSL_session_reused(3)> call.
20 21
21If there is already a session set inside B<ssl> (because it was set with 22If there is already a session set inside B<ssl> (because it was set with
22SSL_set_session() before or because the same B<ssl> was already used for 23SSL_set_session() before or because the same B<ssl> was already used for
23a connection), SSL_SESSION_free() will be called for that session. 24a connection), SSL_SESSION_free() will be called for that session.
24 25
26=head1 NOTES
27
28SSL_SESSION objects keep internal link information about the session cache
29list, when being inserted into one SSL_CTX object's session cache.
30One SSL_SESSION object, regardless of its reference count, must therefore
31only be used with one SSL_CTX object (and the SSL objects created
32from this SSL_CTX object).
33
25=head1 RETURN VALUES 34=head1 RETURN VALUES
26 35
27The following return values can occur: 36The following return values can occur:
@@ -41,6 +50,8 @@ The operation succeeded.
41=head1 SEE ALSO 50=head1 SEE ALSO
42 51
43L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, 52L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
53L<SSL_get_session(3)|SSL_get_session(3)>,
54L<SSL_session_reused(3)|SSL_session_reused(3)>,
44L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)> 55L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>
45 56
46=cut 57=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
index 6b196c1f15..6289e635d9 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_set_shutdown.pod
@@ -46,7 +46,10 @@ The shutdown state of the connection is used to determine the state of
46the ssl session. If the session is still open, when 46the ssl session. If the session is still open, when
47L<SSL_clear(3)|SSL_clear(3)> or L<SSL_free(3)|SSL_free(3)> is called, 47L<SSL_clear(3)|SSL_clear(3)> or L<SSL_free(3)|SSL_free(3)> is called,
48it is considered bad and removed according to RFC2246. 48it is considered bad and removed according to RFC2246.
49The actual condition for a correctly closed session is SSL_SENT_SHUTDOWN. 49The actual condition for a correctly closed session is SSL_SENT_SHUTDOWN
50(according to the TLS RFC, it is acceptable to only send the "close notify"
51alert but to not wait for the peer's answer, when the underlying connection
52is closed).
50SSL_set_shutdown() can be used to set this state without sending a 53SSL_set_shutdown() can be used to set this state without sending a
51close alert to the peer (see L<SSL_shutdown(3)|SSL_shutdown(3)>). 54close alert to the peer (see L<SSL_shutdown(3)|SSL_shutdown(3)>).
52 55
@@ -63,6 +66,7 @@ SSL_get_shutdown() returns the current setting.
63=head1 SEE ALSO 66=head1 SEE ALSO
64 67
65L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>, 68L<ssl(3)|ssl(3)>, L<SSL_shutdown(3)|SSL_shutdown(3)>,
69L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
66L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)> 70L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>
67 71
68=cut 72=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
index c4ae6704e7..6b5012be7a 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_shutdown.pod
@@ -22,10 +22,52 @@ Whether the operation succeeds or not, the SSL_SENT_SHUTDOWN flag is set and
22a currently open session is considered closed and good and will be kept in the 22a currently open session is considered closed and good and will be kept in the
23session cache for further reuse. 23session cache for further reuse.
24 24
25The behaviour of SSL_shutdown() depends on the underlying BIO. 25The shutdown procedure consists of 2 steps: the sending of the "close notify"
26shutdown alert and the reception of the peer's "close notify" shutdown
27alert. According to the TLS standard, it is acceptable for an application
28to only send its shutdown alert and then close the underlying connection
29without waiting for the peer's response (this way resources can be saved,
30as the process can already terminate or serve another connection).
31When the underlying connection shall be used for more communications, the
32complete shutdown procedure (bidirectional "close notify" alerts) must be
33performed, so that the peers stay synchronized.
34
35SSL_shutdown() supports both uni- and bidirectional shutdown by its 2 step
36behaviour.
37
38=over 4
39
40=item When the application is the first party to send the "close notify"
41alert, SSL_shutdown() will only send the alert and the set the
42SSL_SENT_SHUTDOWN flag (so that the session is considered good and will
43be kept in cache). SSL_shutdown() will then return with 0. If a unidirectional
44shutdown is enough (the underlying connection shall be closed anyway), this
45first call to SSL_shutdown() is sufficient. In order to complete the
46bidirectional shutdown handshake, SSL_shutdown() must be called again.
47The second call will make SSL_shutdown() wait for the peer's "close notify"
48shutdown alert. On success, the second call to SSL_shutdown() will return
49with 1.
50
51=item If the peer already sent the "close notify" alert B<and> it was
52already processed implicitly inside another function
53(L<SSL_read(3)|SSL_read(3)>), the SSL_RECEIVED_SHUTDOWN flag is set.
54SSL_shutdown() will send the "close notify" alert, set the SSL_SENT_SHUTDOWN
55flag and will immediately return with 1.
56Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the
57SSL_get_shutdown() (see also L<SSL_set_shutdown(3)|SSL_set_shutdown(3)> call.
58
59=back
60
61It is therefore recommended, to check the return value of SSL_shutdown()
62and call SSL_shutdown() again, if the bidirectional shutdown is not yet
63complete (return value of the first call is 0). As the shutdown is not
64specially handled in the SSLv2 protocol, SSL_shutdown() will succeed on
65the first call.
66
67The behaviour of SSL_shutdown() additionally depends on the underlying BIO.
26 68
27If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the 69If the underlying BIO is B<blocking>, SSL_shutdown() will only return once the
28handshake has been finished or an error occurred. 70handshake step has been finished or an error occurred.
29 71
30If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return 72If the underlying BIO is B<non-blocking>, SSL_shutdown() will also return
31when the underlying BIO could not satisfy the needs of SSL_shutdown() 73when the underlying BIO could not satisfy the needs of SSL_shutdown()
@@ -38,6 +80,12 @@ nothing is to be done, but select() can be used to check for the required
38condition. When using a buffering BIO, like a BIO pair, data must be written 80condition. When using a buffering BIO, like a BIO pair, data must be written
39into or retrieved out of the BIO before being able to continue. 81into or retrieved out of the BIO before being able to continue.
40 82
83SSL_shutdown() can be modified to only set the connection to "shutdown"
84state but not actually send the "close notify" alert messages,
85see L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>.
86When "quiet shutdown" is enabled, SSL_shutdown() will always succeed
87and return 1.
88
41=head1 RETURN VALUES 89=head1 RETURN VALUES
42 90
43The following return values can occur: 91The following return values can occur:
@@ -46,19 +94,23 @@ The following return values can occur:
46 94
47=item 1 95=item 1
48 96
49The shutdown was successfully completed. 97The shutdown was successfully completed. The "close notify" alert was sent
98and the peer's "close notify" alert was received.
50 99
51=item 0 100=item 0
52 101
53The shutdown was not successful. Call SSL_get_error() with the return 102The shutdown is not yet finished. Call SSL_shutdown() for a second time,
54value B<ret> to find out the reason. 103if a bidirectional shutdown shall be performed.
104The output of L<SSL_get_error(3)|SSL_get_error(3)> may be misleading, as an
105erroneous SSL_ERROR_SYSCALL may be flagged even though no error occurred.
55 106
56=item -1 107=item -1
57 108
58The shutdown was not successful because a fatal error occurred either 109The shutdown was not successful because a fatal error occurred either
59at the protocol level or a connection failure occurred. It can also occur of 110at the protocol level or a connection failure occurred. It can also occur if
60action is need to continue the operation for non-blocking BIOs. 111action is need to continue the operation for non-blocking BIOs.
61Call SSL_get_error() with the return value B<ret> to find out the reason. 112Call L<SSL_get_error(3)|SSL_get_error(3)> with the return value B<ret>
113to find out the reason.
62 114
63=back 115=back
64 116
@@ -66,6 +118,7 @@ Call SSL_get_error() with the return value B<ret> to find out the reason.
66 118
67L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>, 119L<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_connect(3)|SSL_connect(3)>,
68L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 120L<SSL_accept(3)|SSL_accept(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
121L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
69L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>, 122L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>,
70L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)> 123L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>
71 124
diff --git a/src/lib/libssl/src/doc/ssl/SSL_state_string.pod b/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
new file mode 100644
index 0000000000..b4be1aaa48
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_state_string.pod
@@ -0,0 +1,45 @@
1=pod
2
3=head1 NAME
4
5SSL_state_string, SSL_state_string_long - get textual description of state of an SSL object
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 const char *SSL_state_string(SSL *ssl);
12 const char *SSL_state_string_long(SSL *ssl);
13
14=head1 DESCRIPTION
15
16SSL_state_string() returns a 6 letter string indicating the current state
17of the SSL object B<ssl>.
18
19SSL_state_string_long() returns a string indicating the current state of
20the SSL object B<ssl>.
21
22=head1 NOTES
23
24During its use, an SSL objects passes several states. The state is internally
25maintained. Querying the state information is not very informative before
26or when a connection has been established. It however can be of significant
27interest during the handshake.
28
29When using non-blocking sockets, the function call performing the handshake
30may return with SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition,
31so that SSL_state_string[_long]() may be called.
32
33For both blocking or non-blocking sockets, the details state information
34can be used within the info_callback function set with the
35SSL_set_info_callback() call.
36
37=head1 RETURN VALUES
38
39Detailed description of possible states to be included later.
40
41=head1 SEE ALSO
42
43L<ssl(3)|ssl(3)>, L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>
44
45=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_want.pod b/src/lib/libssl/src/doc/ssl/SSL_want.pod
new file mode 100644
index 0000000000..50cc89db80
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl/SSL_want.pod
@@ -0,0 +1,77 @@
1=pod
2
3=head1 NAME
4
5SSL_want, SSL_want_nothing, SSL_want_read, SSL_want_write, SSL_want_x509_lookup - obtain state information TLS/SSL I/O operation
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_want(SSL *ssl);
12 int SSL_want_nothing(SSL *ssl);
13 int SSL_want_read(SSL *ssl);
14 int SSL_want_write(SSL *ssl);
15 int SSL_want_x509_lookup(SSL *ssl);
16
17=head1 DESCRIPTION
18
19SSL_want() returns state information for the SSL object B<ssl>.
20
21The other SSL_want_*() calls are shortcuts for the possible states returned
22by SSL_want().
23
24=head1 NOTES
25
26SSL_want() examines the internal state information of the SSL object. Its
27return values are similar to that of L<SSL_get_error(3)|SSL_get_error(3)>.
28Unlike L<SSL_get_error(3)|SSL_get_error(3)>, which also evaluates the
29error queue, the results are obtained by examining an internal state flag
30only. The information must therefore only be used for normal operation under
31non-blocking I/O. Error conditions are not handled and must be treated
32using L<SSL_get_error(3)|SSL_get_error(3)>.
33
34The result returned by SSL_want() should always be consistent with
35the result of L<SSL_get_error(3)|SSL_get_error(3)>.
36
37=head1 RETURN VALUES
38
39The following return values can currently occur for SSL_want():
40
41=over 4
42
43=item SSL_NOTHING
44
45There is no data to be written or to be read.
46
47=item SSL_WRITING
48
49There are data in the SSL buffer that must be written to the underlying
50B<BIO> layer in order to complete the actual SSL_*() operation.
51A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
52SSL_ERROR_WANT_WRITE.
53
54=item SSL_READING
55
56More data must be read from the underlying B<BIO> layer in order to
57complete the actual SSL_*() operation.
58A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
59SSL_ERROR_WANT_READ.
60
61=item SSL_X509_LOOKUP
62
63The operation did not complete because an application callback set by
64SSL_CTX_set_client_cert_cb() has asked to be called again.
65A call to L<SSL_get_error(3)|SSL_get_error(3)> should return
66SSL_ERROR_WANT_X509_LOOKUP.
67
68=back
69
70SSL_want_nothing(), SSL_want_read(), SSL_want_write(), SSL_want_x509_lookup()
71return 1, when the corresponding condition is true or 0 otherwise.
72
73=head1 SEE ALSO
74
75L<ssl(3)|ssl(3)>, L<err(3)|err(3)>, L<SSL_get_error(3)|SSL_get_error(3)>
76
77=cut
diff --git a/src/lib/libssl/src/doc/ssl/SSL_write.pod b/src/lib/libssl/src/doc/ssl/SSL_write.pod
index b0dfefae20..dfa42e9aee 100644
--- a/src/lib/libssl/src/doc/ssl/SSL_write.pod
+++ b/src/lib/libssl/src/doc/ssl/SSL_write.pod
@@ -25,11 +25,9 @@ the SSL_write() operation. The behaviour of SSL_write() depends on the
25underlying BIO. 25underlying BIO.
26 26
27For the transparent negotiation to succeed, the B<ssl> must have been 27For the transparent negotiation to succeed, the B<ssl> must have been
28initialized to client or server mode. This is not the case if a generic 28initialized to client or server mode. This is being done by calling
29method is being used (see L<SSL_CTX_new(3)|SSL_CTX_new(3)>, so that
30L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state() 29L<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()
31must be used before the first call to an L<SSL_read(3)|SSL_read(3)> 30before the first call to an L<SSL_read(3)|SSL_read(3)> or SSL_write() function.
32or SSL_write() function.
33 31
34If the underlying BIO is B<blocking>, SSL_write() will only return, once the 32If the underlying BIO is B<blocking>, SSL_write() will only return, once the
35write operation has been finished or an error occurred, except when a 33write operation has been finished or an error occurred, except when a
@@ -80,8 +78,14 @@ bytes actually written to the TLS/SSL connection.
80 78
81=item 0 79=item 0
82 80
83The write operation was not successful. Call SSL_get_error() with the return 81The write operation was not successful. Probably the underlying connection
84value B<ret> to find out, whether an error occurred. 82was closed. Call SSL_get_error() with the return value B<ret> to find out,
83whether an error occurred or the connection was shut down cleanly
84(SSL_ERROR_ZERO_RETURN).
85
86SSLv2 (deprecated) does not support a shutdown alert protocol, so it can
87only be detected, whether the underlying connection was closed. It cannot
88be checked, why the closure happened.
85 89
86=item E<lt>0 90=item E<lt>0
87 91
diff --git a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
index 9a1ba6c47b..0321a5a36f 100644
--- a/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
+++ b/src/lib/libssl/src/doc/ssl/d2i_SSL_SESSION.pod
@@ -30,7 +30,17 @@ session data on disk or into a database, it must be transformed into
30a binary ASN1 representation. 30a binary ASN1 representation.
31 31
32When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically 32When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically
33allocated. 33allocated. The reference count is 1, so that the session must be
34explicitly removed using L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
35unless the SSL_SESSION object is completely taken over, when being called
36inside the get_session_cb() (see
37L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>).
38
39SSL_SESSION objects keep internal link information about the session cache
40list, when being inserted into one SSL_CTX object's session cache.
41One SSL_SESSION object, regardless of its reference count, must therefore
42only be used with one SSL_CTX object (and the SSL objects created
43from this SSL_CTX object).
34 44
35When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be 45When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be
36large enough to hold the binary representation of the session. There is no 46large enough to hold the binary representation of the session. There is no
@@ -50,7 +60,7 @@ When the session is not valid, B<0> is returned and no operation is performed.
50 60
51=head1 SEE ALSO 61=head1 SEE ALSO
52 62
53L<ssl(3)|ssl(3)>, 63L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
54L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)> 64L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
55 65
56=cut 66=cut
diff --git a/src/lib/libssl/src/doc/ssl/ssl.pod b/src/lib/libssl/src/doc/ssl/ssl.pod
index 16292a05f2..ce41b3e17d 100644
--- a/src/lib/libssl/src/doc/ssl/ssl.pod
+++ b/src/lib/libssl/src/doc/ssl/ssl.pod
@@ -299,7 +299,7 @@ protocol context defined in the B<SSL_CTX> structure.
299 299
300=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs); 300=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
301 301
302=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(SSL_CTX *), char *arg) 302=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(), char *arg)
303 303
304=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str); 304=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
305 305
@@ -317,6 +317,10 @@ protocol context defined in the B<SSL_CTX> structure.
317 317
318=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret)); 318=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
319 319
320=item void B<SSL_CTX_set_msg_callback>(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
321
322=item void B<SSL_CTX_set_msg_callback_arg>(SSL_CTX *ctx, void *arg);
323
320=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op); 324=item void B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
321 325
322=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode); 326=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
@@ -576,6 +580,10 @@ connection defined in the B<SSL> structure.
576 580
577=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void)) 581=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
578 582
583=item void B<SSL_set_msg_callback>(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
584
585=item void B<SSL_set_msg_callback_arg>(SSL *ctx, void *arg);
586
579=item void B<SSL_set_options>(SSL *ssl, unsigned long op); 587=item void B<SSL_set_options>(SSL *ssl, unsigned long op);
580 588
581=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode); 589=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
@@ -650,8 +658,10 @@ L<openssl(1)|openssl(1)>, L<crypto(3)|crypto(3)>,
650L<SSL_accept(3)|SSL_accept(3)>, L<SSL_clear(3)|SSL_clear(3)>, 658L<SSL_accept(3)|SSL_accept(3)>, L<SSL_clear(3)|SSL_clear(3)>,
651L<SSL_connect(3)|SSL_connect(3)>, 659L<SSL_connect(3)|SSL_connect(3)>,
652L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>, 660L<SSL_CIPHER_get_name(3)|SSL_CIPHER_get_name(3)>,
661L<SSL_COMP_add_compression_method(3)|SSL_COMP_add_compression_method(3)>,
653L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>, 662L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,
654L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>, 663L<SSL_CTX_add_session(3)|SSL_CTX_add_session(3)>,
664L<SSL_CTX_ctrl(3)|SSL_CTX_ctrl(3)>,
655L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>, 665L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
656L<SSL_CTX_get_ex_new_index(3)|SSL_CTX_get_ex_new_index(3)>, 666L<SSL_CTX_get_ex_new_index(3)|SSL_CTX_get_ex_new_index(3)>,
657L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>, 667L<SSL_CTX_get_verify_mode(3)|SSL_CTX_get_verify_mode(3)>,
@@ -661,18 +671,32 @@ L<SSL_CTX_sess_number(3)|SSL_CTX_sess_number(3)>,
661L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>, 671L<SSL_CTX_sess_set_cache_size(3)|SSL_CTX_sess_set_cache_size(3)>,
662L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>, 672L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>,
663L<SSL_CTX_sessions(3)|SSL_CTX_sessions(3)>, 673L<SSL_CTX_sessions(3)|SSL_CTX_sessions(3)>,
674L<SSL_CTX_set_cert_store(3)|SSL_CTX_set_cert_store(3)>,
675L<SSL_CTX_set_cert_verify_callback(3)|SSL_CTX_set_cert_verify_callback(3)>,
676L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>,
664L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>, 677L<SSL_CTX_set_client_CA_list(3)|SSL_CTX_set_client_CA_list(3)>,
678L<SSL_CTX_set_client_cert_cb(3)|SSL_CTX_set_client_cert_cb(3)>,
665L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>, 679L<SSL_CTX_set_default_passwd_cb(3)|SSL_CTX_set_default_passwd_cb(3)>,
680L<SSL_CTX_set_generate_session_id(3)|SSL_CTX_set_generate_session_id(3)>,
681L<SSL_CTX_set_info_callback(3)|SSL_CTX_set_info_callback(3)>,
682L<SSL_CTX_set_max_cert_list(3)|SSL_CTX_set_max_cert_list(3)>,
666L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, 683L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>,
684L<SSL_CTX_set_msg_callback(3)|SSL_CTX_set_msg_callback(3)>,
667L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>, 685L<SSL_CTX_set_options(3)|SSL_CTX_set_options(3)>,
686L<SSL_CTX_set_quiet_shutdown(3)|SSL_CTX_set_quiet_shutdown(3)>,
668L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>, 687L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
669L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>, 688L<SSL_CTX_set_session_id_context(3)|SSL_CTX_set_session_id_context(3)>,
670L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>, 689L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)>,
671L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>, 690L<SSL_CTX_set_timeout(3)|SSL_CTX_set_timeout(3)>,
691L<SSL_CTX_set_tmp_rsa_callback(3)|SSL_CTX_set_tmp_rsa_callback(3)>,
692L<SSL_CTX_set_tmp_dh_callback(3)|SSL_CTX_set_tmp_dh_callback(3)>,
672L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>, 693L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
673L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>, 694L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,
695L<SSL_alert_type_string(3)|SSL_alert_type_string(3)>,
696L<SSL_get_SSL_CTX(3)|SSL_get_SSL_CTX(3)>,
674L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, 697L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>,
675L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>, 698L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,
699L<SSL_get_default_timeout(3)|SSL_get_default_timeout(3)>,
676L<SSL_get_error(3)|SSL_get_error(3)>, 700L<SSL_get_error(3)|SSL_get_error(3)>,
677L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>, 701L<SSL_get_ex_data_X509_STORE_CTX_idx(3)|SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
678L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>, 702L<SSL_get_ex_new_index(3)|SSL_get_ex_new_index(3)>,
@@ -685,12 +709,19 @@ L<SSL_get_version(3)|SSL_get_version(3)>,
685L<SSL_library_init(3)|SSL_library_init(3)>, 709L<SSL_library_init(3)|SSL_library_init(3)>,
686L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>, 710L<SSL_load_client_CA_file(3)|SSL_load_client_CA_file(3)>,
687L<SSL_new(3)|SSL_new(3)>, 711L<SSL_new(3)|SSL_new(3)>,
688L<SSL_read(3)|SSL_read(3)>, L<SSL_set_bio(3)|SSL_set_bio(3)>, 712L<SSL_pending(3)|SSL_pending(3)>,
713L<SSL_read(3)|SSL_read(3)>,
714L<SSL_rstate_string(3)|SSL_rstate_string(3)>,
715L<SSL_session_reused(3)|SSL_session_reused(3)>,
716L<SSL_set_bio(3)|SSL_set_bio(3)>,
689L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>, 717L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,
690L<SSL_set_fd(3)|SSL_set_fd(3)>, L<SSL_pending(3)|SSL_pending(3)>, 718L<SSL_set_fd(3)|SSL_set_fd(3)>,
691L<SSL_set_session(3)|SSL_set_session(3)>, 719L<SSL_set_session(3)|SSL_set_session(3)>,
692L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>, 720L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,
693L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_write(3)|SSL_write(3)>, 721L<SSL_shutdown(3)|SSL_shutdown(3)>,
722L<SSL_state_string(3)|SSL_state_string(3)>,
723L<SSL_want(3)|SSL_want(3)>,
724L<SSL_write(3)|SSL_write(3)>,
694L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>, 725L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
695L<SSL_SESSION_get_ex_new_index(3)|SSL_SESSION_get_ex_new_index(3)>, 726L<SSL_SESSION_get_ex_new_index(3)|SSL_SESSION_get_ex_new_index(3)>,
696L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>, 727L<SSL_SESSION_get_time(3)|SSL_SESSION_get_time(3)>,
diff --git a/src/lib/libssl/src/doc/ssleay.txt b/src/lib/libssl/src/doc/ssleay.txt
index fab8d42c42..c6049d5e53 100644
--- a/src/lib/libssl/src/doc/ssleay.txt
+++ b/src/lib/libssl/src/doc/ssleay.txt
@@ -1,6 +1,22 @@
1 1
2Bundle of old SSLeay documentation files [OBSOLETE!] 2Bundle of old SSLeay documentation files [OBSOLETE!]
3 3
4*** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! ***
5
6OBSOLETE means that nothing in this document should be trusted. This
7document is provided mostly for historical purposes (it wasn't even up
8to date at the time SSLeay 0.8.1 was released) and as inspiration. If
9you copy some snippet of code from this document, please _check_ that
10it really is correct from all points of view. For example, you can
11check with the other documents in this directory tree, or by comparing
12with relevant parts of the include files.
13
14People have done the mistake of trusting what's written here. Please
15don't do that.
16
17*** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! ***
18
19
4==== readme ======================================================== 20==== readme ========================================================
5 21
6This is the old 0.6.6 docuementation. Most of the cipher stuff is still 22This is the old 0.6.6 docuementation. Most of the cipher stuff is still
diff --git a/src/lib/libssl/src/doc/standards.txt b/src/lib/libssl/src/doc/standards.txt
index 61ccc5d7e0..596d9001e6 100644
--- a/src/lib/libssl/src/doc/standards.txt
+++ b/src/lib/libssl/src/doc/standards.txt
@@ -24,7 +24,8 @@ http://www.rsasecurity.com/rsalabs/pkcs/.
24Implemented: 24Implemented:
25------------ 25------------
26 26
27These are documents that describe things that are implemented in OpenSSL. 27These are documents that describe things that are implemented (in
28whole or at least great parts) in OpenSSL.
28 29
291319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992. 301319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992.
30 (Format: TXT=25661 bytes) (Status: INFORMATIONAL) 31 (Format: TXT=25661 bytes) (Status: INFORMATIONAL)
@@ -59,6 +60,11 @@ PKCS#8: Private-Key Information Syntax Standard
59 60
60PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. 61PKCS#12: Personal Information Exchange Syntax Standard, version 1.0.
61 62
632560 X.509 Internet Public Key Infrastructure Online Certificate
64 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin,
65 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED
66 STANDARD)
67
62 68
63Related: 69Related:
64-------- 70--------
@@ -84,6 +90,10 @@ STARTTLS documents.
84 Certification and Related Services. B. Kaliski. February 1993. 90 Certification and Related Services. B. Kaliski. February 1993.
85 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) 91 (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD)
86 92
932256 A Summary of the X.500(96) User Schema for use with LDAPv3. M.
94 Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED
95 STANDARD)
96
872487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. 972487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman.
88 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) 98 January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD)
89 99
@@ -114,8 +124,7 @@ To be implemented:
114These are documents that describe things that are planed to be 124These are documents that describe things that are planed to be
115implemented in the hopefully short future. 125implemented in the hopefully short future.
116 126
1172560 X.509 Internet Public Key Infrastructure Online Certificate 1272712 Addition of Kerberos Cipher Suites to Transport Layer Security
118 Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin, 128 (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes)
119 C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED 129 (Status: PROPOSED STANDARD)
120 STANDARD)
121 130
diff --git a/src/lib/libssl/src/e_os.h b/src/lib/libssl/src/e_os.h
index 44aec41406..49811404c5 100644
--- a/src/lib/libssl/src/e_os.h
+++ b/src/lib/libssl/src/e_os.h
@@ -77,12 +77,24 @@ extern "C" {
77#endif 77#endif
78 78
79#ifndef DEVRANDOM 79#ifndef DEVRANDOM
80/* set this to your 'random' device if you have one. 80/* set this to a comma-separated list of 'random' device files to try out.
81 * By default, we will try to read this file */ 81 * My default, we will try to read at least one of these files */
82#define DEVRANDOM "/dev/arandom" 82#define DEVRANDOM "/dev/arandom","/dev/urandom","/dev/random","/dev/srandom"
83#endif
84#ifndef DEVRANDOM_EGD
85/* set this to a comma-seperated list of 'egd' sockets to try out. These
86 * sockets will be tried in the order listed in case accessing the device files
87 * listed in DEVRANDOM did not return enough entropy. */
88#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
83#endif 89#endif
84 90
85#if defined(__MWERKS__) && defined(macintosh) 91#if defined(OPENSSL_SYS_VXWORKS)
92# define NO_SYS_PARAM_H
93# define NO_CHMOD
94# define NO_SYSLOG
95#endif
96
97#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
86# if macintosh==1 98# if macintosh==1
87# ifndef MAC_OS_GUSI_SOURCE 99# ifndef MAC_OS_GUSI_SOURCE
88# define MAC_OS_pre_X 100# define MAC_OS_pre_X
@@ -102,23 +114,23 @@ extern "C" {
102 ********************************************************************/ 114 ********************************************************************/
103/* The following is used becaue of the small stack in some 115/* The following is used becaue of the small stack in some
104 * Microsoft operating systems */ 116 * Microsoft operating systems */
105#if defined(WIN16) || defined(MSDOS) 117#if defined(OPENSSL_SYS_MSDOS)
106# define MS_STATIC static 118# define MS_STATIC static
107#else 119#else
108# define MS_STATIC 120# define MS_STATIC
109#endif 121#endif
110 122
111#if defined(_WIN32) && !defined(WIN32) && !defined(__CYGWIN32__) 123#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
112# define WIN32 124# define WIN32
113#endif 125#endif
114 126#if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
115#if (defined(WIN32) || defined(WIN16)) && !defined(__CYGWIN32__) 127# define WIN16
116# ifndef WINDOWS 128#endif
117# define WINDOWS 129#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
118# endif 130# define WINDOWS
119# ifndef MSDOS 131#endif
120# define MSDOS 132#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
121# endif 133# define MSDOS
122#endif 134#endif
123 135
124#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS) 136#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
@@ -136,7 +148,7 @@ extern "C" {
136#define clear_sys_error() errno=0 148#define clear_sys_error() errno=0
137#endif 149#endif
138 150
139#if defined(WINDOWS) && !defined(__CYGWIN32__) 151#if defined(WINDOWS)
140#define get_last_socket_error() WSAGetLastError() 152#define get_last_socket_error() WSAGetLastError()
141#define clear_socket_error() WSASetLastError(0) 153#define clear_socket_error() WSASetLastError(0)
142#define readsocket(s,b,n) recv((s),(b),(n),0) 154#define readsocket(s,b,n) recv((s),(b),(n),0)
@@ -148,6 +160,13 @@ extern "C" {
148#define closesocket(s) MacSocket_close(s) 160#define closesocket(s) MacSocket_close(s)
149#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true) 161#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
150#define writesocket(s,b,n) MacSocket_send((s),(b),(n)) 162#define writesocket(s,b,n) MacSocket_send((s),(b),(n))
163#elif defined(OPENSSL_SYS_VMS)
164#define get_last_socket_error() errno
165#define clear_socket_error() errno=0
166#define ioctlsocket(a,b,c) ioctl(a,b,c)
167#define closesocket(s) close(s)
168#define readsocket(s,b,n) recv((s),(b),(n),0)
169#define writesocket(s,b,n) send((s),(b),(n),0)
151#else 170#else
152#define get_last_socket_error() errno 171#define get_last_socket_error() errno
153#define clear_socket_error() errno=0 172#define clear_socket_error() errno=0
@@ -158,7 +177,7 @@ extern "C" {
158#endif 177#endif
159 178
160#ifdef WIN16 179#ifdef WIN16
161# define NO_FP_API 180# define OPENSSL_NO_FP_API
162# define MS_CALLBACK _far _loadds 181# define MS_CALLBACK _far _loadds
163# define MS_FAR _far 182# define MS_FAR _far
164#else 183#else
@@ -166,25 +185,24 @@ extern "C" {
166# define MS_FAR 185# define MS_FAR
167#endif 186#endif
168 187
169#ifdef NO_STDIO 188#ifdef OPENSSL_NO_STDIO
170# define NO_FP_API 189# define OPENSSL_NO_FP_API
171#endif 190#endif
172 191
173#if (defined(WINDOWS) || defined(MSDOS)) && !defined(__CYGWIN32__) 192#if (defined(WINDOWS) || defined(MSDOS))
174 193
175#ifndef S_IFDIR 194# ifndef S_IFDIR
176#define S_IFDIR _S_IFDIR 195# define S_IFDIR _S_IFDIR
177#endif 196# endif
178
179#ifndef S_IFMT
180#define S_IFMT _S_IFMT
181 197
182#if !defined(WINNT) 198# ifndef S_IFMT
183#define NO_SYSLOG 199# define S_IFMT _S_IFMT
184#endif 200# endif
185#define NO_DIRENT
186 201
187#endif 202# if !defined(WINNT)
203# define NO_SYSLOG
204# endif
205# define NO_DIRENT
188 206
189# ifdef WINDOWS 207# ifdef WINDOWS
190# include <windows.h> 208# include <windows.h>
@@ -196,29 +214,31 @@ extern "C" {
196# include <io.h> 214# include <io.h>
197# include <fcntl.h> 215# include <fcntl.h>
198 216
199#if defined (__BORLANDC__) 217# define ssize_t long
200#define _setmode setmode
201#define _O_TEXT O_TEXT
202#define _O_BINARY O_BINARY
203#define _int64 __int64
204#define _kbhit kbhit
205#endif
206 218
207#if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) 219# if defined (__BORLANDC__)
208# define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } 220# define _setmode setmode
209#else 221# define _O_TEXT O_TEXT
210# define EXIT(n) return(n); 222# define _O_BINARY O_BINARY
211#endif 223# define _int64 __int64
224# define _kbhit kbhit
225# endif
226
227# if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
228# define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); }
229# else
230# define EXIT(n) return(n);
231# endif
212# define LIST_SEPARATOR_CHAR ';' 232# define LIST_SEPARATOR_CHAR ';'
213#ifndef X_OK 233# ifndef X_OK
214# define X_OK 0 234# define X_OK 0
215#endif 235# endif
216#ifndef W_OK 236# ifndef W_OK
217# define W_OK 2 237# define W_OK 2
218#endif 238# endif
219#ifndef R_OK 239# ifndef R_OK
220# define R_OK 4 240# define R_OK 4
221#endif 241# endif
222# define OPENSSL_CONF "openssl.cnf" 242# define OPENSSL_CONF "openssl.cnf"
223# define SSLEAY_CONF OPENSSL_CONF 243# define SSLEAY_CONF OPENSSL_CONF
224# define NUL_DEV "nul" 244# define NUL_DEV "nul"
@@ -227,11 +247,8 @@ extern "C" {
227 247
228#else /* The non-microsoft world world */ 248#else /* The non-microsoft world world */
229 249
230# if defined(__VMS) && !defined(VMS) 250# ifdef OPENSSL_SYS_VMS
231# define VMS 1 251# define VMS 1
232# endif
233
234# ifdef VMS
235 /* some programs don't include stdlib, so exit() and others give implicit 252 /* some programs don't include stdlib, so exit() and others give implicit
236 function warnings */ 253 function warnings */
237# include <stdlib.h> 254# include <stdlib.h>
@@ -245,23 +262,39 @@ extern "C" {
245# define RFILE ".rnd" 262# define RFILE ".rnd"
246# define LIST_SEPARATOR_CHAR ',' 263# define LIST_SEPARATOR_CHAR ','
247# define NUL_DEV "NLA0:" 264# define NUL_DEV "NLA0:"
248 /* We need to do this, because DEC C converts exit code 0 to 1, but not 1 265 /* We don't have any well-defined random devices on VMS, yet... */
249 to 0. We will convert 1 to 3! Also, add the inhibit message bit... */ 266# undef DEVRANDOM
250# ifndef MONOLITH 267 /* We need to do this since VMS has the following coding on status codes:
268
269 Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
270 The important thing to know is that odd numbers are considered
271 good, while even ones are considered errors.
272 Bits 3-15: actual status number
273 Bits 16-27: facility number. 0 is considered "unknown"
274 Bits 28-31: control bits. If bit 28 is set, the shell won't try to
275 output the message (which, for random codes, just looks ugly)
276
277 So, what we do here is to change 0 to 1 to get the default success status,
278 and everything else is shifted up to fit into the status number field, and
279 the status is tagged as an error, which I believe is what is wanted here.
280 -- Richard Levitte
281 */
282# if !defined(MONOLITH) || defined(OPENSSL_C)
251# define EXIT(n) do { int __VMS_EXIT = n; \ 283# define EXIT(n) do { int __VMS_EXIT = n; \
252 if (__VMS_EXIT == 1) __VMS_EXIT = 3; \ 284 if (__VMS_EXIT == 0) \
285 __VMS_EXIT = 1; \
286 else \
287 __VMS_EXIT = (n << 3) | 2; \
253 __VMS_EXIT |= 0x10000000; \ 288 __VMS_EXIT |= 0x10000000; \
254 exit(n); return(n); } while(0) 289 exit(__VMS_EXIT); \
290 return(__VMS_EXIT); } while(0)
255# else 291# else
256# define EXIT(n) do { int __VMS_EXIT = n; \ 292# define EXIT(n) return(n)
257 if (__VMS_EXIT == 1) __VMS_EXIT = 3; \
258 __VMS_EXIT |= 0x10000000; \
259 return(n); } while(0)
260# endif 293# endif
261# define NO_SYS_PARAM_H 294# define NO_SYS_PARAM_H
262# else 295# else
263 /* !defined VMS */ 296 /* !defined VMS */
264# ifdef MPE 297# ifdef OPENSSL_SYS_MPE
265# define NO_SYS_PARAM_H 298# define NO_SYS_PARAM_H
266# endif 299# endif
267# ifdef OPENSSL_UNISTD 300# ifdef OPENSSL_UNISTD
@@ -272,13 +305,13 @@ extern "C" {
272# ifndef NO_SYS_TYPES_H 305# ifndef NO_SYS_TYPES_H
273# include <sys/types.h> 306# include <sys/types.h>
274# endif 307# endif
275# if defined(NeXT) || defined(NEWS4) 308# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
276# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP 309# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
277 * (unless when compiling with -D_POSIX_SOURCE, 310 * (unless when compiling with -D_POSIX_SOURCE,
278 * which doesn't work for us) */ 311 * which doesn't work for us) */
279# define ssize_t int /* ditto */ 312# define ssize_t int /* ditto */
280# endif 313# endif
281# ifdef NEWS4 /* setvbuf is missing on mips-sony-bsd */ 314# ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
282# define setvbuf(a, b, c, d) setbuffer((a), (b), (d)) 315# define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
283 typedef unsigned long clock_t; 316 typedef unsigned long clock_t;
284# endif 317# endif
@@ -306,7 +339,7 @@ extern "C" {
306# if defined(WINDOWS) || defined(MSDOS) 339# if defined(WINDOWS) || defined(MSDOS)
307 /* windows world */ 340 /* windows world */
308 341
309# ifdef NO_SOCK 342# ifdef OPENSSL_NO_SOCK
310# define SSLeay_Write(a,b,c) (-1) 343# define SSLeay_Write(a,b,c) (-1)
311# define SSLeay_Read(a,b,c) (-1) 344# define SSLeay_Read(a,b,c) (-1)
312# define SHUTDOWN(fd) close(fd) 345# define SHUTDOWN(fd) close(fd)
@@ -333,12 +366,14 @@ extern HINSTANCE _hInstance;
333# ifndef NO_SYS_PARAM_H 366# ifndef NO_SYS_PARAM_H
334# include <sys/param.h> 367# include <sys/param.h>
335# endif 368# endif
336# ifndef MPE 369# ifdef OPENSSL_SYS_VXWORKS
370# include <time.h>
371# elif !defined(OPENSSL_SYS_MPE)
337# include <sys/time.h> /* Needed under linux for FD_XXX */ 372# include <sys/time.h> /* Needed under linux for FD_XXX */
338# endif 373# endif
339 374
340# include <netdb.h> 375# include <netdb.h>
341# if defined(VMS) && !defined(__DECC) 376# if defined(OPENSSL_SYS_VMS_NODECC)
342# include <socket.h> 377# include <socket.h>
343# include <in.h> 378# include <in.h>
344# include <inet.h> 379# include <inet.h>
@@ -356,7 +391,7 @@ extern HINSTANCE _hInstance;
356# include <sys/types.h> 391# include <sys/types.h>
357# endif 392# endif
358 393
359# ifdef AIX 394# ifdef OPENSSL_SYS_AIX
360# include <sys/select.h> 395# include <sys/select.h>
361# endif 396# endif
362 397
@@ -392,13 +427,16 @@ extern HINSTANCE _hInstance;
392# endif 427# endif
393#endif 428#endif
394 429
395#if defined(THREADS) || defined(sun) 430#if defined(__ultrix)
396#ifndef _REENTRANT 431# ifndef ssize_t
397#define _REENTRANT 432# define ssize_t int
398#endif 433# endif
399#endif 434#endif
400 435
401#if defined(sun) && !defined(__svr4__) && !defined(__SVR4) 436#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
437 /* include headers first, so our defines don't break it */
438#include <stdlib.h>
439#include <string.h>
402 /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */ 440 /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
403# define memmove(s1,s2,n) bcopy((s2),(s1),(n)) 441# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
404# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b))) 442# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
@@ -426,21 +464,15 @@ extern char *sys_errlist[]; extern int sys_nerr;
426#ifdef sgi 464#ifdef sgi
427#define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */ 465#define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
428#endif 466#endif
429#ifdef SNI 467#ifdef OPENSSL_SYS_SNI
430#define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/ 468#define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
431#endif 469#endif
432 470
433#ifdef NO_MD2 471#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
434#define MD2_Init MD2Init 472# include <io.h>
435#define MD2_Update MD2Update 473# include <fcntl.h>
436#define MD2_Final MD2Final 474# define NO_SYSLOG
437#define MD2_DIGEST_LENGTH 16 475# define strcasecmp stricmp
438#endif
439#ifdef NO_MD5
440#define MD5_Init MD5Init
441#define MD5_Update MD5Update
442#define MD5_Final MD5Final
443#define MD5_DIGEST_LENGTH 16
444#endif 476#endif
445 477
446#ifdef __cplusplus 478#ifdef __cplusplus
diff --git a/src/lib/libssl/src/e_os2.h b/src/lib/libssl/src/e_os2.h
index 5a25ac7cf6..9c4a541728 100644
--- a/src/lib/libssl/src/e_os2.h
+++ b/src/lib/libssl/src/e_os2.h
@@ -1,15 +1,185 @@
1/* e_os2.h */ 1/* e_os2.h */
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 <openssl/opensslconf.h>
2 57
3#ifndef HEADER_E_OS2_H 58#ifndef HEADER_E_OS2_H
4#define HEADER_E_OS2_H 59#define HEADER_E_OS2_H
5 60
6#include <openssl/opensslconf.h> /* OPENSSL_UNISTD */
7
8#ifdef __cplusplus 61#ifdef __cplusplus
9extern "C" { 62extern "C" {
10#endif 63#endif
11 64
12#ifdef MSDOS 65/******************************************************************************
66 * Detect operating systems. This probably needs completing.
67 * The result is that at least one OPENSSL_SYS_os macro should be defined.
68 * However, if none is defined, Unix is assumed.
69 **/
70
71#define OPENSSL_SYS_UNIX
72
73/* ----------------------- Macintosh, before MacOS X ----------------------- */
74#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)
75# undef OPENSSL_SYS_UNIX
76# define OPENSSL_SYS_MACINTOSH_CLASSIC
77#endif
78
79/* ---------------------- Microsoft operating systems ---------------------- */
80
81/* The 16 bit environments are pretty straightforward */
82#if defined(OPENSSL_SYSNAME_WIN16) || defined(OPENSSL_SYSNAME_MSDOS)
83# undef OPENSSL_SYS_UNIX
84# define OPENSSL_SYS_MSDOS
85#endif
86#if defined(OPENSSL_SYSNAME_WIN16)
87# undef OPENSSL_SYS_UNIX
88# define OPENSSL_SYS_WIN16
89#endif
90
91/* For 32 bit environment, there seems to be the CygWin environment and then
92 all the others that try to do the same thing Microsoft does... */
93#if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32)
94# undef OPENSSL_SYS_UNIX
95# define OPENSSL_SYS_WIN32_CYGWIN
96#else
97# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)
98# undef OPENSSL_SYS_UNIX
99# define OPENSSL_SYS_WIN32
100# endif
101# if defined(OPENSSL_SYSNAME_WINNT)
102# undef OPENSSL_SYS_UNIX
103# define OPENSSL_SYS_WINNT
104# endif
105#endif
106
107/* Anything that tries to look like Microsoft is "Windows" */
108#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT)
109# undef OPENSSL_SYS_UNIX
110# define OPENSSL_SYS_WINDOWS
111# ifndef OPENSSL_SYS_MSDOS
112# define OPENSSL_SYS_MSDOS
113# endif
114#endif
115
116/* DLL settings. This part is a bit tough, because it's up to the application
117 implementor how he or she will link the application, so it requires some
118 macro to be used. */
119#ifdef OPENSSL_SYS_WINDOWS
120# ifndef OPENSSL_OPT_WINDLL
121# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that
122 DLL linkage should be used */
123# define OPENSSL_OPT_WINDLL
124# endif
125# endif
126#endif
127
128/* -------------------------------- OpenVMS -------------------------------- */
129#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)
130# undef OPENSSL_SYS_UNIX
131# define OPENSSL_SYS_VMS
132# if defined(__DECC)
133# define OPENSSL_SYS_VMS_DECC
134# elif defined(__DECCXX)
135# define OPENSSL_SYS_VMS_DECC
136# define OPENSSL_SYS_VMS_DECCXX
137# else
138# define OPENSSL_SYS_VMS_NODECC
139# endif
140#endif
141
142/* --------------------------------- OS/2 ---------------------------------- */
143#if defined(__EMX__) || defined(__OS2__)
144# undef OPENSSL_SYS_UNIX
145# define OPENSSL_SYS_OS2
146#endif
147
148/* --------------------------------- Unix ---------------------------------- */
149#ifdef OPENSSL_SYS_UNIX
150# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)
151# define OPENSSL_SYS_LINUX
152# endif
153# ifdef OPENSSL_SYSNAME_MPE
154# define OPENSSL_SYS_MPE
155# endif
156# ifdef OPENSSL_SYSNAME_SNI
157# define OPENSSL_SYS_SNI
158# endif
159# ifdef OPENSSL_SYSNAME_ULTRASPARC
160# define OPENSSL_SYS_ULTRASPARC
161# endif
162# ifdef OPENSSL_SYSNAME_NEWS4
163# define OPENSSL_SYS_NEWS4
164# endif
165# ifdef OPENSSL_SYSNAME_MACOSX
166# define OPENSSL_SYS_MACOSX
167# endif
168# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)
169# define OPENSSL_SYS_CRAY
170# endif
171# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)
172# define OPENSSL_SYS_AIX
173# endif
174#endif
175
176/**
177 * That's it for OS-specific stuff
178 *****************************************************************************/
179
180
181/* Specials for I/O an exit */
182#ifdef OPENSSL_SYS_MSDOS
13# define OPENSSL_UNISTD_IO <io.h> 183# define OPENSSL_UNISTD_IO <io.h>
14# define OPENSSL_DECLARE_EXIT extern void exit(int); 184# define OPENSSL_DECLARE_EXIT extern void exit(int);
15#else 185#else
@@ -17,22 +187,63 @@ extern "C" {
17# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ 187# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */
18#endif 188#endif
19 189
20/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, 190/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
21 to define and declare certain global 191 certain global symbols that, with some compilers under VMS, have to be
22 symbols that, with some compilers under VMS, have to be defined and 192 defined and declared explicitely with globaldef and globalref.
23 declared explicitely with globaldef and globalref. On other OS:es, 193 Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
24 these macros are defined with something sensible. */ 194 DLL exports and imports for compilers under Win32. These are a little
195 more complicated to use. Basically, for any library that exports some
196 global variables, the following code must be present in the header file
197 that declares them, before OPENSSL_EXTERN is used:
25 198
26#if defined(VMS) && !defined(__DECC) 199 #ifdef SOME_BUILD_FLAG_MACRO
27# define OPENSSL_EXTERN globalref 200 # undef OPENSSL_EXTERN
201 # define OPENSSL_EXTERN OPENSSL_EXPORT
202 #endif
203
204 The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL
205 have some generally sensible values, and for OPENSSL_EXTERN to have the
206 value OPENSSL_IMPORT.
207*/
208
209#if defined(OPENSSL_SYS_VMS_NODECC)
210# define OPENSSL_EXPORT globalref
211# define OPENSSL_IMPORT globalref
28# define OPENSSL_GLOBAL globaldef 212# define OPENSSL_GLOBAL globaldef
213#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
214# define OPENSSL_EXPORT extern _declspec(dllexport)
215# define OPENSSL_IMPORT extern _declspec(dllimport)
216# define OPENSSL_GLOBAL
29#else 217#else
30# define OPENSSL_EXTERN extern 218# define OPENSSL_EXPORT extern
219# define OPENSSL_IMPORT extern
31# define OPENSSL_GLOBAL 220# define OPENSSL_GLOBAL
32#endif 221#endif
222#define OPENSSL_EXTERN OPENSSL_IMPORT
223
224/* Macros to allow global variables to be reached through function calls when
225 required (if a shared library version requvres it, for example.
226 The way it's done allows definitions like this:
227
228 // in foobar.c
229 OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0;
230 // in foobar.h
231 OPENSSL_DECLARE_GLOBAL(int,foobar);
232 #define foobar OPENSSL_GLOBAL_REF(foobar)
233*/
234#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
235# define OPENSSL_IMPLEMENT_GLOBAL(type,name) static type _hide_##name; \
236 type *_shadow_##name(void) { return &_hide_##name; } \
237 static type _hide_##name
238# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
239# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
240#else
241# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name
242# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
243# define OPENSSL_GLOBAL_REF(name) _shadow_##name
244#endif
33 245
34#ifdef __cplusplus 246#ifdef __cplusplus
35} 247}
36#endif 248#endif
37#endif 249#endif
38
diff --git a/src/lib/libssl/src/install.com b/src/lib/libssl/src/install.com
index e09d13ae5f..86fae7e872 100644
--- a/src/lib/libssl/src/install.com
+++ b/src/lib/libssl/src/install.com
@@ -53,7 +53,7 @@ $ IF F$PARSE("WRK_SSLROOT:[VMS]") .EQS. "" THEN -
53 CREATE/DIR/LOG WRK_SSLROOT:[VMS] 53 CREATE/DIR/LOG WRK_SSLROOT:[VMS]
54$ 54$
55$ SDIRS := CRYPTO,SSL,RSAREF,APPS,VMS!,TEST,TOOLS 55$ SDIRS := CRYPTO,SSL,RSAREF,APPS,VMS!,TEST,TOOLS
56$ EXHEADER := e_os.h,e_os2.h 56$ EXHEADER := e_os2.h
57$ 57$
58$ COPY 'EXHEADER' WRK_SSLINCLUDE: /LOG 58$ COPY 'EXHEADER' WRK_SSLINCLUDE: /LOG
59$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'EXHEADER' 59$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'EXHEADER'
diff --git a/src/lib/libssl/src/makevms.com b/src/lib/libssl/src/makevms.com
index 733e0e6f4f..5a0f5e228c 100644
--- a/src/lib/libssl/src/makevms.com
+++ b/src/lib/libssl/src/makevms.com
@@ -185,6 +185,59 @@ $!
185$ WRITE H_FILE "/* This file was automatically built using makevms.com */" 185$ WRITE H_FILE "/* This file was automatically built using makevms.com */"
186$ WRITE H_FILE "/* and [.CRYPTO]OPENSSLCONF.H_IN */" 186$ WRITE H_FILE "/* and [.CRYPTO]OPENSSLCONF.H_IN */"
187$ 187$
188$!
189$! Write a few macros that indicate how this system was built.
190$!
191$ WRITE H_FILE ""
192$ WRITE H_FILE "#ifndef OPENSSL_SYS_VMS"
193$ WRITE H_FILE "# define OPENSSL_SYS_VMS"
194$ WRITE H_FILE "#endif"
195$ CONFIG_LOGICALS := NO_ASM,NO_RSA,NO_DSA,NO_DH,NO_MD2,NO_MD5,NO_RIPEMD,-
196 NO_SHA,NO_SHA0,NO_SHA1,NO_DES/NO_MDC2;NO_MDC2,NO_RC2,NO_RC4,NO_RC5,-
197 NO_IDEA,NO_BF,NO_CAST,NO_HMAC,NO_SSL2
198$ CONFIG_LOG_I = 0
199$ CONFIG_LOG_LOOP:
200$ CONFIG_LOG_E1 = F$ELEMENT(CONFIG_LOG_I,",",CONFIG_LOGICALS)
201$ CONFIG_LOG_I = CONFIG_LOG_I + 1
202$ IF CONFIG_LOG_E1 .EQS. "" THEN GOTO CONFIG_LOG_LOOP
203$ IF CONFIG_LOG_E1 .EQS. "," THEN GOTO CONFIG_LOG_LOOP_END
204$ CONFIG_LOG_E2 = F$EDIT(CONFIG_LOG_E1,"TRIM")
205$ CONFIG_LOG_E1 = F$ELEMENT(0,";",CONFIG_LOG_E2)
206$ CONFIG_LOG_E2 = F$ELEMENT(1,";",CONFIG_LOG_E2)
207$ CONFIG_LOG_E0 = F$ELEMENT(0,"/",CONFIG_LOG_E1)
208$ CONFIG_LOG_E1 = F$ELEMENT(1,"/",CONFIG_LOG_E1)
209$ IF F$TRNLNM("OPENSSL_"+CONFIG_LOG_E0)
210$ THEN
211$ WRITE H_FILE "#ifndef OPENSSL_",CONFIG_LOG_E0
212$ WRITE H_FILE "# define OPENSSL_",CONFIG_LOG_E0
213$ WRITE H_FILE "#endif"
214$ IF CONFIG_LOG_E1 .NES. "/"
215$ THEN
216$ WRITE H_FILE "#ifndef OPENSSL_",CONFIG_LOG_E1
217$ WRITE H_FILE "# define OPENSSL_",CONFIG_LOG_E1
218$ WRITE H_FILE "#endif"
219$ ENDIF
220$ ELSE
221$ IF CONFIG_LOG_E2 .NES. ";"
222$ THEN
223$ IF F$TRNLNM("OPENSSL_"+CONFIG_LOG_E2)
224$ THEN
225$ WRITE H_FILE "#ifndef OPENSSL_",CONFIG_LOG_E2
226$ WRITE H_FILE "# define OPENSSL_",CONFIG_LOG_E2
227$ WRITE H_FILE "#endif"
228$ ENDIF
229$ ENDIF
230$ ENDIF
231$ GOTO CONFIG_LOG_LOOP
232$ CONFIG_LOG_LOOP_END:
233$ WRITE H_FILE "#ifndef OPENSSL_THREADS"
234$ WRITE H_FILE "# define OPENSSL_THREADS"
235$ WRITE H_FILE "#endif"
236$ WRITE H_FILE "#ifndef OPENSSL_NO_KRB5"
237$ WRITE H_FILE "# define OPENSSL_NO_KRB5"
238$ WRITE H_FILE "#endif"
239$ WRITE H_FILE ""
240$!
188$! Different tar version may have named the file differently 241$! Different tar version may have named the file differently
189$ IF F$SEARCH("[.CRYPTO]OPENSSLCONF.H_IN") .NES. "" 242$ IF F$SEARCH("[.CRYPTO]OPENSSLCONF.H_IN") .NES. ""
190$ THEN 243$ THEN
@@ -194,11 +247,16 @@ $ IF F$SEARCH("[.CRYPTO]OPENSSLCONF_H.IN") .NES. ""
194$ THEN 247$ THEN
195$ TYPE [.CRYPTO]OPENSSLCONF_H.IN /OUTPUT=H_FILE: 248$ TYPE [.CRYPTO]OPENSSLCONF_H.IN /OUTPUT=H_FILE:
196$ ELSE 249$ ELSE
197$ WRITE SYS$ERROR "Couldn't find a [.CRYPTO]OPENSSLCONF.H_IN. Exiting!" 250$ ! For ODS-5
198$ EXIT 0 251$ IF F$SEARCH("[.CRYPTO]OPENSSLCONF.H.IN") .NES. ""
252$ THEN
253$ TYPE [.CRYPTO]OPENSSLCONF.H.IN /OUTPUT=H_FILE:
254$ ELSE
255$ WRITE SYS$ERROR "Couldn't find a [.CRYPTO]OPENSSLCONF.H_IN. Exiting!"
256$ EXIT 0
257$ ENDIF
199$ ENDIF 258$ ENDIF
200$ ENDIF 259$ ENDIF
201$!
202$ IF ARCH .EQS. "AXP" 260$ IF ARCH .EQS. "AXP"
203$ THEN 261$ THEN
204$! 262$!
@@ -231,6 +289,8 @@ $ WRITE H_FILE "#undef THIRTY_TWO_BIT"
231$ WRITE H_FILE "#undef SIXTEEN_BIT" 289$ WRITE H_FILE "#undef SIXTEEN_BIT"
232$ WRITE H_FILE "#undef EIGHT_BIT" 290$ WRITE H_FILE "#undef EIGHT_BIT"
233$ WRITE H_FILE "#endif" 291$ WRITE H_FILE "#endif"
292$
293$ WRITE H_FILE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION"
234$! 294$!
235$! Else... 295$! Else...
236$! 296$!
@@ -263,6 +323,9 @@ $ WRITE H_FILE "#define THIRTY_TWO_BIT"
263$ WRITE H_FILE "#undef SIXTEEN_BIT" 323$ WRITE H_FILE "#undef SIXTEEN_BIT"
264$ WRITE H_FILE "#undef EIGHT_BIT" 324$ WRITE H_FILE "#undef EIGHT_BIT"
265$ WRITE H_FILE "#endif" 325$ WRITE H_FILE "#endif"
326$
327$ WRITE H_FILE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION"
328$ WRITE H_FILE "#define OPENSSL_EXPORT_VAR_AS_FUNCTION"
266$! 329$!
267$! End 330$! End
268$! 331$!
@@ -336,10 +399,12 @@ $! First, We Have To "Rebuild" The "[.TEST]" Directory, So Delete
336$! All The "C" Files That Are Currently There Now. 399$! All The "C" Files That Are Currently There Now.
337$! 400$!
338$ DELETE SYS$DISK:[.TEST]*.C;* 401$ DELETE SYS$DISK:[.TEST]*.C;*
402$ DELETE SYS$DISK:[.TEST]EVPTESTS.TXT;*
339$! 403$!
340$! Copy all the *TEST.C files from [.CRYPTO...] into [.TEST] 404$! Copy all the *TEST.C files from [.CRYPTO...] into [.TEST]
341$! 405$!
342$ COPY SYS$DISK:[.CRYPTO.*]%*TEST.C SYS$DISK:[.TEST] 406$ COPY SYS$DISK:[.CRYPTO.*]%*TEST.C SYS$DISK:[.TEST]
407$ COPY SYS$DISK:[.CRYPTO.EVP]EVPTESTS.TXT SYS$DISK:[.TEST]
343$! 408$!
344$! Copy all the *TEST.C files from [.SSL...] into [.TEST] 409$! Copy all the *TEST.C files from [.SSL...] into [.TEST]
345$! 410$!
@@ -356,17 +421,18 @@ $ IF F$PARSE("SYS$DISK:[.INCLUDE.OPENSSL]") .EQS. "" THEN -
356$! 421$!
357$! Copy All The ".H" Files From The Main Directory. 422$! Copy All The ".H" Files From The Main Directory.
358$! 423$!
359$ EXHEADER := e_os.h,e_os2.h 424$ EXHEADER := e_os2.h
360$ COPY 'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL] 425$ COPY 'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL]
361$! 426$!
362$! Copy All The ".H" Files From The [.CRYPTO] Directory Tree. 427$! Copy All The ".H" Files From The [.CRYPTO] Directory Tree.
363$! 428$!
364$ SDIRS := ,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,- 429$ SDIRS := ,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,-
365 DES,RC2,RC4,RC5,IDEA,BF,CAST,- 430 DES,RC2,RC4,RC5,IDEA,BF,CAST,-
366 BN,RSA,DSA,DH,DSO,ENGINE,- 431 BN,EC,RSA,DSA,DH,DSO,ENGINE,AES,-
367 BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,- 432 BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,-
368 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP 433 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5
369$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,symhacks.h 434$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,symhacks.h,-
435 ossl_typ.h
370$ EXHEADER_MD2 := md2.h 436$ EXHEADER_MD2 := md2.h
371$ EXHEADER_MD4 := md4.h 437$ EXHEADER_MD4 := md4.h
372$ EXHEADER_MD5 := md5.h 438$ EXHEADER_MD5 := md5.h
@@ -374,7 +440,7 @@ $ EXHEADER_SHA := sha.h
374$ EXHEADER_MDC2 := mdc2.h 440$ EXHEADER_MDC2 := mdc2.h
375$ EXHEADER_HMAC := hmac.h 441$ EXHEADER_HMAC := hmac.h
376$ EXHEADER_RIPEMD := ripemd.h 442$ EXHEADER_RIPEMD := ripemd.h
377$ EXHEADER_DES := des.h 443$ EXHEADER_DES := des.h,des_old.h
378$ EXHEADER_RC2 := rc2.h 444$ EXHEADER_RC2 := rc2.h
379$ EXHEADER_RC4 := rc4.h 445$ EXHEADER_RC4 := rc4.h
380$ EXHEADER_RC5 := rc5.h 446$ EXHEADER_RC5 := rc5.h
@@ -382,11 +448,13 @@ $ EXHEADER_IDEA := idea.h
382$ EXHEADER_BF := blowfish.h 448$ EXHEADER_BF := blowfish.h
383$ EXHEADER_CAST := cast.h 449$ EXHEADER_CAST := cast.h
384$ EXHEADER_BN := bn.h 450$ EXHEADER_BN := bn.h
451$ EXHEADER_EC := ec.h
385$ EXHEADER_RSA := rsa.h 452$ EXHEADER_RSA := rsa.h
386$ EXHEADER_DSA := dsa.h 453$ EXHEADER_DSA := dsa.h
387$ EXHEADER_DH := dh.h 454$ EXHEADER_DH := dh.h
388$ EXHEADER_DSO := dso.h 455$ EXHEADER_DSO := dso.h
389$ EXHEADER_ENGINE := engine.h 456$ EXHEADER_ENGINE := engine.h
457$ EXHEADER_AES := aes.h
390$ EXHEADER_BUFFER := buffer.h 458$ EXHEADER_BUFFER := buffer.h
391$ EXHEADER_BIO := bio.h 459$ EXHEADER_BIO := bio.h
392$ EXHEADER_STACK := stack.h,safestack.h 460$ EXHEADER_STACK := stack.h,safestack.h
@@ -395,7 +463,7 @@ $ EXHEADER_RAND := rand.h
395$ EXHEADER_ERR := err.h 463$ EXHEADER_ERR := err.h
396$ EXHEADER_OBJECTS := objects.h,obj_mac.h 464$ EXHEADER_OBJECTS := objects.h,obj_mac.h
397$ EXHEADER_EVP := evp.h 465$ EXHEADER_EVP := evp.h
398$ EXHEADER_ASN1 := asn1.h,asn1_mac.h 466$ EXHEADER_ASN1 := asn1.h,asn1_mac.h,asn1t.h
399$ EXHEADER_PEM := pem.h,pem2.h 467$ EXHEADER_PEM := pem.h,pem2.h
400$ EXHEADER_X509 := x509.h,x509_vfy.h 468$ EXHEADER_X509 := x509.h,x509_vfy.h
401$ EXHEADER_X509V3 := x509v3.h 469$ EXHEADER_X509V3 := x509v3.h
@@ -404,6 +472,9 @@ $ EXHEADER_TXT_DB := txt_db.h
404$ EXHEADER_PKCS7 := pkcs7.h 472$ EXHEADER_PKCS7 := pkcs7.h
405$ EXHEADER_PKCS12 := pkcs12.h 473$ EXHEADER_PKCS12 := pkcs12.h
406$ EXHEADER_COMP := comp.h 474$ EXHEADER_COMP := comp.h
475$ EXHEADER_OCSP := ocsp.h
476$ EXHEADER_UI := ui.h,ui_compat.h
477$ EXHEADER_KRB5 := krb5_asn.h
407$ 478$
408$ I = 0 479$ I = 0
409$ LOOP_SDIRS: 480$ LOOP_SDIRS:
@@ -422,12 +493,12 @@ $ LOOP_SDIRS_END:
422$! 493$!
423$! Copy All The ".H" Files From The [.RSAREF] Directory. 494$! Copy All The ".H" Files From The [.RSAREF] Directory.
424$! 495$!
425$ EXHEADER := rsaref.h 496$! EXHEADER := rsaref.h
426$ COPY SYS$DISK:[.RSAREF]'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL] 497$! COPY SYS$DISK:[.RSAREF]'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL]
427$! 498$!
428$! Copy All The ".H" Files From The [.SSL] Directory. 499$! Copy All The ".H" Files From The [.SSL] Directory.
429$! 500$!
430$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h 501$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h,kssl.h
431$ COPY SYS$DISK:[.SSL]'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL] 502$ COPY SYS$DISK:[.SSL]'EXHEADER' SYS$DISK:[.INCLUDE.OPENSSL]
432$! 503$!
433$! Purge all doubles 504$! Purge all doubles
@@ -470,6 +541,9 @@ $!
470$! Build The [.xxx.EXE.RSAREF]LIBRSAGLUE Library. 541$! Build The [.xxx.EXE.RSAREF]LIBRSAGLUE Library.
471$! 542$!
472$ RSAREF: 543$ RSAREF:
544$ WRITE SYS$OUTPUT ""
545$ WRITE SYS$OUTPUT "RSAref glue library not built, since it's no longer needed"
546$ RETURN
473$! 547$!
474$! Tell The User What We Are Doing. 548$! Tell The User What We Are Doing.
475$! 549$!
@@ -634,7 +708,6 @@ $ WRITE SYS$OUTPUT " CONFIG : Just build the [.CRYPTO]OPENSSLCONF.H fi
634$ WRITE SYS$OUTPUT " BUILDINF : Just build the [.CRYPTO]BUILDINF.H file." 708$ WRITE SYS$OUTPUT " BUILDINF : Just build the [.CRYPTO]BUILDINF.H file."
635$ WRITE SYS$OUTPUT " SOFTLINKS: Just Fix The Unix soft links." 709$ WRITE SYS$OUTPUT " SOFTLINKS: Just Fix The Unix soft links."
636$ WRITE SYS$OUTPUT " BUILDALL : Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done." 710$ WRITE SYS$OUTPUT " BUILDALL : Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done."
637$ WRITE SYS$OUTPUT " RSAREF : To Build Just The [.xxx.EXE.RSAREF]LIBRSAGLUE.OLB Library."
638$ WRITE SYS$OUTPUT " CRYPTO : To Build Just The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library." 711$ WRITE SYS$OUTPUT " CRYPTO : To Build Just The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library."
639$ WRITE SYS$OUTPUT " SSL : To Build Just The [.xxx.EXE.SSL]LIBSSL.OLB Library." 712$ WRITE SYS$OUTPUT " SSL : To Build Just The [.xxx.EXE.SSL]LIBSSL.OLB Library."
640$ WRITE SYS$OUTPUT " SSL_TASK : To Build Just The [.xxx.EXE.SSL]SSL_TASK.EXE Program." 713$ WRITE SYS$OUTPUT " SSL_TASK : To Build Just The [.xxx.EXE.SSL]SSL_TASK.EXE Program."
@@ -661,6 +734,7 @@ $ ENDIF
661$! 734$!
662$! Check To See If P2 Is Blank. 735$! Check To See If P2 Is Blank.
663$! 736$!
737$ P2 = "NORSAREF"
664$ IF (P2.EQS."NORSAREF") 738$ IF (P2.EQS."NORSAREF")
665$ THEN 739$ THEN
666$! 740$!
diff --git a/src/lib/libssl/src/ms/32all.bat b/src/lib/libssl/src/ms/32all.bat
index 09f47059ad..aaab9b0c9d 100644
--- a/src/lib/libssl/src/ms/32all.bat
+++ b/src/lib/libssl/src/ms/32all.bat
@@ -10,6 +10,11 @@ perl util\mkdef.pl 32 libeay > ms\libeay32.def
10perl util\mkdef.pl 32 ssleay > ms\ssleay32.def 10perl util\mkdef.pl 32 ssleay > ms\ssleay32.def
11 11
12nmake -f d32.mak 12nmake -f d32.mak
13@if errorlevel 1 goto end
13nmake -f 32.mak 14nmake -f 32.mak
15@if errorlevel 1 goto end
14nmake -f d32dll.mak 16nmake -f d32dll.mak
17@if errorlevel 1 goto end
15nmake -f 32dll.mak 18nmake -f 32dll.mak
19
20:end
diff --git a/src/lib/libssl/src/ms/testss.bat b/src/lib/libssl/src/ms/testss.bat
index 36863a5017..d9ae625439 100644
--- a/src/lib/libssl/src/ms/testss.bat
+++ b/src/lib/libssl/src/ms/testss.bat
@@ -1,4 +1,4 @@
1echo=on 1echo on
2 2
3rem set ssleay=..\out\ssleay 3rem set ssleay=..\out\ssleay
4set ssleay=%1 4set ssleay=%1
diff --git a/src/lib/libssl/src/openssl.spec b/src/lib/libssl/src/openssl.spec
index d00e461e37..4d68d705ae 100644
--- a/src/lib/libssl/src/openssl.spec
+++ b/src/lib/libssl/src/openssl.spec
@@ -1,15 +1,15 @@
1%define libmaj 0 1%define libmaj 0
2%define libmin 9 2%define libmin 9
3%define librel 6 3%define librel 7
4%define librev a 4#%define librev a
5Release: 1 5Release: 1
6 6
7%define openssldir /var/ssl 7%define openssldir /var/ssl
8 8
9Summary: Secure Sockets Layer and cryptography libraries and tools 9Summary: Secure Sockets Layer and cryptography libraries and tools
10Name: openssl-engine 10Name: openssl
11#Version: %{libmaj}.%{libmin}.%{librel} 11Version: %{libmaj}.%{libmin}.%{librel}
12Version: %{libmaj}.%{libmin}.%{librel}%{librev} 12#Version: %{libmaj}.%{libmin}.%{librel}%{librev}
13Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz 13Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz
14Copyright: Freely distributable 14Copyright: Freely distributable
15Group: System Environment/Libraries 15Group: System Environment/Libraries
@@ -38,7 +38,7 @@ libraries and tools.
38%package devel 38%package devel
39Summary: Secure Sockets Layer and cryptography static libraries and headers 39Summary: Secure Sockets Layer and cryptography static libraries and headers
40Group: Development/Libraries 40Group: Development/Libraries
41Requires: openssl-engine 41Requires: openssl
42%description devel 42%description devel
43The OpenSSL Project is a collaborative effort to develop a robust, 43The OpenSSL Project is a collaborative effort to develop a robust,
44commercial-grade, fully featured, and Open Source toolkit implementing the 44commercial-grade, fully featured, and Open Source toolkit implementing the
@@ -59,7 +59,7 @@ static libraries and header files required when developing applications.
59%package doc 59%package doc
60Summary: OpenSSL miscellaneous files 60Summary: OpenSSL miscellaneous files
61Group: Documentation 61Group: Documentation
62Requires: openssl-engine 62Requires: openssl
63%description doc 63%description doc
64The OpenSSL Project is a collaborative effort to develop a robust, 64The OpenSSL Project is a collaborative effort to develop a robust,
65commercial-grade, fully featured, and Open Source toolkit implementing the 65commercial-grade, fully featured, and Open Source toolkit implementing the
@@ -88,16 +88,13 @@ documentation and POD files from which the man pages were produced.
88perl util/perlpath.pl /usr/bin/perl 88perl util/perlpath.pl /usr/bin/perl
89 89
90%ifarch i386 i486 i586 i686 90%ifarch i386 i486 i586 i686
91./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-elf 91./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-elf shared
92#!#./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-elf shared
93%endif 92%endif
94%ifarch ppc 93%ifarch ppc
95./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-ppc 94./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-ppc shared
96#!#./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-ppc shared
97%endif 95%endif
98%ifarch alpha 96%ifarch alpha
99./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-alpha 97./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-alpha shared
100#!#./Configure %{CONFIG_FLAGS} --openssldir=%{openssldir} linux-alpha shared
101%endif 98%endif
102LD_LIBRARY_PATH=`pwd` make 99LD_LIBRARY_PATH=`pwd` make
103LD_LIBRARY_PATH=`pwd` make rehash 100LD_LIBRARY_PATH=`pwd` make rehash
@@ -112,12 +109,8 @@ for x in $RPM_BUILD_ROOT/usr/man/man*/*
112 do mv ${x} ${x}ssl 109 do mv ${x} ${x}ssl
113done 110done
114 111
115# Install RSAref stuff
116install -m644 rsaref/rsaref.h $RPM_BUILD_ROOT/usr/include/openssl
117install -m644 libRSAglue.a $RPM_BUILD_ROOT/usr/lib
118
119# Make backwards-compatibility symlink to ssleay 112# Make backwards-compatibility symlink to ssleay
120ln -s /usr/bin/openssl $RPM_BUILD_ROOT/usr/bin/ssleay 113ln -sf /usr/bin/openssl $RPM_BUILD_ROOT/usr/bin/ssleay
121 114
122%clean 115%clean
123rm -rf $RPM_BUILD_ROOT 116rm -rf $RPM_BUILD_ROOT
@@ -127,7 +120,7 @@ rm -rf $RPM_BUILD_ROOT
127%doc CHANGES CHANGES.SSLeay LICENSE NEWS README 120%doc CHANGES CHANGES.SSLeay LICENSE NEWS README
128 121
129%attr(0755,root,root) /usr/bin/* 122%attr(0755,root,root) /usr/bin/*
130#!#%attr(0755,root,root) /usr/lib/*.so* 123%attr(0755,root,root) /usr/lib/*.so*
131%attr(0755,root,root) %{openssldir}/misc/* 124%attr(0755,root,root) %{openssldir}/misc/*
132%attr(0644,root,root) /usr/man/man[157]/* 125%attr(0644,root,root) /usr/man/man[157]/*
133 126
@@ -138,14 +131,15 @@ rm -rf $RPM_BUILD_ROOT
138%dir %attr(0750,root,root) %{openssldir}/private 131%dir %attr(0750,root,root) %{openssldir}/private
139 132
140%files devel 133%files devel
134%defattr(0644,root,root,0755)
141%doc CHANGES CHANGES.SSLeay LICENSE NEWS README 135%doc CHANGES CHANGES.SSLeay LICENSE NEWS README
142 136
143%defattr(0644,root,root,0755)
144%attr(0644,root,root) /usr/lib/*.a 137%attr(0644,root,root) /usr/lib/*.a
145%attr(0644,root,root) /usr/include/openssl/* 138%attr(0644,root,root) /usr/include/openssl/*
146%attr(0644,root,root) /usr/man/man[3]/* 139%attr(0644,root,root) /usr/man/man[3]/*
147 140
148%files doc 141%files doc
142%defattr(0644,root,root,0755)
149%doc CHANGES CHANGES.SSLeay LICENSE NEWS README 143%doc CHANGES CHANGES.SSLeay LICENSE NEWS README
150%doc doc 144%doc doc
151 145
@@ -158,7 +152,8 @@ ldconfig
158%changelog 152%changelog
159* Thu Mar 22 2001 Richard Levitte <richard@levitte.org> 153* Thu Mar 22 2001 Richard Levitte <richard@levitte.org>
160- Removed redundant subsection that re-installed libcrypto.a and libssl.a 154- Removed redundant subsection that re-installed libcrypto.a and libssl.a
161 as well. 155 as well. Also remove RSAref stuff completely, since it's not needed
156 any more.
162* Thu Mar 15 2001 Jeremiah Johnson <jjohnson@penguincomputing.com> 157* Thu Mar 15 2001 Jeremiah Johnson <jjohnson@penguincomputing.com>
163- Removed redundant subsection that re-installed libcrypto.so.0.9.6 and 158- Removed redundant subsection that re-installed libcrypto.so.0.9.6 and
164 libssl.so.0.9.6. As well as the subsection that created symlinks for 159 libssl.so.0.9.6. As well as the subsection that created symlinks for
diff --git a/src/lib/libssl/src/os2/OS2-EMX.cmd b/src/lib/libssl/src/os2/OS2-EMX.cmd
new file mode 100644
index 0000000000..8b2a092c68
--- /dev/null
+++ b/src/lib/libssl/src/os2/OS2-EMX.cmd
@@ -0,0 +1,61 @@
1@echo off
2
3perl Configure OS2-EMX
4perl util\mkfiles.pl > MINFO
5
6@rem create make file
7perl util\mk1mf.pl OS2-EMX > OS2-EMX.mak
8
9echo Generating x86 for GNU assember
10
11echo Bignum
12cd crypto\bn\asm
13rem perl x86.pl a.out > bn-os2.asm
14perl bn-586.pl a.out > bn-os2.asm
15perl co-586.pl a.out > co-os2.asm
16cd ..\..\..
17
18echo DES
19cd crypto\des\asm
20perl des-586.pl a.out > d-os2.asm
21cd ..\..\..
22
23echo crypt(3)
24cd crypto\des\asm
25perl crypt586.pl a.out > y-os2.asm
26cd ..\..\..
27
28echo Blowfish
29cd crypto\bf\asm
30perl bf-586.pl a.out > b-os2.asm
31cd ..\..\..
32
33echo CAST5
34cd crypto\cast\asm
35perl cast-586.pl a.out > c-os2.asm
36cd ..\..\..
37
38echo RC4
39cd crypto\rc4\asm
40perl rc4-586.pl a.out > r4-os2.asm
41cd ..\..\..
42
43echo MD5
44cd crypto\md5\asm
45perl md5-586.pl a.out > m5-os2.asm
46cd ..\..\..
47
48echo SHA1
49cd crypto\sha\asm
50perl sha1-586.pl a.out > s1-os2.asm
51cd ..\..\..
52
53echo RIPEMD160
54cd crypto\ripemd\asm
55perl rmd-586.pl a.out > rm-os2.asm
56cd ..\..\..
57
58echo RC5\32
59cd crypto\rc5\asm
60perl rc5-586.pl a.out > r5-os2.asm
61cd ..\..\..
diff --git a/src/lib/libssl/src/perl/OpenSSL.xs b/src/lib/libssl/src/perl/OpenSSL.xs
index 2267168b79..6ef66ccc1e 100644
--- a/src/lib/libssl/src/perl/OpenSSL.xs
+++ b/src/lib/libssl/src/perl/OpenSSL.xs
@@ -72,11 +72,38 @@ BOOT:
72 boot_digest(); 72 boot_digest();
73 boot_err(); 73 boot_err();
74 boot_ssl(); 74 boot_ssl();
75 boot_OpenSSL__BN(); 75
76 boot_OpenSSL__BIO(); 76 /* */
77 boot_OpenSSL__Cipher(); 77 /* The next macro is the completely correct way to call a C */
78 boot_OpenSSL__MD(); 78 /* function that uses perl calling conventions but is not */
79 boot_OpenSSL__ERR(); 79 /* registered with perl. */
80 boot_OpenSSL__SSL(); 80 /* */
81 boot_OpenSSL__X509(); 81 /* The second macro seems to work for this context. (We just */
82 /* need a mark for the called function since we don't have */
83 /* any local variables and what-not.) */
84 /* */
85 /* Unfortunately, we need to do this because these boot_* */
86 /* functions are auto-generated by xsubpp and are normally */
87 /* called from DyncLoader, but we're pulling them in here. */
88 /* */
89#define FULL_callBootFunc(func) { \
90 dSP; \
91 ENTER; \
92 SAVETMPS; \
93 PUSHMARK(SP); \
94 func(); \
95 FREETMPS; \
96 LEAVE; \
97 }
98#define callBootFunc(func) { \
99 PUSHMARK(SP); \
100 func(); \
101 }
102 callBootFunc(boot_OpenSSL__BN);
103 callBootFunc(boot_OpenSSL__BIO);
104 callBootFunc(boot_OpenSSL__Cipher);
105 callBootFunc(boot_OpenSSL__MD);
106 callBootFunc(boot_OpenSSL__ERR);
107 callBootFunc(boot_OpenSSL__SSL);
108 callBootFunc(boot_OpenSSL__X509);
82 109
diff --git a/src/lib/libssl/src/perl/openssl_bio.xs b/src/lib/libssl/src/perl/openssl_bio.xs
index 06d61af130..5628300d0b 100644
--- a/src/lib/libssl/src/perl/openssl_bio.xs
+++ b/src/lib/libssl/src/perl/openssl_bio.xs
@@ -32,7 +32,7 @@ p5_bio_callback(bio,state,parg,cmd,larg,ret)
32 if ((state == BIO_CB_READ) || (state == BIO_CB_WRITE)) 32 if ((state == BIO_CB_READ) || (state == BIO_CB_WRITE))
33 XPUSHs(sv_2mortal(newSVpv(parg,larg))); 33 XPUSHs(sv_2mortal(newSVpv(parg,larg)));
34 else 34 else
35 XPUSHs(&sv_undef); 35 XPUSHs(&PL_sv_undef);
36 /* ptr one */ 36 /* ptr one */
37 XPUSHs(sv_2mortal(newSViv(larg))); 37 XPUSHs(sv_2mortal(newSViv(larg)));
38 XPUSHs(sv_2mortal(newSViv(ret))); 38 XPUSHs(sv_2mortal(newSViv(ret)));
@@ -129,9 +129,9 @@ p5_BIO_new(...)
129 PPCODE: 129 PPCODE:
130 pr_name("p5_BIO_new"); 130 pr_name("p5_BIO_new");
131 if ((items == 1) && SvPOK(ST(0))) 131 if ((items == 1) && SvPOK(ST(0)))
132 type = SvPV(ST(0),na); 132 type = SvPV_nolen(ST(0));
133 else if ((items == 2) && SvPOK(ST(1))) 133 else if ((items == 2) && SvPOK(ST(1)))
134 type = SvPV(ST(1),na); 134 type = SvPV_nolen(ST(1));
135 else 135 else
136 croak("Usage: OpenSSL::BIO::new(type)"); 136 croak("Usage: OpenSSL::BIO::new(type)");
137 EXTEND(sp,1); 137 EXTEND(sp,1);
@@ -314,7 +314,7 @@ p5_BIO_getline(bio)
314 PUSHs(sv_newmortal()); 314 PUSHs(sv_newmortal());
315 sv_setpvn(ST(0), "", 0); 315 sv_setpvn(ST(0), "", 0);
316 SvGROW(ST(0), 1024); 316 SvGROW(ST(0), 1024);
317 p=SvPV(ST(0), na); 317 p=SvPV_nolen(ST(0));
318 i = BIO_gets(bio, p, 1024); 318 i = BIO_gets(bio, p, 1024);
319 if (i < 0) 319 if (i < 0)
320 i = 0; 320 i = 0;
@@ -370,7 +370,7 @@ p5_BIO_puts(bio, in)
370 PREINIT: 370 PREINIT:
371 char *ptr; 371 char *ptr;
372 CODE: 372 CODE:
373 ptr = SvPV(in,na); 373 ptr = SvPV_nolen(in);
374 RETVAL = BIO_puts(bio, ptr); 374 RETVAL = BIO_puts(bio, ptr);
375 OUTPUT: 375 OUTPUT:
376 RETVAL 376 RETVAL
diff --git a/src/lib/libssl/src/perl/openssl_bn.xs b/src/lib/libssl/src/perl/openssl_bn.xs
index f79bf879e8..6817cfb740 100644
--- a/src/lib/libssl/src/perl/openssl_bn.xs
+++ b/src/lib/libssl/src/perl/openssl_bn.xs
@@ -142,7 +142,7 @@ p5_BN_bn2bin(a)
142 i=BN_num_bytes(a)+2; 142 i=BN_num_bytes(a)+2;
143 sv_setpvn(ST(0),"",1); 143 sv_setpvn(ST(0),"",1);
144 SvGROW(ST(0),i+1); 144 SvGROW(ST(0),i+1);
145 SvCUR_set(ST(0),BN_bn2bin(a,SvPV(ST(0),na))); 145 SvCUR_set(ST(0),BN_bn2bin(a,SvPV_nolen(ST(0))));
146 146
147void 147void
148p5_BN_mpi2bn(a) 148p5_BN_mpi2bn(a)
@@ -168,7 +168,7 @@ p5_BN_bn2mpi(a)
168 i=BN_bn2mpi(a,NULL); 168 i=BN_bn2mpi(a,NULL);
169 sv_setpvn(ST(0),"",1); 169 sv_setpvn(ST(0),"",1);
170 SvGROW(ST(0),i+1); 170 SvGROW(ST(0),i+1);
171 SvCUR_set(ST(0),BN_bn2mpi(a,SvPV(ST(0),na))); 171 SvCUR_set(ST(0),BN_bn2mpi(a,SvPV_nolen(ST(0))));
172 172
173void 173void
174p5_BN_hex2bn(a) 174p5_BN_hex2bn(a)
@@ -208,9 +208,9 @@ p5_BN_bn2hex(a)
208 RETVAL=newSVpv("",0); 208 RETVAL=newSVpv("",0);
209 i=strlen(ptr); 209 i=strlen(ptr);
210 SvGROW(RETVAL,i+1); 210 SvGROW(RETVAL,i+1);
211 memcpy(SvPV(RETVAL,na),ptr,i+1); 211 memcpy(SvPV_nolen(RETVAL),ptr,i+1);
212 SvCUR_set(RETVAL,i); 212 SvCUR_set(RETVAL,i);
213 Free(ptr); 213 OPENSSL_free(ptr);
214 OUTPUT: 214 OUTPUT:
215 RETVAL 215 RETVAL
216 216
@@ -226,9 +226,9 @@ p5_BN_bn2dec(a)
226 RETVAL=newSVpv("",0); 226 RETVAL=newSVpv("",0);
227 i=strlen(ptr); 227 i=strlen(ptr);
228 SvGROW(RETVAL,i+1); 228 SvGROW(RETVAL,i+1);
229 memcpy(SvPV(RETVAL,na),ptr,i+1); 229 memcpy(SvPV_nolen(RETVAL),ptr,i+1);
230 SvCUR_set(RETVAL,i); 230 SvCUR_set(RETVAL,i);
231 Free(ptr); 231 OPENSSL_free(ptr);
232 OUTPUT: 232 OUTPUT:
233 RETVAL 233 RETVAL
234 234
diff --git a/src/lib/libssl/src/perl/openssl_cipher.xs b/src/lib/libssl/src/perl/openssl_cipher.xs
index e9ff2a8f79..580620ffbc 100644
--- a/src/lib/libssl/src/perl/openssl_cipher.xs
+++ b/src/lib/libssl/src/perl/openssl_cipher.xs
@@ -20,9 +20,9 @@ p5_EVP_C_new(...)
20 char *name; 20 char *name;
21 PPCODE: 21 PPCODE:
22 if ((items == 1) && SvPOK(ST(0))) 22 if ((items == 1) && SvPOK(ST(0)))
23 name=SvPV(ST(0),na); 23 name=SvPV_nolen(ST(0));
24 else if ((items == 2) && SvPOK(ST(1))) 24 else if ((items == 2) && SvPOK(ST(1)))
25 name=SvPV(ST(1),na); 25 name=SvPV_nolen(ST(1));
26 else 26 else
27 croak("Usage: OpenSSL::Cipher::new(type)"); 27 croak("Usage: OpenSSL::Cipher::new(type)");
28 PUSHs(sv_newmortal()); 28 PUSHs(sv_newmortal());
@@ -112,7 +112,7 @@ p5_EVP_C_cipher(ctx,in)
112 CODE: 112 CODE:
113 RETVAL=newSVpv("",0); 113 RETVAL=newSVpv("",0);
114 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); 114 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1);
115 EVP_Cipher(ctx,SvPV(RETVAL,na),in.dptr,in.dsize); 115 EVP_Cipher(ctx,SvPV_nolen(RETVAL),in.dptr,in.dsize);
116 SvCUR_set(RETVAL,in.dsize); 116 SvCUR_set(RETVAL,in.dsize);
117 OUTPUT: 117 OUTPUT:
118 RETVAL 118 RETVAL
@@ -126,7 +126,7 @@ p5_EVP_C_update(ctx, in)
126 CODE: 126 CODE:
127 RETVAL=newSVpv("",0); 127 RETVAL=newSVpv("",0);
128 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1); 128 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1);
129 EVP_CipherUpdate(ctx,SvPV(RETVAL,na),&i,in.dptr,in.dsize); 129 EVP_CipherUpdate(ctx,SvPV_nolen(RETVAL),&i,in.dptr,in.dsize);
130 SvCUR_set(RETVAL,i); 130 SvCUR_set(RETVAL,i);
131 OUTPUT: 131 OUTPUT:
132 RETVAL 132 RETVAL
@@ -139,7 +139,7 @@ p5_EVP_C_final(ctx)
139 CODE: 139 CODE:
140 RETVAL=newSVpv("",0); 140 RETVAL=newSVpv("",0);
141 SvGROW(RETVAL,EVP_CIPHER_CTX_block_size(ctx)+1); 141 SvGROW(RETVAL,EVP_CIPHER_CTX_block_size(ctx)+1);
142 if (!EVP_CipherFinal(ctx,SvPV(RETVAL,na),&i)) 142 if (!EVP_CipherFinal(ctx,SvPV_nolen(RETVAL),&i))
143 sv_setpv(RETVAL,"BAD DECODE"); 143 sv_setpv(RETVAL,"BAD DECODE");
144 else 144 else
145 SvCUR_set(RETVAL,i); 145 SvCUR_set(RETVAL,i);
diff --git a/src/lib/libssl/src/perl/openssl_digest.xs b/src/lib/libssl/src/perl/openssl_digest.xs
index 6cd3018e9f..4f2f8938cf 100644
--- a/src/lib/libssl/src/perl/openssl_digest.xs
+++ b/src/lib/libssl/src/perl/openssl_digest.xs
@@ -27,9 +27,9 @@ p5_EVP_MD_new(...)
27 char *name; 27 char *name;
28 PPCODE: 28 PPCODE:
29 if ((items == 1) && SvPOK(ST(0))) 29 if ((items == 1) && SvPOK(ST(0)))
30 name=SvPV(ST(0),na); 30 name=SvPV_nolen(ST(0));
31 else if ((items == 2) && SvPOK(ST(1))) 31 else if ((items == 2) && SvPOK(ST(1)))
32 name=SvPV(ST(1),na); 32 name=SvPV_nolen(ST(1));
33 else 33 else
34 croak("Usage: OpenSSL::MD::new(type)"); 34 croak("Usage: OpenSSL::MD::new(type)");
35 PUSHs(sv_newmortal()); 35 PUSHs(sv_newmortal());
@@ -45,8 +45,9 @@ datum
45p5_EVP_MD_name(ctx) 45p5_EVP_MD_name(ctx)
46 EVP_MD_CTX *ctx 46 EVP_MD_CTX *ctx
47 CODE: 47 CODE:
48 RETVAL.dptr=OBJ_nid2ln(EVP_MD_type(EVP_MD_CTX_type(ctx))); 48 RETVAL.dptr=OBJ_nid2ln(EVP_MD_CTX_type(ctx));
49 RETVAL.dsize=strlen(RETVAL.dptr); 49 RETVAL.dsize=strlen(RETVAL.dptr);
50
50 OUTPUT: 51 OUTPUT:
51 RETVAL 52 RETVAL
52 53
diff --git a/src/lib/libssl/src/perl/openssl_ssl.xs b/src/lib/libssl/src/perl/openssl_ssl.xs
index c7d1b171ab..146c1ace8e 100644
--- a/src/lib/libssl/src/perl/openssl_ssl.xs
+++ b/src/lib/libssl/src/perl/openssl_ssl.xs
@@ -72,9 +72,9 @@ p5_SSL_CTX_new(...)
72 PPCODE: 72 PPCODE:
73 pr_name("p5_SSL_CTX_new"); 73 pr_name("p5_SSL_CTX_new");
74 if ((items == 1) && SvPOK(ST(0))) 74 if ((items == 1) && SvPOK(ST(0)))
75 method=SvPV(ST(0),na); 75 method=SvPV_nolen(ST(0));
76 else if ((items == 2) && SvPOK(ST(1))) 76 else if ((items == 2) && SvPOK(ST(1)))
77 method=SvPV(ST(1),na); 77 method=SvPV_nolen(ST(1));
78 else 78 else
79 croak("Usage: OpenSSL::SSL::CTX::new(type)"); 79 croak("Usage: OpenSSL::SSL::CTX::new(type)");
80 80
@@ -124,7 +124,7 @@ p5_SSL_CTX_use_PrivateKey_file(ctx,file,...)
124 croak("OpenSSL::SSL::CTX::use_PrivateKey_file(ssl_ctx,file[,type])"); 124 croak("OpenSSL::SSL::CTX::use_PrivateKey_file(ssl_ctx,file[,type])");
125 if (items == 3) 125 if (items == 3)
126 { 126 {
127 ptr=SvPV(ST(2),na); 127 ptr=SvPV_nolen(ST(2));
128 if (strcmp(ptr,"der") == 0) 128 if (strcmp(ptr,"der") == 0)
129 i=SSL_FILETYPE_ASN1; 129 i=SSL_FILETYPE_ASN1;
130 else 130 else
@@ -148,7 +148,7 @@ p5_SSL_CTX_set_options(ctx,...)
148 { 148 {
149 if (!SvPOK(ST(i))) 149 if (!SvPOK(ST(i)))
150 croak("Usage: OpenSSL::SSL_CTX::set_options(ssl_ctx[,option,value]+)"); 150 croak("Usage: OpenSSL::SSL_CTX::set_options(ssl_ctx[,option,value]+)");
151 ptr=SvPV(ST(i),na); 151 ptr=SvPV_nolen(ST(i));
152 if (strcmp(ptr,"-info_callback") == 0) 152 if (strcmp(ptr,"-info_callback") == 0)
153 { 153 {
154 SSL_CTX_set_info_callback(ctx, 154 SSL_CTX_set_info_callback(ctx,
@@ -325,7 +325,7 @@ p5_SSL_set_options(ssl,...)
325 { 325 {
326 if (!SvPOK(ST(i))) 326 if (!SvPOK(ST(i)))
327 croak("Usage: OpenSSL::SSL::set_options(ssl[,option,value]+)"); 327 croak("Usage: OpenSSL::SSL::set_options(ssl[,option,value]+)");
328 ptr=SvPV(ST(i),na); 328 ptr=SvPV_nolen(ST(i));
329 if (strcmp(ptr,"-info_callback") == 0) 329 if (strcmp(ptr,"-info_callback") == 0)
330 { 330 {
331 SSL_set_info_callback(ssl, 331 SSL_set_info_callback(ssl,
@@ -477,7 +477,7 @@ p5_BIO_get_ssl(bio)
477 ret=sv_mortalcopy(ret); 477 ret=sv_mortalcopy(ret);
478 } 478 }
479 else 479 else
480 ret= &sv_undef; 480 ret= &PL_sv_undef;
481 EXTEND(sp,1); 481 EXTEND(sp,1);
482 PUSHs(ret); 482 PUSHs(ret);
483 483
diff --git a/src/lib/libssl/src/shlib/Makefile.hpux10-cc b/src/lib/libssl/src/shlib/Makefile.hpux10-cc
index 4dc62ebd9e..4d2d19bcf2 100644
--- a/src/lib/libssl/src/shlib/Makefile.hpux10-cc
+++ b/src/lib/libssl/src/shlib/Makefile.hpux10-cc
@@ -1,12 +1,12 @@
1# Makefile.hpux-cc 1# Makefile.hpux-cc
2 2
3major=1 3major=0.9.7
4 4
5slib=libssl 5slib=libssl
6sh_slib=$(slib).so.$(major) 6sh_slib=$(slib).sl.$(major)
7 7
8clib=libcrypto 8clib=libcrypto
9sh_clib=$(clib).so.$(major) 9sh_clib=$(clib).sl.$(major)
10 10
11all : $(clib).sl $(slib).sl 11all : $(clib).sl $(slib).sl
12 12
@@ -20,31 +20,14 @@ $(slib)_pic.a : $(slib).a
20 cp -p $? $@ 20 cp -p $? $@
21 21
22$(sh_clib) : $(clib)_pic.a 22$(sh_clib) : $(clib)_pic.a
23 echo "collecting all object files for $@" 23 ld -b -s -z +h $@ -o $@ -Fl $(clib)_pic.a -ldld -lc
24 find . -name \*.o -print > allobjs
25 for obj in `ar t $(clib)_pic.a`; \
26 do \
27 grep /$$obj allobjs; \
28 done >objlist
29 echo "linking $@"
30 ld -b -s -z +h $@ -o $@ `cat objlist` -lc
31 rm allobjs objlist
32 24
33$(clib).sl : $(sh_clib) 25$(clib).sl : $(sh_clib)
34 rm -f $@ 26 rm -f $@
35 ln -s $? $@ 27 ln -s $? $@
36 28
37$(sh_slib) : $(slib)_pic.a $(clib).sl 29$(sh_slib) : $(slib)_pic.a $(clib).sl
38 echo "collecting all object files for $@" 30 ld -b -s -z +h $@ -o $@ -Fl $(slib)_pic.a -ldld -lc
39 find . -name \*.o -print > allobjs
40 for obj in `ar t $(slib)_pic.a`; \
41 do \
42 grep /$$obj allobjs; \
43 done >objlist
44 echo "linking $@"
45 ld -b -s -z +h $@ +b /usr/local/ssl/lib:/usr/lib -o $@ `cat objlist` \
46 -L. -lcrypto -lc
47 rm -f allobjs objlist
48 31
49$(slib).sl : $(sh_slib) 32$(slib).sl : $(sh_slib)
50 rm -f $@ 33 rm -f $@
diff --git a/src/lib/libssl/src/shlib/hpux10-cc.sh b/src/lib/libssl/src/shlib/hpux10-cc.sh
index 903baaa4e7..81eb9d4cab 100644
--- a/src/lib/libssl/src/shlib/hpux10-cc.sh
+++ b/src/lib/libssl/src/shlib/hpux10-cc.sh
@@ -20,7 +20,9 @@
20# WARNING: At high optimization levels, HP's ANSI-C compiler can chew up 20# WARNING: At high optimization levels, HP's ANSI-C compiler can chew up
21# large amounts of memory and CPU time. Make sure to have at least 21# large amounts of memory and CPU time. Make sure to have at least
22# 128MB of RAM available and that your kernel is configured to allow 22# 128MB of RAM available and that your kernel is configured to allow
23# at least 128MB data size (maxdsiz parameter). 23# at least 128MB data size (maxdsiz parameter which can be obtained
24# by multiplying 'echo maxdsiz/D | adb -k /stand/vmunix /dev/kmem'
25# by 'getconf PAGE_SIZE').
24# The installation process can take several hours, even on fast 26# The installation process can take several hours, even on fast
25# machines. +O4 optimization of the libcrypto.sl shared library may 27# machines. +O4 optimization of the libcrypto.sl shared library may
26# take 1 hour on a C200 (200MHz PA8200 CPU), +O3 compilation of 28# take 1 hour on a C200 (200MHz PA8200 CPU), +O3 compilation of
@@ -40,7 +42,7 @@ SITEFLAGS="+DAportable +w1"
40MYFLAGS="-D_REENTRANT +Oall $SITEFLAGS" 42MYFLAGS="-D_REENTRANT +Oall $SITEFLAGS"
41 43
42# Configure for pic and build the static pic libraries 44# Configure for pic and build the static pic libraries
43perl5 Configure hpux-parisc-cc-o4 +z ${MYFLAGS} 45perl5 Configure no-shared hpux-parisc-cc-o4 +Z ${MYFLAGS}
44make clean 46make clean
45make DIRS="crypto ssl" 47make DIRS="crypto ssl"
46# Rename the static pic libs and build dynamic libraries from them 48# Rename the static pic libs and build dynamic libraries from them
@@ -58,21 +60,21 @@ mkdir /usr/local
58mkdir /usr/local/ssl 60mkdir /usr/local/ssl
59mkdir /usr/local/ssl/lib 61mkdir /usr/local/ssl/lib
60chmod 444 lib*_pic.a 62chmod 444 lib*_pic.a
61chmod 555 lib*.so.1 63chmod 555 lib*.sl.0.9.7
62cp -p lib*_pic.a lib*.so.1 /usr/local/ssl/lib 64cp -p lib*_pic.a lib*.sl.0.9.7 /usr/local/ssl/lib
63(cd /usr/local/ssl/lib ; ln -sf libcrypto.so.1 libcrypto.sl ; ln -sf libssl.so.1 libssl.sl) 65(cd /usr/local/ssl/lib ; ln -sf libcrypto.sl.0.9.7 libcrypto.sl ; ln -sf libssl.sl.0.9.7 libssl.sl)
64 66
65# Reconfigure without pic to compile the executables. Unfortunately, while 67# Reconfigure without pic to compile the executables. Unfortunately, while
66# performing this task we have to recompile the library components, even 68# performing this task we have to recompile the library components, even
67# though we use the already installed shared libs anyway. 69# though we use the already installed shared libs anyway.
68# 70#
69perl5 Configure hpux-parisc-cc-o4 ${MYFLAGS} 71perl5 Configure no-shared hpux-parisc-cc-o4 ${MYFLAGS}
70 72
71make clean 73make clean
72 74
73# Hack the Makefiles to pick up the dynamic libraries during linking 75# Hack the Makefiles to pick up the dynamic libraries during linking
74# 76#
75sed 's/^PEX_LIBS=.*$/PEX_LIBS=-L\/usr\/local\/ssl\/lib -Wl,+b,\/usr\/local\/ssl\/lib:\/usr\/lib/' Makefile.ssl >xxx; mv xxx Makefile.ssl 77sed 's/^PEX_LIBS=.*$/PEX_LIBS=-L\/usr\/local\/ssl\/lib/' Makefile.ssl >xxx; mv xxx Makefile.ssl
76sed 's/-L\.\.//' apps/Makefile.ssl >xxx; mv xxx apps/Makefile.ssl 78sed 's/-L\.\.//' apps/Makefile.ssl >xxx; mv xxx apps/Makefile.ssl
77sed 's/-L\.\.//' test/Makefile.ssl >xxx; mv xxx test/Makefile.ssl 79sed 's/-L\.\.//' test/Makefile.ssl >xxx; mv xxx test/Makefile.ssl
78# Build the static libs and the executables in one make. 80# Build the static libs and the executables in one make.
@@ -83,7 +85,7 @@ make install
83# Finally build the static libs with +O3. This time we only need the libraries, 85# Finally build the static libs with +O3. This time we only need the libraries,
84# once created, they are simply copied into place. 86# once created, they are simply copied into place.
85# 87#
86perl5 Configure hpux-parisc-cc ${MYFLAGS} 88perl5 Configure no-shared hpux-parisc-cc ${MYFLAGS}
87make clean 89make clean
88make DIRS="crypto ssl" 90make DIRS="crypto ssl"
89chmod 644 libcrypto.a libssl.a 91chmod 644 libcrypto.a libssl.a
diff --git a/src/lib/libssl/src/shlib/svr5-shared-gcc.sh b/src/lib/libssl/src/shlib/svr5-shared-gcc.sh
new file mode 100644
index 0000000000..b36a0375a6
--- /dev/null
+++ b/src/lib/libssl/src/shlib/svr5-shared-gcc.sh
@@ -0,0 +1,48 @@
1#!/usr/bin/sh
2
3major="0"
4minor="9.7"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12FLAGS="-O3 -DFILIO_H -fomit-frame-pointer -pthread
13SHFLAGS="-DPIC -fPIC"
14
15touch $sh_clib
16touch $sh_slib
17
18echo collecting all object files for $clib.so
19OBJS=
20find . -name \*.o -print > allobjs
21for obj in `ar t libcrypto.a`
22do
23 OBJS="$OBJS `grep $obj allobjs`"
24done
25
26echo linking $clib.so
27gcc -G -o $sh_clib -h $sh_clib $OBJS -lnsl -lsocket
28
29rm -f $clib.so
30ln -s $sh_clib $clib.so
31
32echo collecting all object files for $slib.so
33OBJS=
34for obj in `ar t libssl.a`
35do
36 OBJS="$OBJS `grep $obj allobjs`"
37done
38
39echo linking $slib.so
40gcc -G -o $sh_slib -h $sh_slib $OBJS -L. -lcrypto
41
42rm -f $slib.so
43ln -s $sh_slib $slib.so
44
45mv libRSAglue.a libRSAglue.a.orig
46mv libcrypto.a libcrypto.a.orig
47mv libssl.a libssl.a.orig
48
diff --git a/src/lib/libssl/src/shlib/svr5-shared-installed b/src/lib/libssl/src/shlib/svr5-shared-installed
new file mode 100644
index 0000000000..544f5a9417
--- /dev/null
+++ b/src/lib/libssl/src/shlib/svr5-shared-installed
@@ -0,0 +1,28 @@
1#!/usr/bin/sh
2
3major="0"
4minor="9.7"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12# If you want them in /usr/local/lib then change INSTALLTOP to point there.
13#INSTALLTOP=/usr/local/ssl/lib
14INSTALLTOP=/usr/local/lib
15
16cp -p $sh_clib $INSTALLTOP
17cp -p $sh_slib $INSTALLTOP
18
19PWD=`pwd`
20cd $INSTALLTOP
21rm -f $INSTALLTOP/$clib.so
22ln -s $INSTALLTOP/$sh_clib $clib.so
23
24rm -f $INSTALLTOP/$slib.so
25ln -s $INSTALLTOP/$sh_slib $slib.so
26
27cd $PWD
28
diff --git a/src/lib/libssl/src/shlib/svr5-shared.sh b/src/lib/libssl/src/shlib/svr5-shared.sh
new file mode 100644
index 0000000000..a70bb65baa
--- /dev/null
+++ b/src/lib/libssl/src/shlib/svr5-shared.sh
@@ -0,0 +1,48 @@
1#!/usr/bin/sh
2
3major="0"
4minor="9.7"
5
6slib=libssl
7sh_slib=$slib.so.$major.$minor
8
9clib=libcrypto
10sh_clib=$clib.so.$major.$minor
11
12FLAGS="-O -DFILIO_H -Kalloca -Kthread"
13SHFLAGS="-Kpic -DPIC"
14
15touch $sh_clib
16touch $sh_slib
17
18echo collecting all object files for $clib.so
19OBJS=
20find . -name \*.o -print > allobjs
21for obj in `ar t libcrypto.a`
22do
23 OBJS="$OBJS `grep $obj allobjs`"
24done
25
26echo linking $clib.so
27cc -G -o $sh_clib -h $sh_clib $OBJS -lnsl -lsocket
28
29rm -f $clib.so
30ln -s $sh_clib $clib.so
31
32echo collecting all object files for $slib.so
33OBJS=
34for obj in `ar t libssl.a`
35do
36 OBJS="$OBJS `grep $obj allobjs`"
37done
38
39echo linking $slib.so
40cc -G -o $sh_slib -h $sh_slib $OBJS -L. -lcrypto
41
42rm -f $slib.so
43ln -s $sh_slib $slib.so
44
45mv libRSAglue.a libRSAglue.a.orig
46mv libcrypto.a libcrypto.a.orig
47mv libssl.a libssl.a.orig
48
diff --git a/src/lib/libssl/src/ssl/Makefile.ssl b/src/lib/libssl/src/ssl/Makefile.ssl
index cfb627d29a..dd133cc86b 100644
--- a/src/lib/libssl/src/ssl/Makefile.ssl
+++ b/src/lib/libssl/src/ssl/Makefile.ssl
@@ -5,15 +5,19 @@
5DIR= ssl 5DIR= ssl
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDES= -I../crypto -I../include 8INCLUDES= -I../crypto -I$(TOP) -I../include $(KRB5_INCLUDES)
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
18# KRB5 stuff
19KRB5_INCLUDES=
20LIBKRB5=
17 21
18CFLAGS= $(INCLUDES) $(CFLAG) 22CFLAGS= $(INCLUDES) $(CFLAG)
19 23
@@ -22,6 +26,7 @@ TEST=ssltest.c
22APPS= 26APPS=
23 27
24LIB=$(TOP)/libssl.a 28LIB=$(TOP)/libssl.a
29SHARED_LIB= libssl$(SHLIB_EXT)
25LIBSRC= \ 30LIBSRC= \
26 s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \ 31 s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
27 s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \ 32 s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
@@ -30,7 +35,7 @@ LIBSRC= \
30 ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \ 35 ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
31 ssl_ciph.c ssl_stat.c ssl_rsa.c \ 36 ssl_ciph.c ssl_stat.c ssl_rsa.c \
32 ssl_asn1.c ssl_txt.c ssl_algs.c \ 37 ssl_asn1.c ssl_txt.c ssl_algs.c \
33 bio_ssl.c ssl_err.c 38 bio_ssl.c ssl_err.c kssl.c
34LIBOBJ= \ 39LIBOBJ= \
35 s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \ 40 s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
36 s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \ 41 s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
@@ -39,26 +44,30 @@ LIBOBJ= \
39 ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \ 44 ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
40 ssl_ciph.o ssl_stat.o ssl_rsa.o \ 45 ssl_ciph.o ssl_stat.o ssl_rsa.o \
41 ssl_asn1.o ssl_txt.o ssl_algs.o \ 46 ssl_asn1.o ssl_txt.o ssl_algs.o \
42 bio_ssl.o ssl_err.o 47 bio_ssl.o ssl_err.o kssl.o
43 48
44SRC= $(LIBSRC) 49SRC= $(LIBSRC)
45 50
46EXHEADER= ssl.h ssl2.h ssl3.h ssl23.h tls1.h 51EXHEADER= ssl.h ssl2.h ssl3.h ssl23.h tls1.h kssl.h
47HEADER= $(EXHEADER) ssl_locl.h 52HEADER= $(EXHEADER) ssl_locl.h kssl_lcl.h
48 53
49ALL= $(GENERAL) $(SRC) $(HEADER) 54ALL= $(GENERAL) $(SRC) $(HEADER)
50 55
51top: 56top:
52 (cd ..; $(MAKE) DIRS=$(DIR) all) 57 (cd ..; $(MAKE) DIRS=$(DIR) all)
53 58
54all: lib 59all: lib shared
55 60
56lib: $(LIBOBJ) 61lib: $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ) 62 $(AR) $(LIB) $(LIBOBJ)
58 @echo You may get an error following this line. Please ignore. 63 $(RANLIB) $(LIB) || echo Never mind.
59 - $(RANLIB) $(LIB)
60 @touch lib 64 @touch lib
61 65
66shared:
67 if [ -n "$(SHARED_LIBS)" ]; then \
68 (cd ..; make $(SHARED_LIB)); \
69 fi
70
62files: 71files:
63 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 72 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
64 73
@@ -96,789 +105,632 @@ clean:
96# DO NOT DELETE THIS LINE -- make depend depends on it. 105# DO NOT DELETE THIS LINE -- make depend depends on it.
97 106
98bio_ssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h 107bio_ssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h
99bio_ssl.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 108bio_ssl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
100bio_ssl.o: ../include/openssl/buffer.h ../include/openssl/cast.h
101bio_ssl.o: ../include/openssl/comp.h ../include/openssl/crypto.h 109bio_ssl.o: ../include/openssl/comp.h ../include/openssl/crypto.h
102bio_ssl.o: ../include/openssl/des.h ../include/openssl/dh.h 110bio_ssl.o: ../include/openssl/dh.h ../include/openssl/dsa.h
103bio_ssl.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 111bio_ssl.o: ../include/openssl/e_os2.h ../include/openssl/err.h
104bio_ssl.o: ../include/openssl/err.h ../include/openssl/evp.h 112bio_ssl.o: ../include/openssl/evp.h ../include/openssl/kssl.h
105bio_ssl.o: ../include/openssl/idea.h ../include/openssl/lhash.h 113bio_ssl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
106bio_ssl.o: ../include/openssl/md2.h ../include/openssl/md4.h 114bio_ssl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
107bio_ssl.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 115bio_ssl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
108bio_ssl.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
109bio_ssl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
110bio_ssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h 116bio_ssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
111bio_ssl.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 117bio_ssl.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
112bio_ssl.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
113bio_ssl.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
114bio_ssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h 118bio_ssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
115bio_ssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 119bio_ssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
116bio_ssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 120bio_ssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
117bio_ssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 121bio_ssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
118bio_ssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h 122bio_ssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h
119bio_ssl.o: ../include/openssl/x509_vfy.h 123bio_ssl.o: ../include/openssl/x509_vfy.h bio_ssl.c
120s23_clnt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 124kssl.o: ../include/openssl/asn1.h ../include/openssl/bio.h
121s23_clnt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 125kssl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
122s23_clnt.o: ../include/openssl/buffer.h ../include/openssl/cast.h 126kssl.o: ../include/openssl/comp.h ../include/openssl/crypto.h
127kssl.o: ../include/openssl/dh.h ../include/openssl/dsa.h
128kssl.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
129kssl.o: ../include/openssl/krb5_asn.h ../include/openssl/kssl.h
130kssl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
131kssl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
132kssl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
133kssl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
134kssl.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
135kssl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
136kssl.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
137kssl.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
138kssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
139kssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h
140kssl.o: ../include/openssl/x509_vfy.h kssl.c
141s23_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
142s23_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
123s23_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 143s23_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
124s23_clnt.o: ../include/openssl/des.h ../include/openssl/dh.h 144s23_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
125s23_clnt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
126s23_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 145s23_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
127s23_clnt.o: ../include/openssl/evp.h ../include/openssl/idea.h 146s23_clnt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
128s23_clnt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 147s23_clnt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
129s23_clnt.o: ../include/openssl/md4.h ../include/openssl/md5.h
130s23_clnt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
131s23_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 148s23_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
132s23_clnt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 149s23_clnt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
133s23_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 150s23_clnt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
134s23_clnt.o: ../include/openssl/rand.h ../include/openssl/rc2.h 151s23_clnt.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
135s23_clnt.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 152s23_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
136s23_clnt.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 153s23_clnt.o: ../include/openssl/sha.h ../include/openssl/ssl.h
137s23_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h 154s23_clnt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
138s23_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 155s23_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
139s23_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 156s23_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
140s23_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 157s23_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s23_clnt.c
141s23_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h 158s23_clnt.o: ssl_locl.h
142s23_clnt.o: ../include/openssl/x509_vfy.h ssl_locl.h 159s23_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
143s23_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 160s23_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h
144s23_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
145s23_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h
146s23_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h 161s23_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h
147s23_lib.o: ../include/openssl/des.h ../include/openssl/dh.h 162s23_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h
148s23_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
149s23_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 163s23_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
150s23_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 164s23_lib.o: ../include/openssl/evp.h ../include/openssl/kssl.h
151s23_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 165s23_lib.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
152s23_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h
153s23_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
154s23_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 166s23_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
155s23_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 167s23_lib.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
156s23_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 168s23_lib.o: ../include/openssl/pem.h ../include/openssl/pem2.h
157s23_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 169s23_lib.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
158s23_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 170s23_lib.o: ../include/openssl/safestack.h ../include/openssl/sha.h
159s23_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 171s23_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
160s23_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 172s23_lib.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
161s23_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 173s23_lib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
162s23_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 174s23_lib.o: ../include/openssl/tls1.h ../include/openssl/x509.h
163s23_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 175s23_lib.o: ../include/openssl/x509_vfy.h s23_lib.c ssl_locl.h
164s23_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 176s23_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
165s23_meth.o: ../include/openssl/asn1.h ../include/openssl/bio.h 177s23_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h
166s23_meth.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
167s23_meth.o: ../include/openssl/buffer.h ../include/openssl/cast.h
168s23_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h 178s23_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h
169s23_meth.o: ../include/openssl/des.h ../include/openssl/dh.h 179s23_meth.o: ../include/openssl/dh.h ../include/openssl/dsa.h
170s23_meth.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
171s23_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h 180s23_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h
172s23_meth.o: ../include/openssl/evp.h ../include/openssl/idea.h 181s23_meth.o: ../include/openssl/evp.h ../include/openssl/kssl.h
173s23_meth.o: ../include/openssl/lhash.h ../include/openssl/md2.h 182s23_meth.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
174s23_meth.o: ../include/openssl/md4.h ../include/openssl/md5.h
175s23_meth.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
176s23_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 183s23_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
177s23_meth.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 184s23_meth.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
178s23_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 185s23_meth.o: ../include/openssl/pem.h ../include/openssl/pem2.h
179s23_meth.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 186s23_meth.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
180s23_meth.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 187s23_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h
181s23_meth.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 188s23_meth.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
182s23_meth.o: ../include/openssl/sha.h ../include/openssl/ssl.h 189s23_meth.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
183s23_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 190s23_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
184s23_meth.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 191s23_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h
185s23_meth.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 192s23_meth.o: ../include/openssl/x509_vfy.h s23_meth.c ssl_locl.h
186s23_meth.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 193s23_pkt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
187s23_pkt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 194s23_pkt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
188s23_pkt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
189s23_pkt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
190s23_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 195s23_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
191s23_pkt.o: ../include/openssl/des.h ../include/openssl/dh.h 196s23_pkt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
192s23_pkt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
193s23_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 197s23_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
194s23_pkt.o: ../include/openssl/evp.h ../include/openssl/idea.h 198s23_pkt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
195s23_pkt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 199s23_pkt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
196s23_pkt.o: ../include/openssl/md4.h ../include/openssl/md5.h
197s23_pkt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
198s23_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 200s23_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
199s23_pkt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 201s23_pkt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
200s23_pkt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 202s23_pkt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
201s23_pkt.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 203s23_pkt.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
202s23_pkt.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 204s23_pkt.o: ../include/openssl/safestack.h ../include/openssl/sha.h
203s23_pkt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 205s23_pkt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
204s23_pkt.o: ../include/openssl/sha.h ../include/openssl/ssl.h 206s23_pkt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
205s23_pkt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 207s23_pkt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
206s23_pkt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 208s23_pkt.o: ../include/openssl/tls1.h ../include/openssl/x509.h
207s23_pkt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 209s23_pkt.o: ../include/openssl/x509_vfy.h s23_pkt.c ssl_locl.h
208s23_pkt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 210s23_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
209s23_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 211s23_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h
210s23_srvr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
211s23_srvr.o: ../include/openssl/buffer.h ../include/openssl/cast.h
212s23_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h 212s23_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h
213s23_srvr.o: ../include/openssl/des.h ../include/openssl/dh.h 213s23_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h
214s23_srvr.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
215s23_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h 214s23_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h
216s23_srvr.o: ../include/openssl/evp.h ../include/openssl/idea.h 215s23_srvr.o: ../include/openssl/evp.h ../include/openssl/kssl.h
217s23_srvr.o: ../include/openssl/lhash.h ../include/openssl/md2.h 216s23_srvr.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
218s23_srvr.o: ../include/openssl/md4.h ../include/openssl/md5.h
219s23_srvr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
220s23_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 217s23_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
221s23_srvr.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 218s23_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
222s23_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 219s23_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
223s23_srvr.o: ../include/openssl/rand.h ../include/openssl/rc2.h 220s23_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
224s23_srvr.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 221s23_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
225s23_srvr.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 222s23_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
226s23_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h 223s23_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
227s23_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 224s23_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
228s23_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 225s23_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
229s23_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 226s23_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s23_srvr.c
230s23_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h 227s23_srvr.o: ssl_locl.h
231s23_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h 228s2_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
232s2_clnt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 229s2_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
233s2_clnt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
234s2_clnt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
235s2_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 230s2_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
236s2_clnt.o: ../include/openssl/des.h ../include/openssl/dh.h 231s2_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
237s2_clnt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
238s2_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 232s2_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
239s2_clnt.o: ../include/openssl/evp.h ../include/openssl/idea.h 233s2_clnt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
240s2_clnt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 234s2_clnt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
241s2_clnt.o: ../include/openssl/md4.h ../include/openssl/md5.h
242s2_clnt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
243s2_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 235s2_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
244s2_clnt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 236s2_clnt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
245s2_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 237s2_clnt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
246s2_clnt.o: ../include/openssl/rand.h ../include/openssl/rc2.h 238s2_clnt.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
247s2_clnt.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 239s2_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
248s2_clnt.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 240s2_clnt.o: ../include/openssl/sha.h ../include/openssl/ssl.h
249s2_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h 241s2_clnt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
250s2_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 242s2_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
251s2_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 243s2_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
252s2_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 244s2_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s2_clnt.c
253s2_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h 245s2_clnt.o: ssl_locl.h
254s2_clnt.o: ../include/openssl/x509_vfy.h ssl_locl.h 246s2_enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
255s2_enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h 247s2_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h
256s2_enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
257s2_enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h
258s2_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h 248s2_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h
259s2_enc.o: ../include/openssl/des.h ../include/openssl/dh.h 249s2_enc.o: ../include/openssl/dh.h ../include/openssl/dsa.h
260s2_enc.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
261s2_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h 250s2_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h
262s2_enc.o: ../include/openssl/evp.h ../include/openssl/idea.h 251s2_enc.o: ../include/openssl/evp.h ../include/openssl/kssl.h
263s2_enc.o: ../include/openssl/lhash.h ../include/openssl/md2.h 252s2_enc.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
264s2_enc.o: ../include/openssl/md4.h ../include/openssl/md5.h
265s2_enc.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
266s2_enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 253s2_enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
267s2_enc.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 254s2_enc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
268s2_enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 255s2_enc.o: ../include/openssl/pem.h ../include/openssl/pem2.h
269s2_enc.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 256s2_enc.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
270s2_enc.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 257s2_enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h
271s2_enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 258s2_enc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
272s2_enc.o: ../include/openssl/sha.h ../include/openssl/ssl.h 259s2_enc.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
273s2_enc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 260s2_enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
274s2_enc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 261s2_enc.o: ../include/openssl/tls1.h ../include/openssl/x509.h
275s2_enc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 262s2_enc.o: ../include/openssl/x509_vfy.h s2_enc.c ssl_locl.h
276s2_enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 263s2_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
277s2_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 264s2_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h
278s2_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
279s2_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h
280s2_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h 265s2_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h
281s2_lib.o: ../include/openssl/des.h ../include/openssl/dh.h 266s2_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h
282s2_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
283s2_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 267s2_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
284s2_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 268s2_lib.o: ../include/openssl/evp.h ../include/openssl/kssl.h
285s2_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 269s2_lib.o: ../include/openssl/lhash.h ../include/openssl/md5.h
286s2_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h 270s2_lib.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
287s2_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 271s2_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
288s2_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 272s2_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
289s2_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
290s2_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 273s2_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
291s2_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
292s2_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
293s2_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 274s2_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
294s2_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 275s2_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h
295s2_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 276s2_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
296s2_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 277s2_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
297s2_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 278s2_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
298s2_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 279s2_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s2_lib.c
299s2_meth.o: ../include/openssl/asn1.h ../include/openssl/bio.h 280s2_lib.o: ssl_locl.h
300s2_meth.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 281s2_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
301s2_meth.o: ../include/openssl/buffer.h ../include/openssl/cast.h 282s2_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h
302s2_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h 283s2_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h
303s2_meth.o: ../include/openssl/des.h ../include/openssl/dh.h 284s2_meth.o: ../include/openssl/dh.h ../include/openssl/dsa.h
304s2_meth.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
305s2_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h 285s2_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h
306s2_meth.o: ../include/openssl/evp.h ../include/openssl/idea.h 286s2_meth.o: ../include/openssl/evp.h ../include/openssl/kssl.h
307s2_meth.o: ../include/openssl/lhash.h ../include/openssl/md2.h 287s2_meth.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
308s2_meth.o: ../include/openssl/md4.h ../include/openssl/md5.h
309s2_meth.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
310s2_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 288s2_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
311s2_meth.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 289s2_meth.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
312s2_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 290s2_meth.o: ../include/openssl/pem.h ../include/openssl/pem2.h
313s2_meth.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 291s2_meth.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
314s2_meth.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 292s2_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h
315s2_meth.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 293s2_meth.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
316s2_meth.o: ../include/openssl/sha.h ../include/openssl/ssl.h 294s2_meth.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
317s2_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 295s2_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
318s2_meth.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 296s2_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h
319s2_meth.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 297s2_meth.o: ../include/openssl/x509_vfy.h s2_meth.c ssl_locl.h
320s2_meth.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 298s2_pkt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
321s2_pkt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 299s2_pkt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
322s2_pkt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
323s2_pkt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
324s2_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 300s2_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
325s2_pkt.o: ../include/openssl/des.h ../include/openssl/dh.h 301s2_pkt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
326s2_pkt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
327s2_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 302s2_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
328s2_pkt.o: ../include/openssl/evp.h ../include/openssl/idea.h 303s2_pkt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
329s2_pkt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 304s2_pkt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
330s2_pkt.o: ../include/openssl/md4.h ../include/openssl/md5.h
331s2_pkt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
332s2_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 305s2_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
333s2_pkt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 306s2_pkt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
334s2_pkt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 307s2_pkt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
335s2_pkt.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 308s2_pkt.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
336s2_pkt.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 309s2_pkt.o: ../include/openssl/safestack.h ../include/openssl/sha.h
337s2_pkt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 310s2_pkt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
338s2_pkt.o: ../include/openssl/sha.h ../include/openssl/ssl.h 311s2_pkt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
339s2_pkt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 312s2_pkt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
340s2_pkt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 313s2_pkt.o: ../include/openssl/tls1.h ../include/openssl/x509.h
341s2_pkt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 314s2_pkt.o: ../include/openssl/x509_vfy.h s2_pkt.c ssl_locl.h
342s2_pkt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 315s2_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
343s2_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 316s2_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h
344s2_srvr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
345s2_srvr.o: ../include/openssl/buffer.h ../include/openssl/cast.h
346s2_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h 317s2_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h
347s2_srvr.o: ../include/openssl/des.h ../include/openssl/dh.h 318s2_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h
348s2_srvr.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
349s2_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h 319s2_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h
350s2_srvr.o: ../include/openssl/evp.h ../include/openssl/idea.h 320s2_srvr.o: ../include/openssl/evp.h ../include/openssl/kssl.h
351s2_srvr.o: ../include/openssl/lhash.h ../include/openssl/md2.h 321s2_srvr.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
352s2_srvr.o: ../include/openssl/md4.h ../include/openssl/md5.h
353s2_srvr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
354s2_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 322s2_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
355s2_srvr.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 323s2_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
356s2_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 324s2_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
357s2_srvr.o: ../include/openssl/rand.h ../include/openssl/rc2.h 325s2_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
358s2_srvr.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 326s2_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
359s2_srvr.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 327s2_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
360s2_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h 328s2_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
361s2_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 329s2_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
362s2_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 330s2_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
363s2_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 331s2_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s2_srvr.c
364s2_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h 332s2_srvr.o: ssl_locl.h
365s2_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h 333s3_both.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
366s3_both.o: ../include/openssl/asn1.h ../include/openssl/bio.h 334s3_both.o: ../include/openssl/bn.h ../include/openssl/buffer.h
367s3_both.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
368s3_both.o: ../include/openssl/buffer.h ../include/openssl/cast.h
369s3_both.o: ../include/openssl/comp.h ../include/openssl/crypto.h 335s3_both.o: ../include/openssl/comp.h ../include/openssl/crypto.h
370s3_both.o: ../include/openssl/des.h ../include/openssl/dh.h 336s3_both.o: ../include/openssl/dh.h ../include/openssl/dsa.h
371s3_both.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
372s3_both.o: ../include/openssl/e_os2.h ../include/openssl/err.h 337s3_both.o: ../include/openssl/e_os2.h ../include/openssl/err.h
373s3_both.o: ../include/openssl/evp.h ../include/openssl/idea.h 338s3_both.o: ../include/openssl/evp.h ../include/openssl/kssl.h
374s3_both.o: ../include/openssl/lhash.h ../include/openssl/md2.h 339s3_both.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
375s3_both.o: ../include/openssl/md4.h ../include/openssl/md5.h
376s3_both.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
377s3_both.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 340s3_both.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
378s3_both.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 341s3_both.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
379s3_both.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 342s3_both.o: ../include/openssl/pem.h ../include/openssl/pem2.h
380s3_both.o: ../include/openssl/rand.h ../include/openssl/rc2.h 343s3_both.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
381s3_both.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 344s3_both.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
382s3_both.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 345s3_both.o: ../include/openssl/sha.h ../include/openssl/ssl.h
383s3_both.o: ../include/openssl/safestack.h ../include/openssl/sha.h 346s3_both.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
384s3_both.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 347s3_both.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
385s3_both.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 348s3_both.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
386s3_both.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 349s3_both.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_both.c
387s3_both.o: ../include/openssl/tls1.h ../include/openssl/x509.h 350s3_both.o: ssl_locl.h
388s3_both.o: ../include/openssl/x509_vfy.h ssl_locl.h 351s3_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
389s3_clnt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 352s3_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
390s3_clnt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
391s3_clnt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
392s3_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 353s3_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
393s3_clnt.o: ../include/openssl/des.h ../include/openssl/dh.h 354s3_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
394s3_clnt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
395s3_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 355s3_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
396s3_clnt.o: ../include/openssl/evp.h ../include/openssl/idea.h 356s3_clnt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
397s3_clnt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 357s3_clnt.o: ../include/openssl/lhash.h ../include/openssl/md5.h
398s3_clnt.o: ../include/openssl/md4.h ../include/openssl/md5.h 358s3_clnt.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
399s3_clnt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 359s3_clnt.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
400s3_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 360s3_clnt.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
401s3_clnt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
402s3_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 361s3_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
403s3_clnt.o: ../include/openssl/rand.h ../include/openssl/rc2.h 362s3_clnt.o: ../include/openssl/rand.h ../include/openssl/rsa.h
404s3_clnt.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
405s3_clnt.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
406s3_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h 363s3_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h
407s3_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 364s3_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
408s3_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 365s3_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
409s3_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 366s3_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
410s3_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h 367s3_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h
411s3_clnt.o: ../include/openssl/x509_vfy.h ssl_locl.h 368s3_clnt.o: ../include/openssl/x509_vfy.h kssl_lcl.h s3_clnt.c ssl_locl.h
412s3_enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h 369s3_enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
413s3_enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 370s3_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h
414s3_enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h
415s3_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h 371s3_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h
416s3_enc.o: ../include/openssl/des.h ../include/openssl/dh.h 372s3_enc.o: ../include/openssl/dh.h ../include/openssl/dsa.h
417s3_enc.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
418s3_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h 373s3_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h
419s3_enc.o: ../include/openssl/evp.h ../include/openssl/idea.h 374s3_enc.o: ../include/openssl/evp.h ../include/openssl/kssl.h
420s3_enc.o: ../include/openssl/lhash.h ../include/openssl/md2.h 375s3_enc.o: ../include/openssl/lhash.h ../include/openssl/md5.h
421s3_enc.o: ../include/openssl/md4.h ../include/openssl/md5.h 376s3_enc.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
422s3_enc.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 377s3_enc.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
423s3_enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 378s3_enc.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
424s3_enc.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
425s3_enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 379s3_enc.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
426s3_enc.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
427s3_enc.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
428s3_enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 380s3_enc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
429s3_enc.o: ../include/openssl/sha.h ../include/openssl/ssl.h 381s3_enc.o: ../include/openssl/sha.h ../include/openssl/ssl.h
430s3_enc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 382s3_enc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
431s3_enc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 383s3_enc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
432s3_enc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 384s3_enc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
433s3_enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 385s3_enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_enc.c
434s3_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 386s3_enc.o: ssl_locl.h
435s3_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 387s3_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
436s3_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h 388s3_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h
437s3_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h 389s3_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h
438s3_lib.o: ../include/openssl/des.h ../include/openssl/dh.h 390s3_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h
439s3_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
440s3_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 391s3_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
441s3_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 392s3_lib.o: ../include/openssl/evp.h ../include/openssl/kssl.h
442s3_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 393s3_lib.o: ../include/openssl/lhash.h ../include/openssl/md5.h
443s3_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h 394s3_lib.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
444s3_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 395s3_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
445s3_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 396s3_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
446s3_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
447s3_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 397s3_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
448s3_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
449s3_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
450s3_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 398s3_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
451s3_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 399s3_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h
452s3_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 400s3_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
453s3_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 401s3_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
454s3_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 402s3_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
455s3_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 403s3_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h
456s3_meth.o: ../include/openssl/asn1.h ../include/openssl/bio.h 404s3_lib.o: s3_lib.c ssl_locl.h
457s3_meth.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 405s3_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
458s3_meth.o: ../include/openssl/buffer.h ../include/openssl/cast.h 406s3_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h
459s3_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h 407s3_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h
460s3_meth.o: ../include/openssl/des.h ../include/openssl/dh.h 408s3_meth.o: ../include/openssl/dh.h ../include/openssl/dsa.h
461s3_meth.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
462s3_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h 409s3_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h
463s3_meth.o: ../include/openssl/evp.h ../include/openssl/idea.h 410s3_meth.o: ../include/openssl/evp.h ../include/openssl/kssl.h
464s3_meth.o: ../include/openssl/lhash.h ../include/openssl/md2.h 411s3_meth.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
465s3_meth.o: ../include/openssl/md4.h ../include/openssl/md5.h
466s3_meth.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
467s3_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 412s3_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
468s3_meth.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 413s3_meth.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
469s3_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 414s3_meth.o: ../include/openssl/pem.h ../include/openssl/pem2.h
470s3_meth.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 415s3_meth.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
471s3_meth.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 416s3_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h
472s3_meth.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 417s3_meth.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
473s3_meth.o: ../include/openssl/sha.h ../include/openssl/ssl.h 418s3_meth.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
474s3_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 419s3_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
475s3_meth.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 420s3_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h
476s3_meth.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 421s3_meth.o: ../include/openssl/x509_vfy.h s3_meth.c ssl_locl.h
477s3_meth.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 422s3_pkt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
478s3_pkt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 423s3_pkt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
479s3_pkt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
480s3_pkt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
481s3_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 424s3_pkt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
482s3_pkt.o: ../include/openssl/des.h ../include/openssl/dh.h 425s3_pkt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
483s3_pkt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
484s3_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 426s3_pkt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
485s3_pkt.o: ../include/openssl/evp.h ../include/openssl/idea.h 427s3_pkt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
486s3_pkt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 428s3_pkt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
487s3_pkt.o: ../include/openssl/md4.h ../include/openssl/md5.h
488s3_pkt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
489s3_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 429s3_pkt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
490s3_pkt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 430s3_pkt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
491s3_pkt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 431s3_pkt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
492s3_pkt.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 432s3_pkt.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
493s3_pkt.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 433s3_pkt.o: ../include/openssl/safestack.h ../include/openssl/sha.h
494s3_pkt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 434s3_pkt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
495s3_pkt.o: ../include/openssl/sha.h ../include/openssl/ssl.h 435s3_pkt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
496s3_pkt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 436s3_pkt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
497s3_pkt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 437s3_pkt.o: ../include/openssl/tls1.h ../include/openssl/x509.h
498s3_pkt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 438s3_pkt.o: ../include/openssl/x509_vfy.h s3_pkt.c ssl_locl.h
499s3_pkt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 439s3_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
500s3_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 440s3_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h
501s3_srvr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
502s3_srvr.o: ../include/openssl/buffer.h ../include/openssl/cast.h
503s3_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h 441s3_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h
504s3_srvr.o: ../include/openssl/des.h ../include/openssl/dh.h 442s3_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h
505s3_srvr.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
506s3_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h 443s3_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h
507s3_srvr.o: ../include/openssl/evp.h ../include/openssl/idea.h 444s3_srvr.o: ../include/openssl/evp.h ../include/openssl/krb5_asn.h
508s3_srvr.o: ../include/openssl/lhash.h ../include/openssl/md2.h 445s3_srvr.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
509s3_srvr.o: ../include/openssl/md4.h ../include/openssl/md5.h 446s3_srvr.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
510s3_srvr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
511s3_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 447s3_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
512s3_srvr.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 448s3_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
513s3_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 449s3_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
514s3_srvr.o: ../include/openssl/rand.h ../include/openssl/rc2.h 450s3_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
515s3_srvr.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 451s3_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
516s3_srvr.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 452s3_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
517s3_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h 453s3_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
518s3_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 454s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
519s3_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 455s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
520s3_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 456s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h
521s3_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h 457s3_srvr.o: s3_srvr.c ssl_locl.h
522s3_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h 458ssl_algs.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
523ssl_algs.o: ../include/openssl/asn1.h ../include/openssl/bio.h 459ssl_algs.o: ../include/openssl/bn.h ../include/openssl/buffer.h
524ssl_algs.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
525ssl_algs.o: ../include/openssl/buffer.h ../include/openssl/cast.h
526ssl_algs.o: ../include/openssl/comp.h ../include/openssl/crypto.h 460ssl_algs.o: ../include/openssl/comp.h ../include/openssl/crypto.h
527ssl_algs.o: ../include/openssl/des.h ../include/openssl/dh.h 461ssl_algs.o: ../include/openssl/dh.h ../include/openssl/dsa.h
528ssl_algs.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
529ssl_algs.o: ../include/openssl/e_os2.h ../include/openssl/err.h 462ssl_algs.o: ../include/openssl/e_os2.h ../include/openssl/err.h
530ssl_algs.o: ../include/openssl/evp.h ../include/openssl/idea.h 463ssl_algs.o: ../include/openssl/evp.h ../include/openssl/kssl.h
531ssl_algs.o: ../include/openssl/lhash.h ../include/openssl/md2.h 464ssl_algs.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
532ssl_algs.o: ../include/openssl/md4.h ../include/openssl/md5.h
533ssl_algs.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
534ssl_algs.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 465ssl_algs.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
535ssl_algs.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 466ssl_algs.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
536ssl_algs.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 467ssl_algs.o: ../include/openssl/pem.h ../include/openssl/pem2.h
537ssl_algs.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 468ssl_algs.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
538ssl_algs.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 469ssl_algs.o: ../include/openssl/safestack.h ../include/openssl/sha.h
539ssl_algs.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 470ssl_algs.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
540ssl_algs.o: ../include/openssl/sha.h ../include/openssl/ssl.h 471ssl_algs.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
541ssl_algs.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 472ssl_algs.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
542ssl_algs.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 473ssl_algs.o: ../include/openssl/tls1.h ../include/openssl/x509.h
543ssl_algs.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 474ssl_algs.o: ../include/openssl/x509_vfy.h ssl_algs.c ssl_locl.h
544ssl_algs.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 475ssl_asn1.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/asn1_mac.h
545ssl_asn1.o: ../include/openssl/asn1.h ../include/openssl/asn1_mac.h 476ssl_asn1.o: ../include/openssl/bio.h ../include/openssl/bn.h
546ssl_asn1.o: ../include/openssl/bio.h ../include/openssl/blowfish.h 477ssl_asn1.o: ../include/openssl/buffer.h ../include/openssl/comp.h
547ssl_asn1.o: ../include/openssl/bn.h ../include/openssl/buffer.h 478ssl_asn1.o: ../include/openssl/crypto.h ../include/openssl/dh.h
548ssl_asn1.o: ../include/openssl/cast.h ../include/openssl/comp.h 479ssl_asn1.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
549ssl_asn1.o: ../include/openssl/crypto.h ../include/openssl/des.h
550ssl_asn1.o: ../include/openssl/dh.h ../include/openssl/dsa.h
551ssl_asn1.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
552ssl_asn1.o: ../include/openssl/err.h ../include/openssl/evp.h 480ssl_asn1.o: ../include/openssl/err.h ../include/openssl/evp.h
553ssl_asn1.o: ../include/openssl/idea.h ../include/openssl/lhash.h 481ssl_asn1.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
554ssl_asn1.o: ../include/openssl/md2.h ../include/openssl/md4.h
555ssl_asn1.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
556ssl_asn1.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h 482ssl_asn1.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
557ssl_asn1.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 483ssl_asn1.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
558ssl_asn1.o: ../include/openssl/pem.h ../include/openssl/pem2.h 484ssl_asn1.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
559ssl_asn1.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 485ssl_asn1.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
560ssl_asn1.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 486ssl_asn1.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
561ssl_asn1.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 487ssl_asn1.o: ../include/openssl/sha.h ../include/openssl/ssl.h
562ssl_asn1.o: ../include/openssl/safestack.h ../include/openssl/sha.h 488ssl_asn1.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
563ssl_asn1.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 489ssl_asn1.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
564ssl_asn1.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 490ssl_asn1.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
565ssl_asn1.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 491ssl_asn1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_asn1.c
566ssl_asn1.o: ../include/openssl/tls1.h ../include/openssl/x509.h 492ssl_asn1.o: ssl_locl.h
567ssl_asn1.o: ../include/openssl/x509_vfy.h ssl_locl.h 493ssl_cert.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
568ssl_cert.o: ../include/openssl/asn1.h ../include/openssl/bio.h 494ssl_cert.o: ../include/openssl/bn.h ../include/openssl/buffer.h
569ssl_cert.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
570ssl_cert.o: ../include/openssl/buffer.h ../include/openssl/cast.h
571ssl_cert.o: ../include/openssl/comp.h ../include/openssl/conf.h 495ssl_cert.o: ../include/openssl/comp.h ../include/openssl/conf.h
572ssl_cert.o: ../include/openssl/crypto.h ../include/openssl/des.h 496ssl_cert.o: ../include/openssl/crypto.h ../include/openssl/dh.h
573ssl_cert.o: ../include/openssl/dh.h ../include/openssl/dsa.h 497ssl_cert.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
574ssl_cert.o: ../include/openssl/e_os.h ../include/openssl/e_os.h
575ssl_cert.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
576ssl_cert.o: ../include/openssl/err.h ../include/openssl/evp.h 498ssl_cert.o: ../include/openssl/err.h ../include/openssl/evp.h
577ssl_cert.o: ../include/openssl/idea.h ../include/openssl/lhash.h 499ssl_cert.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
578ssl_cert.o: ../include/openssl/md2.h ../include/openssl/md4.h
579ssl_cert.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
580ssl_cert.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h 500ssl_cert.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
581ssl_cert.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 501ssl_cert.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
582ssl_cert.o: ../include/openssl/pem.h ../include/openssl/pem2.h 502ssl_cert.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
583ssl_cert.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 503ssl_cert.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
584ssl_cert.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 504ssl_cert.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
585ssl_cert.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 505ssl_cert.o: ../include/openssl/sha.h ../include/openssl/ssl.h
586ssl_cert.o: ../include/openssl/safestack.h ../include/openssl/sha.h 506ssl_cert.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
587ssl_cert.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 507ssl_cert.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
588ssl_cert.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 508ssl_cert.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
589ssl_cert.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 509ssl_cert.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
590ssl_cert.o: ../include/openssl/tls1.h ../include/openssl/x509.h 510ssl_cert.o: ../include/openssl/x509v3.h ssl_cert.c ssl_locl.h
591ssl_cert.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h 511ssl_ciph.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
592ssl_cert.o: ssl_locl.h 512ssl_ciph.o: ../include/openssl/bn.h ../include/openssl/buffer.h
593ssl_ciph.o: ../include/openssl/asn1.h ../include/openssl/bio.h
594ssl_ciph.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
595ssl_ciph.o: ../include/openssl/buffer.h ../include/openssl/cast.h
596ssl_ciph.o: ../include/openssl/comp.h ../include/openssl/crypto.h 513ssl_ciph.o: ../include/openssl/comp.h ../include/openssl/crypto.h
597ssl_ciph.o: ../include/openssl/des.h ../include/openssl/dh.h 514ssl_ciph.o: ../include/openssl/dh.h ../include/openssl/dsa.h
598ssl_ciph.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
599ssl_ciph.o: ../include/openssl/e_os2.h ../include/openssl/err.h 515ssl_ciph.o: ../include/openssl/e_os2.h ../include/openssl/err.h
600ssl_ciph.o: ../include/openssl/evp.h ../include/openssl/idea.h 516ssl_ciph.o: ../include/openssl/evp.h ../include/openssl/kssl.h
601ssl_ciph.o: ../include/openssl/lhash.h ../include/openssl/md2.h 517ssl_ciph.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
602ssl_ciph.o: ../include/openssl/md4.h ../include/openssl/md5.h
603ssl_ciph.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
604ssl_ciph.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 518ssl_ciph.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
605ssl_ciph.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 519ssl_ciph.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
606ssl_ciph.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 520ssl_ciph.o: ../include/openssl/pem.h ../include/openssl/pem2.h
607ssl_ciph.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 521ssl_ciph.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
608ssl_ciph.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 522ssl_ciph.o: ../include/openssl/safestack.h ../include/openssl/sha.h
609ssl_ciph.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 523ssl_ciph.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
610ssl_ciph.o: ../include/openssl/sha.h ../include/openssl/ssl.h 524ssl_ciph.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
611ssl_ciph.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 525ssl_ciph.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
612ssl_ciph.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 526ssl_ciph.o: ../include/openssl/tls1.h ../include/openssl/x509.h
613ssl_ciph.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 527ssl_ciph.o: ../include/openssl/x509_vfy.h ssl_ciph.c ssl_locl.h
614ssl_ciph.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h
615ssl_err.o: ../include/openssl/asn1.h ../include/openssl/bio.h 528ssl_err.o: ../include/openssl/asn1.h ../include/openssl/bio.h
616ssl_err.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 529ssl_err.o: ../include/openssl/bn.h ../include/openssl/buffer.h
617ssl_err.o: ../include/openssl/buffer.h ../include/openssl/cast.h
618ssl_err.o: ../include/openssl/comp.h ../include/openssl/crypto.h 530ssl_err.o: ../include/openssl/comp.h ../include/openssl/crypto.h
619ssl_err.o: ../include/openssl/des.h ../include/openssl/dh.h 531ssl_err.o: ../include/openssl/dh.h ../include/openssl/dsa.h
620ssl_err.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 532ssl_err.o: ../include/openssl/e_os2.h ../include/openssl/err.h
621ssl_err.o: ../include/openssl/err.h ../include/openssl/evp.h 533ssl_err.o: ../include/openssl/evp.h ../include/openssl/kssl.h
622ssl_err.o: ../include/openssl/idea.h ../include/openssl/lhash.h 534ssl_err.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
623ssl_err.o: ../include/openssl/md2.h ../include/openssl/md4.h 535ssl_err.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
624ssl_err.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 536ssl_err.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
625ssl_err.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
626ssl_err.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
627ssl_err.o: ../include/openssl/pem.h ../include/openssl/pem2.h 537ssl_err.o: ../include/openssl/pem.h ../include/openssl/pem2.h
628ssl_err.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 538ssl_err.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
629ssl_err.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
630ssl_err.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
631ssl_err.o: ../include/openssl/safestack.h ../include/openssl/sha.h 539ssl_err.o: ../include/openssl/safestack.h ../include/openssl/sha.h
632ssl_err.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 540ssl_err.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
633ssl_err.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 541ssl_err.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
634ssl_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 542ssl_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
635ssl_err.o: ../include/openssl/tls1.h ../include/openssl/x509.h 543ssl_err.o: ../include/openssl/tls1.h ../include/openssl/x509.h
636ssl_err.o: ../include/openssl/x509_vfy.h 544ssl_err.o: ../include/openssl/x509_vfy.h ssl_err.c
637ssl_err2.o: ../include/openssl/asn1.h ../include/openssl/bio.h 545ssl_err2.o: ../include/openssl/asn1.h ../include/openssl/bio.h
638ssl_err2.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 546ssl_err2.o: ../include/openssl/bn.h ../include/openssl/buffer.h
639ssl_err2.o: ../include/openssl/buffer.h ../include/openssl/cast.h
640ssl_err2.o: ../include/openssl/comp.h ../include/openssl/crypto.h 547ssl_err2.o: ../include/openssl/comp.h ../include/openssl/crypto.h
641ssl_err2.o: ../include/openssl/des.h ../include/openssl/dh.h 548ssl_err2.o: ../include/openssl/dh.h ../include/openssl/dsa.h
642ssl_err2.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 549ssl_err2.o: ../include/openssl/e_os2.h ../include/openssl/err.h
643ssl_err2.o: ../include/openssl/err.h ../include/openssl/evp.h 550ssl_err2.o: ../include/openssl/evp.h ../include/openssl/kssl.h
644ssl_err2.o: ../include/openssl/idea.h ../include/openssl/lhash.h 551ssl_err2.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
645ssl_err2.o: ../include/openssl/md2.h ../include/openssl/md4.h 552ssl_err2.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
646ssl_err2.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 553ssl_err2.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
647ssl_err2.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
648ssl_err2.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
649ssl_err2.o: ../include/openssl/pem.h ../include/openssl/pem2.h 554ssl_err2.o: ../include/openssl/pem.h ../include/openssl/pem2.h
650ssl_err2.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 555ssl_err2.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
651ssl_err2.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
652ssl_err2.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
653ssl_err2.o: ../include/openssl/safestack.h ../include/openssl/sha.h 556ssl_err2.o: ../include/openssl/safestack.h ../include/openssl/sha.h
654ssl_err2.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 557ssl_err2.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
655ssl_err2.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 558ssl_err2.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
656ssl_err2.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 559ssl_err2.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
657ssl_err2.o: ../include/openssl/tls1.h ../include/openssl/x509.h 560ssl_err2.o: ../include/openssl/tls1.h ../include/openssl/x509.h
658ssl_err2.o: ../include/openssl/x509_vfy.h 561ssl_err2.o: ../include/openssl/x509_vfy.h ssl_err2.c
659ssl_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 562ssl_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
660ssl_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 563ssl_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h
661ssl_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h
662ssl_lib.o: ../include/openssl/comp.h ../include/openssl/conf.h 564ssl_lib.o: ../include/openssl/comp.h ../include/openssl/conf.h
663ssl_lib.o: ../include/openssl/crypto.h ../include/openssl/des.h 565ssl_lib.o: ../include/openssl/crypto.h ../include/openssl/dh.h
664ssl_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h 566ssl_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
665ssl_lib.o: ../include/openssl/e_os.h ../include/openssl/e_os.h 567ssl_lib.o: ../include/openssl/err.h ../include/openssl/evp.h
666ssl_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 568ssl_lib.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
667ssl_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 569ssl_lib.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
668ssl_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 570ssl_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
669ssl_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h 571ssl_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
670ssl_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
671ssl_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
672ssl_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
673ssl_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 572ssl_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
674ssl_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
675ssl_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
676ssl_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 573ssl_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
677ssl_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 574ssl_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h
678ssl_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 575ssl_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
679ssl_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 576ssl_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
680ssl_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 577ssl_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
681ssl_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h 578ssl_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
682ssl_lib.o: ../include/openssl/x509v3.h ssl_locl.h 579ssl_lib.o: ../include/openssl/x509v3.h kssl_lcl.h ssl_lib.c ssl_locl.h
683ssl_rsa.o: ../include/openssl/asn1.h ../include/openssl/bio.h 580ssl_rsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
684ssl_rsa.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 581ssl_rsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
685ssl_rsa.o: ../include/openssl/buffer.h ../include/openssl/cast.h
686ssl_rsa.o: ../include/openssl/comp.h ../include/openssl/crypto.h 582ssl_rsa.o: ../include/openssl/comp.h ../include/openssl/crypto.h
687ssl_rsa.o: ../include/openssl/des.h ../include/openssl/dh.h 583ssl_rsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
688ssl_rsa.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
689ssl_rsa.o: ../include/openssl/e_os2.h ../include/openssl/err.h 584ssl_rsa.o: ../include/openssl/e_os2.h ../include/openssl/err.h
690ssl_rsa.o: ../include/openssl/evp.h ../include/openssl/idea.h 585ssl_rsa.o: ../include/openssl/evp.h ../include/openssl/kssl.h
691ssl_rsa.o: ../include/openssl/lhash.h ../include/openssl/md2.h 586ssl_rsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
692ssl_rsa.o: ../include/openssl/md4.h ../include/openssl/md5.h
693ssl_rsa.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
694ssl_rsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 587ssl_rsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
695ssl_rsa.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 588ssl_rsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
696ssl_rsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 589ssl_rsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
697ssl_rsa.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 590ssl_rsa.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
698ssl_rsa.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 591ssl_rsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h
699ssl_rsa.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 592ssl_rsa.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
700ssl_rsa.o: ../include/openssl/sha.h ../include/openssl/ssl.h 593ssl_rsa.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
701ssl_rsa.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 594ssl_rsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
702ssl_rsa.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 595ssl_rsa.o: ../include/openssl/tls1.h ../include/openssl/x509.h
703ssl_rsa.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 596ssl_rsa.o: ../include/openssl/x509_vfy.h ssl_locl.h ssl_rsa.c
704ssl_rsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 597ssl_sess.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
705ssl_sess.o: ../include/openssl/asn1.h ../include/openssl/bio.h 598ssl_sess.o: ../include/openssl/bn.h ../include/openssl/buffer.h
706ssl_sess.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
707ssl_sess.o: ../include/openssl/buffer.h ../include/openssl/cast.h
708ssl_sess.o: ../include/openssl/comp.h ../include/openssl/crypto.h 599ssl_sess.o: ../include/openssl/comp.h ../include/openssl/crypto.h
709ssl_sess.o: ../include/openssl/des.h ../include/openssl/dh.h 600ssl_sess.o: ../include/openssl/dh.h ../include/openssl/dsa.h
710ssl_sess.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
711ssl_sess.o: ../include/openssl/e_os2.h ../include/openssl/err.h 601ssl_sess.o: ../include/openssl/e_os2.h ../include/openssl/err.h
712ssl_sess.o: ../include/openssl/evp.h ../include/openssl/idea.h 602ssl_sess.o: ../include/openssl/evp.h ../include/openssl/kssl.h
713ssl_sess.o: ../include/openssl/lhash.h ../include/openssl/md2.h 603ssl_sess.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
714ssl_sess.o: ../include/openssl/md4.h ../include/openssl/md5.h
715ssl_sess.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
716ssl_sess.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 604ssl_sess.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
717ssl_sess.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 605ssl_sess.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
718ssl_sess.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 606ssl_sess.o: ../include/openssl/pem.h ../include/openssl/pem2.h
719ssl_sess.o: ../include/openssl/rand.h ../include/openssl/rc2.h 607ssl_sess.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
720ssl_sess.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 608ssl_sess.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
721ssl_sess.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 609ssl_sess.o: ../include/openssl/sha.h ../include/openssl/ssl.h
722ssl_sess.o: ../include/openssl/safestack.h ../include/openssl/sha.h 610ssl_sess.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
723ssl_sess.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 611ssl_sess.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
724ssl_sess.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 612ssl_sess.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
725ssl_sess.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 613ssl_sess.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h
726ssl_sess.o: ../include/openssl/tls1.h ../include/openssl/x509.h 614ssl_sess.o: ssl_sess.c
727ssl_sess.o: ../include/openssl/x509_vfy.h ssl_locl.h 615ssl_stat.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
728ssl_stat.o: ../include/openssl/asn1.h ../include/openssl/bio.h 616ssl_stat.o: ../include/openssl/bn.h ../include/openssl/buffer.h
729ssl_stat.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
730ssl_stat.o: ../include/openssl/buffer.h ../include/openssl/cast.h
731ssl_stat.o: ../include/openssl/comp.h ../include/openssl/crypto.h 617ssl_stat.o: ../include/openssl/comp.h ../include/openssl/crypto.h
732ssl_stat.o: ../include/openssl/des.h ../include/openssl/dh.h 618ssl_stat.o: ../include/openssl/dh.h ../include/openssl/dsa.h
733ssl_stat.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
734ssl_stat.o: ../include/openssl/e_os2.h ../include/openssl/err.h 619ssl_stat.o: ../include/openssl/e_os2.h ../include/openssl/err.h
735ssl_stat.o: ../include/openssl/evp.h ../include/openssl/idea.h 620ssl_stat.o: ../include/openssl/evp.h ../include/openssl/kssl.h
736ssl_stat.o: ../include/openssl/lhash.h ../include/openssl/md2.h 621ssl_stat.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
737ssl_stat.o: ../include/openssl/md4.h ../include/openssl/md5.h
738ssl_stat.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
739ssl_stat.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 622ssl_stat.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
740ssl_stat.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 623ssl_stat.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
741ssl_stat.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 624ssl_stat.o: ../include/openssl/pem.h ../include/openssl/pem2.h
742ssl_stat.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 625ssl_stat.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
743ssl_stat.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 626ssl_stat.o: ../include/openssl/safestack.h ../include/openssl/sha.h
744ssl_stat.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 627ssl_stat.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
745ssl_stat.o: ../include/openssl/sha.h ../include/openssl/ssl.h 628ssl_stat.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
746ssl_stat.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 629ssl_stat.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
747ssl_stat.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 630ssl_stat.o: ../include/openssl/tls1.h ../include/openssl/x509.h
748ssl_stat.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 631ssl_stat.o: ../include/openssl/x509_vfy.h ssl_locl.h ssl_stat.c
749ssl_stat.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 632ssl_txt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
750ssl_txt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 633ssl_txt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
751ssl_txt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
752ssl_txt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
753ssl_txt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 634ssl_txt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
754ssl_txt.o: ../include/openssl/des.h ../include/openssl/dh.h 635ssl_txt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
755ssl_txt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
756ssl_txt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 636ssl_txt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
757ssl_txt.o: ../include/openssl/evp.h ../include/openssl/idea.h 637ssl_txt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
758ssl_txt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 638ssl_txt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
759ssl_txt.o: ../include/openssl/md4.h ../include/openssl/md5.h
760ssl_txt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
761ssl_txt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 639ssl_txt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
762ssl_txt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 640ssl_txt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
763ssl_txt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 641ssl_txt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
764ssl_txt.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 642ssl_txt.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
765ssl_txt.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 643ssl_txt.o: ../include/openssl/safestack.h ../include/openssl/sha.h
766ssl_txt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 644ssl_txt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
767ssl_txt.o: ../include/openssl/sha.h ../include/openssl/ssl.h 645ssl_txt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
768ssl_txt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 646ssl_txt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
769ssl_txt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 647ssl_txt.o: ../include/openssl/tls1.h ../include/openssl/x509.h
770ssl_txt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 648ssl_txt.o: ../include/openssl/x509_vfy.h ssl_locl.h ssl_txt.c
771ssl_txt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 649t1_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
772t1_clnt.o: ../include/openssl/asn1.h ../include/openssl/bio.h 650t1_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
773t1_clnt.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
774t1_clnt.o: ../include/openssl/buffer.h ../include/openssl/cast.h
775t1_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h 651t1_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
776t1_clnt.o: ../include/openssl/des.h ../include/openssl/dh.h 652t1_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h
777t1_clnt.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
778t1_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h 653t1_clnt.o: ../include/openssl/e_os2.h ../include/openssl/err.h
779t1_clnt.o: ../include/openssl/evp.h ../include/openssl/idea.h 654t1_clnt.o: ../include/openssl/evp.h ../include/openssl/kssl.h
780t1_clnt.o: ../include/openssl/lhash.h ../include/openssl/md2.h 655t1_clnt.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
781t1_clnt.o: ../include/openssl/md4.h ../include/openssl/md5.h
782t1_clnt.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
783t1_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 656t1_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
784t1_clnt.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 657t1_clnt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
785t1_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 658t1_clnt.o: ../include/openssl/pem.h ../include/openssl/pem2.h
786t1_clnt.o: ../include/openssl/rand.h ../include/openssl/rc2.h 659t1_clnt.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
787t1_clnt.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 660t1_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
788t1_clnt.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 661t1_clnt.o: ../include/openssl/sha.h ../include/openssl/ssl.h
789t1_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h 662t1_clnt.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
790t1_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 663t1_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
791t1_clnt.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 664t1_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
792t1_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 665t1_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h
793t1_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h 666t1_clnt.o: t1_clnt.c
794t1_clnt.o: ../include/openssl/x509_vfy.h ssl_locl.h 667t1_enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
795t1_enc.o: ../include/openssl/asn1.h ../include/openssl/bio.h 668t1_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h
796t1_enc.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
797t1_enc.o: ../include/openssl/buffer.h ../include/openssl/cast.h
798t1_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h 669t1_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h
799t1_enc.o: ../include/openssl/des.h ../include/openssl/dh.h 670t1_enc.o: ../include/openssl/dh.h ../include/openssl/dsa.h
800t1_enc.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
801t1_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h 671t1_enc.o: ../include/openssl/e_os2.h ../include/openssl/err.h
802t1_enc.o: ../include/openssl/evp.h ../include/openssl/hmac.h 672t1_enc.o: ../include/openssl/evp.h ../include/openssl/hmac.h
803t1_enc.o: ../include/openssl/idea.h ../include/openssl/lhash.h 673t1_enc.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
804t1_enc.o: ../include/openssl/md2.h ../include/openssl/md4.h 674t1_enc.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
805t1_enc.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 675t1_enc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
806t1_enc.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h 676t1_enc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
807t1_enc.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
808t1_enc.o: ../include/openssl/pem.h ../include/openssl/pem2.h 677t1_enc.o: ../include/openssl/pem.h ../include/openssl/pem2.h
809t1_enc.o: ../include/openssl/pkcs7.h ../include/openssl/rc2.h 678t1_enc.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
810t1_enc.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
811t1_enc.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
812t1_enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h 679t1_enc.o: ../include/openssl/safestack.h ../include/openssl/sha.h
813t1_enc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 680t1_enc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
814t1_enc.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 681t1_enc.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
815t1_enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 682t1_enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
816t1_enc.o: ../include/openssl/tls1.h ../include/openssl/x509.h 683t1_enc.o: ../include/openssl/tls1.h ../include/openssl/x509.h
817t1_enc.o: ../include/openssl/x509_vfy.h ssl_locl.h 684t1_enc.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_enc.c
818t1_lib.o: ../include/openssl/asn1.h ../include/openssl/bio.h 685t1_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
819t1_lib.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 686t1_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h
820t1_lib.o: ../include/openssl/buffer.h ../include/openssl/cast.h
821t1_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h 687t1_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h
822t1_lib.o: ../include/openssl/des.h ../include/openssl/dh.h 688t1_lib.o: ../include/openssl/dh.h ../include/openssl/dsa.h
823t1_lib.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
824t1_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 689t1_lib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
825t1_lib.o: ../include/openssl/evp.h ../include/openssl/idea.h 690t1_lib.o: ../include/openssl/evp.h ../include/openssl/kssl.h
826t1_lib.o: ../include/openssl/lhash.h ../include/openssl/md2.h 691t1_lib.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
827t1_lib.o: ../include/openssl/md4.h ../include/openssl/md5.h
828t1_lib.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
829t1_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 692t1_lib.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
830t1_lib.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 693t1_lib.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
831t1_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 694t1_lib.o: ../include/openssl/pem.h ../include/openssl/pem2.h
832t1_lib.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 695t1_lib.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
833t1_lib.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 696t1_lib.o: ../include/openssl/safestack.h ../include/openssl/sha.h
834t1_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 697t1_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
835t1_lib.o: ../include/openssl/sha.h ../include/openssl/ssl.h 698t1_lib.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
836t1_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 699t1_lib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
837t1_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 700t1_lib.o: ../include/openssl/tls1.h ../include/openssl/x509.h
838t1_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 701t1_lib.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_lib.c
839t1_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 702t1_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
840t1_meth.o: ../include/openssl/asn1.h ../include/openssl/bio.h 703t1_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h
841t1_meth.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
842t1_meth.o: ../include/openssl/buffer.h ../include/openssl/cast.h
843t1_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h 704t1_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h
844t1_meth.o: ../include/openssl/des.h ../include/openssl/dh.h 705t1_meth.o: ../include/openssl/dh.h ../include/openssl/dsa.h
845t1_meth.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
846t1_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h 706t1_meth.o: ../include/openssl/e_os2.h ../include/openssl/err.h
847t1_meth.o: ../include/openssl/evp.h ../include/openssl/idea.h 707t1_meth.o: ../include/openssl/evp.h ../include/openssl/kssl.h
848t1_meth.o: ../include/openssl/lhash.h ../include/openssl/md2.h 708t1_meth.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
849t1_meth.o: ../include/openssl/md4.h ../include/openssl/md5.h
850t1_meth.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
851t1_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 709t1_meth.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
852t1_meth.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 710t1_meth.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
853t1_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 711t1_meth.o: ../include/openssl/pem.h ../include/openssl/pem2.h
854t1_meth.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 712t1_meth.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
855t1_meth.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 713t1_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h
856t1_meth.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 714t1_meth.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
857t1_meth.o: ../include/openssl/sha.h ../include/openssl/ssl.h 715t1_meth.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
858t1_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h 716t1_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
859t1_meth.o: ../include/openssl/ssl3.h ../include/openssl/stack.h 717t1_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h
860t1_meth.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h 718t1_meth.o: ../include/openssl/x509_vfy.h ssl_locl.h t1_meth.c
861t1_meth.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h 719t1_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
862t1_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h 720t1_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h
863t1_srvr.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
864t1_srvr.o: ../include/openssl/buffer.h ../include/openssl/cast.h
865t1_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h 721t1_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h
866t1_srvr.o: ../include/openssl/des.h ../include/openssl/dh.h 722t1_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h
867t1_srvr.o: ../include/openssl/dsa.h ../include/openssl/e_os.h
868t1_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h 723t1_srvr.o: ../include/openssl/e_os2.h ../include/openssl/err.h
869t1_srvr.o: ../include/openssl/evp.h ../include/openssl/idea.h 724t1_srvr.o: ../include/openssl/evp.h ../include/openssl/kssl.h
870t1_srvr.o: ../include/openssl/lhash.h ../include/openssl/md2.h 725t1_srvr.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
871t1_srvr.o: ../include/openssl/md4.h ../include/openssl/md5.h
872t1_srvr.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
873t1_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 726t1_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
874t1_srvr.o: ../include/openssl/opensslv.h ../include/openssl/pem.h 727t1_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
875t1_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 728t1_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
876t1_srvr.o: ../include/openssl/rand.h ../include/openssl/rc2.h 729t1_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
877t1_srvr.o: ../include/openssl/rc4.h ../include/openssl/rc5.h 730t1_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
878t1_srvr.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h 731t1_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
879t1_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h 732t1_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
880t1_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 733t1_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
881t1_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 734t1_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
882t1_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 735t1_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_locl.h
883t1_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h 736t1_srvr.o: t1_srvr.c
884t1_srvr.o: ../include/openssl/x509_vfy.h ssl_locl.h
diff --git a/src/lib/libssl/src/ssl/bio_ssl.c b/src/lib/libssl/src/ssl/bio_ssl.c
index d85555a7e6..467e149947 100644
--- a/src/lib/libssl/src/ssl/bio_ssl.c
+++ b/src/lib/libssl/src/ssl/bio_ssl.c
@@ -206,6 +206,10 @@ static int ssl_read(BIO *b, char *out, int outl)
206 BIO_set_retry_special(b); 206 BIO_set_retry_special(b);
207 retry_reason=BIO_RR_SSL_X509_LOOKUP; 207 retry_reason=BIO_RR_SSL_X509_LOOKUP;
208 break; 208 break;
209 case SSL_ERROR_WANT_ACCEPT:
210 BIO_set_retry_special(b);
211 retry_reason=BIO_RR_ACCEPT;
212 break;
209 case SSL_ERROR_WANT_CONNECT: 213 case SSL_ERROR_WANT_CONNECT:
210 BIO_set_retry_special(b); 214 BIO_set_retry_special(b);
211 retry_reason=BIO_RR_CONNECT; 215 retry_reason=BIO_RR_CONNECT;
@@ -482,7 +486,9 @@ static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
482 { 486 {
483 case BIO_CTRL_SET_CALLBACK: 487 case BIO_CTRL_SET_CALLBACK:
484 { 488 {
485 SSL_set_info_callback(ssl,fp); 489 /* FIXME: setting this via a completely different prototype
490 seems like a crap idea */
491 SSL_set_info_callback(ssl,(void (*)(const SSL *,int,int))fp);
486 } 492 }
487 break; 493 break;
488 default: 494 default:
diff --git a/src/lib/libssl/src/ssl/install.com b/src/lib/libssl/src/ssl/install.com
index 5d20201e8a..7fc008f91a 100644
--- a/src/lib/libssl/src/ssl/install.com
+++ b/src/lib/libssl/src/ssl/install.com
@@ -38,7 +38,7 @@ $ IF F$PARSE("WRK_SSLVEXE:") .EQS. "" THEN -
38$ IF F$PARSE("WRK_SSLAEXE:") .EQS. "" THEN - 38$ IF F$PARSE("WRK_SSLAEXE:") .EQS. "" THEN -
39 CREATE/DIR/LOG WRK_SSLAEXE: 39 CREATE/DIR/LOG WRK_SSLAEXE:
40$ 40$
41$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h 41$ EXHEADER := ssl.h,ssl2.h,ssl3.h,ssl23.h,tls1.h,kssl.h
42$ E_EXE := ssl_task 42$ E_EXE := ssl_task
43$ LIBS := LIBSSL 43$ LIBS := LIBSSL
44$ 44$
diff --git a/src/lib/libssl/src/ssl/kssl.c b/src/lib/libssl/src/ssl/kssl.c
new file mode 100644
index 0000000000..d3c7be7581
--- /dev/null
+++ b/src/lib/libssl/src/ssl/kssl.c
@@ -0,0 +1,2195 @@
1/* ssl/kssl.c -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.
3 */
4/* ====================================================================
5 * Copyright (c) 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 * 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
59/* ssl/kssl.c -- Routines to support (& debug) Kerberos5 auth for openssl
60**
61** 19990701 VRS Started.
62** 200011?? Jeffrey Altman, Richard Levitte
63** Generalized for Heimdal, Newer MIT, & Win32.
64** Integrated into main OpenSSL 0.9.7 snapshots.
65** 20010413 Simon Wilkinson, VRS
66** Real RFC2712 KerberosWrapper replaces AP_REQ.
67*/
68
69#include <openssl/opensslconf.h>
70
71#define _XOPEN_SOURCE /* glibc2 needs this to declare strptime() */
72#include <time.h>
73#include <string.h>
74
75#include <openssl/ssl.h>
76#include <openssl/evp.h>
77#include <openssl/objects.h>
78#include <openssl/krb5_asn.h>
79
80#ifndef OPENSSL_NO_KRB5
81
82/*
83 * When OpenSSL is built on Windows, we do not want to require that
84 * the Kerberos DLLs be available in order for the OpenSSL DLLs to
85 * work. Therefore, all Kerberos routines are loaded at run time
86 * and we do not link to a .LIB file.
87 */
88
89#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
90/*
91 * The purpose of the following pre-processor statements is to provide
92 * compatibility with different releases of MIT Kerberos for Windows.
93 * All versions up to 1.2 used macros. But macros do not allow for
94 * a binary compatible interface for DLLs. Therefore, all macros are
95 * being replaced by function calls. The following code will allow
96 * an OpenSSL DLL built on Windows to work whether or not the macro
97 * or function form of the routines are utilized.
98 */
99#ifdef krb5_cc_get_principal
100#define NO_DEF_KRB5_CCACHE
101#undef krb5_cc_get_principal
102#endif
103#define krb5_cc_get_principal kssl_krb5_cc_get_principal
104
105#define krb5_free_data_contents kssl_krb5_free_data_contents
106#define krb5_free_context kssl_krb5_free_context
107#define krb5_auth_con_free kssl_krb5_auth_con_free
108#define krb5_free_principal kssl_krb5_free_principal
109#define krb5_mk_req_extended kssl_krb5_mk_req_extended
110#define krb5_get_credentials kssl_krb5_get_credentials
111#define krb5_cc_default kssl_krb5_cc_default
112#define krb5_sname_to_principal kssl_krb5_sname_to_principal
113#define krb5_init_context kssl_krb5_init_context
114#define krb5_free_ticket kssl_krb5_free_ticket
115#define krb5_rd_req kssl_krb5_rd_req
116#define krb5_kt_default kssl_krb5_kt_default
117#define krb5_kt_resolve kssl_krb5_kt_resolve
118/* macros in mit 1.2.2 and earlier; functions in mit 1.2.3 and greater */
119#ifndef krb5_kt_close
120#define krb5_kt_close kssl_krb5_kt_close
121#endif /* krb5_kt_close */
122#ifndef krb5_kt_get_entry
123#define krb5_kt_get_entry kssl_krb5_kt_get_entry
124#endif /* krb5_kt_get_entry */
125#define krb5_auth_con_init kssl_krb5_auth_con_init
126
127#define krb5_principal_compare kssl_krb5_principal_compare
128#define krb5_decrypt_tkt_part kssl_krb5_decrypt_tkt_part
129#define krb5_timeofday kssl_krb5_timeofday
130#define krb5_rc_default kssl_krb5_rc_default
131
132#ifdef krb5_rc_initialize
133#undef krb5_rc_initialize
134#endif
135#define krb5_rc_initialize kssl_krb5_rc_initialize
136
137#ifdef krb5_rc_get_lifespan
138#undef krb5_rc_get_lifespan
139#endif
140#define krb5_rc_get_lifespan kssl_krb5_rc_get_lifespan
141
142#ifdef krb5_rc_destroy
143#undef krb5_rc_destroy
144#endif
145#define krb5_rc_destroy kssl_krb5_rc_destroy
146
147#define valid_cksumtype kssl_valid_cksumtype
148#define krb5_checksum_size kssl_krb5_checksum_size
149#define krb5_kt_free_entry kssl_krb5_kt_free_entry
150#define krb5_auth_con_setrcache kssl_krb5_auth_con_setrcache
151#define krb5_auth_con_getrcache kssl_krb5_auth_con_getrcache
152#define krb5_get_server_rcache kssl_krb5_get_server_rcache
153
154/* Prototypes for built in stubs */
155void kssl_krb5_free_data_contents(krb5_context, krb5_data *);
156void kssl_krb5_free_principal(krb5_context, krb5_principal );
157krb5_error_code kssl_krb5_kt_resolve(krb5_context,
158 krb5_const char *,
159 krb5_keytab *);
160krb5_error_code kssl_krb5_kt_default(krb5_context,
161 krb5_keytab *);
162krb5_error_code kssl_krb5_free_ticket(krb5_context, krb5_ticket *);
163krb5_error_code kssl_krb5_rd_req(krb5_context, krb5_auth_context *,
164 krb5_const krb5_data *,
165 krb5_const_principal, krb5_keytab,
166 krb5_flags *,krb5_ticket **);
167
168krb5_boolean kssl_krb5_principal_compare(krb5_context, krb5_const_principal,
169 krb5_const_principal);
170krb5_error_code kssl_krb5_mk_req_extended(krb5_context,
171 krb5_auth_context *,
172 krb5_const krb5_flags,
173 krb5_data *,
174 krb5_creds *,
175 krb5_data * );
176krb5_error_code kssl_krb5_init_context(krb5_context *);
177void kssl_krb5_free_context(krb5_context);
178krb5_error_code kssl_krb5_cc_default(krb5_context,krb5_ccache *);
179krb5_error_code kssl_krb5_sname_to_principal(krb5_context,
180 krb5_const char *,
181 krb5_const char *,
182 krb5_int32,
183 krb5_principal *);
184krb5_error_code kssl_krb5_get_credentials(krb5_context,
185 krb5_const krb5_flags,
186 krb5_ccache,
187 krb5_creds *,
188 krb5_creds * *);
189krb5_error_code kssl_krb5_auth_con_init(krb5_context,
190 krb5_auth_context *);
191krb5_error_code kssl_krb5_cc_get_principal(krb5_context context,
192 krb5_ccache cache,
193 krb5_principal *principal);
194krb5_error_code kssl_krb5_auth_con_free(krb5_context,krb5_auth_context);
195size_t kssl_krb5_checksum_size(krb5_context context,krb5_cksumtype ctype);
196krb5_boolean kssl_valid_cksumtype(krb5_cksumtype ctype);
197krb5_error_code krb5_kt_free_entry(krb5_context,krb5_keytab_entry FAR * );
198krb5_error_code kssl_krb5_auth_con_setrcache(krb5_context,
199 krb5_auth_context,
200 krb5_rcache);
201krb5_error_code kssl_krb5_get_server_rcache(krb5_context,
202 krb5_const krb5_data *,
203 krb5_rcache *);
204krb5_error_code kssl_krb5_auth_con_getrcache(krb5_context,
205 krb5_auth_context,
206 krb5_rcache *);
207
208/* Function pointers (almost all Kerberos functions are _stdcall) */
209static void (_stdcall *p_krb5_free_data_contents)(krb5_context, krb5_data *)
210 =NULL;
211static void (_stdcall *p_krb5_free_principal)(krb5_context, krb5_principal )
212 =NULL;
213static krb5_error_code(_stdcall *p_krb5_kt_resolve)
214 (krb5_context, krb5_const char *, krb5_keytab *)=NULL;
215static krb5_error_code (_stdcall *p_krb5_kt_default)(krb5_context,
216 krb5_keytab *)=NULL;
217static krb5_error_code (_stdcall *p_krb5_free_ticket)(krb5_context,
218 krb5_ticket *)=NULL;
219static krb5_error_code (_stdcall *p_krb5_rd_req)(krb5_context,
220 krb5_auth_context *,
221 krb5_const krb5_data *,
222 krb5_const_principal,
223 krb5_keytab, krb5_flags *,
224 krb5_ticket **)=NULL;
225static krb5_error_code (_stdcall *p_krb5_mk_req_extended)
226 (krb5_context, krb5_auth_context *,
227 krb5_const krb5_flags, krb5_data *, krb5_creds *,
228 krb5_data * )=NULL;
229static krb5_error_code (_stdcall *p_krb5_init_context)(krb5_context *)=NULL;
230static void (_stdcall *p_krb5_free_context)(krb5_context)=NULL;
231static krb5_error_code (_stdcall *p_krb5_cc_default)(krb5_context,
232 krb5_ccache *)=NULL;
233static krb5_error_code (_stdcall *p_krb5_sname_to_principal)
234 (krb5_context, krb5_const char *, krb5_const char *,
235 krb5_int32, krb5_principal *)=NULL;
236static krb5_error_code (_stdcall *p_krb5_get_credentials)
237 (krb5_context, krb5_const krb5_flags, krb5_ccache,
238 krb5_creds *, krb5_creds **)=NULL;
239static krb5_error_code (_stdcall *p_krb5_auth_con_init)
240 (krb5_context, krb5_auth_context *)=NULL;
241static krb5_error_code (_stdcall *p_krb5_cc_get_principal)
242 (krb5_context context, krb5_ccache cache,
243 krb5_principal *principal)=NULL;
244static krb5_error_code (_stdcall *p_krb5_auth_con_free)
245 (krb5_context, krb5_auth_context)=NULL;
246static krb5_error_code (_stdcall *p_krb5_decrypt_tkt_part)
247 (krb5_context, krb5_const krb5_keyblock *,
248 krb5_ticket *)=NULL;
249static krb5_error_code (_stdcall *p_krb5_timeofday)
250 (krb5_context context, krb5_int32 *timeret)=NULL;
251static krb5_error_code (_stdcall *p_krb5_rc_default)
252 (krb5_context context, krb5_rcache *rc)=NULL;
253static krb5_error_code (_stdcall *p_krb5_rc_initialize)
254 (krb5_context context, krb5_rcache rc,
255 krb5_deltat lifespan)=NULL;
256static krb5_error_code (_stdcall *p_krb5_rc_get_lifespan)
257 (krb5_context context, krb5_rcache rc,
258 krb5_deltat *lifespan)=NULL;
259static krb5_error_code (_stdcall *p_krb5_rc_destroy)
260 (krb5_context context, krb5_rcache rc)=NULL;
261static krb5_boolean (_stdcall *p_krb5_principal_compare)
262 (krb5_context, krb5_const_principal, krb5_const_principal)=NULL;
263static size_t (_stdcall *p_krb5_checksum_size)(krb5_context context,krb5_cksumtype ctype)=NULL;
264static krb5_boolean (_stdcall *p_valid_cksumtype)(krb5_cksumtype ctype)=NULL;
265static krb5_error_code (_stdcall *p_krb5_kt_free_entry)
266 (krb5_context,krb5_keytab_entry * )=NULL;
267static krb5_error_code (_stdcall * p_krb5_auth_con_setrcache)(krb5_context,
268 krb5_auth_context,
269 krb5_rcache)=NULL;
270static krb5_error_code (_stdcall * p_krb5_get_server_rcache)(krb5_context,
271 krb5_const krb5_data *,
272 krb5_rcache *)=NULL;
273static krb5_error_code (* p_krb5_auth_con_getrcache)(krb5_context,
274 krb5_auth_context,
275 krb5_rcache *)=NULL;
276static krb5_error_code (_stdcall * p_krb5_kt_close)(krb5_context context,
277 krb5_keytab keytab)=NULL;
278static krb5_error_code (_stdcall * p_krb5_kt_get_entry)(krb5_context context,
279 krb5_keytab keytab,
280 krb5_const_principal principal, krb5_kvno vno,
281 krb5_enctype enctype, krb5_keytab_entry *entry)=NULL;
282static int krb5_loaded = 0; /* only attempt to initialize func ptrs once */
283
284/* Function to Load the Kerberos 5 DLL and initialize function pointers */
285void
286load_krb5_dll(void)
287 {
288 HANDLE hKRB5_32;
289
290 krb5_loaded++;
291 hKRB5_32 = LoadLibrary("KRB5_32");
292 if (!hKRB5_32)
293 return;
294
295 (FARPROC) p_krb5_free_data_contents =
296 GetProcAddress( hKRB5_32, "krb5_free_data_contents" );
297 (FARPROC) p_krb5_free_context =
298 GetProcAddress( hKRB5_32, "krb5_free_context" );
299 (FARPROC) p_krb5_auth_con_free =
300 GetProcAddress( hKRB5_32, "krb5_auth_con_free" );
301 (FARPROC) p_krb5_free_principal =
302 GetProcAddress( hKRB5_32, "krb5_free_principal" );
303 (FARPROC) p_krb5_mk_req_extended =
304 GetProcAddress( hKRB5_32, "krb5_mk_req_extended" );
305 (FARPROC) p_krb5_get_credentials =
306 GetProcAddress( hKRB5_32, "krb5_get_credentials" );
307 (FARPROC) p_krb5_cc_get_principal =
308 GetProcAddress( hKRB5_32, "krb5_cc_get_principal" );
309 (FARPROC) p_krb5_cc_default =
310 GetProcAddress( hKRB5_32, "krb5_cc_default" );
311 (FARPROC) p_krb5_sname_to_principal =
312 GetProcAddress( hKRB5_32, "krb5_sname_to_principal" );
313 (FARPROC) p_krb5_init_context =
314 GetProcAddress( hKRB5_32, "krb5_init_context" );
315 (FARPROC) p_krb5_free_ticket =
316 GetProcAddress( hKRB5_32, "krb5_free_ticket" );
317 (FARPROC) p_krb5_rd_req =
318 GetProcAddress( hKRB5_32, "krb5_rd_req" );
319 (FARPROC) p_krb5_principal_compare =
320 GetProcAddress( hKRB5_32, "krb5_principal_compare" );
321 (FARPROC) p_krb5_decrypt_tkt_part =
322 GetProcAddress( hKRB5_32, "krb5_decrypt_tkt_part" );
323 (FARPROC) p_krb5_timeofday =
324 GetProcAddress( hKRB5_32, "krb5_timeofday" );
325 (FARPROC) p_krb5_rc_default =
326 GetProcAddress( hKRB5_32, "krb5_rc_default" );
327 (FARPROC) p_krb5_rc_initialize =
328 GetProcAddress( hKRB5_32, "krb5_rc_initialize" );
329 (FARPROC) p_krb5_rc_get_lifespan =
330 GetProcAddress( hKRB5_32, "krb5_rc_get_lifespan" );
331 (FARPROC) p_krb5_rc_destroy =
332 GetProcAddress( hKRB5_32, "krb5_rc_destroy" );
333 (FARPROC) p_krb5_kt_default =
334 GetProcAddress( hKRB5_32, "krb5_kt_default" );
335 (FARPROC) p_krb5_kt_resolve =
336 GetProcAddress( hKRB5_32, "krb5_kt_resolve" );
337 (FARPROC) p_krb5_auth_con_init =
338 GetProcAddress( hKRB5_32, "krb5_auth_con_init" );
339 (FARPROC) p_valid_cksumtype =
340 GetProcAddress( hKRB5_32, "valid_cksumtype" );
341 (FARPROC) p_krb5_checksum_size =
342 GetProcAddress( hKRB5_32, "krb5_checksum_size" );
343 (FARPROC) p_krb5_kt_free_entry =
344 GetProcAddress( hKRB5_32, "krb5_kt_free_entry" );
345 (FARPROC) p_krb5_auth_con_setrcache =
346 GetProcAddress( hKRB5_32, "krb5_auth_con_setrcache" );
347 (FARPROC) p_krb5_get_server_rcache =
348 GetProcAddress( hKRB5_32, "krb5_get_server_rcache" );
349 (FARPROC) p_krb5_auth_con_getrcache =
350 GetProcAddress( hKRB5_32, "krb5_auth_con_getrcache" );
351 (FARPROC) p_krb5_kt_close =
352 GetProcAddress( hKRB5_32, "krb5_kt_close" );
353 (FARPROC) p_krb5_kt_get_entry =
354 GetProcAddress( hKRB5_32, "krb5_kt_get_entry" );
355 }
356
357/* Stubs for each function to be dynamicly loaded */
358void
359kssl_krb5_free_data_contents(krb5_context CO, krb5_data * data)
360 {
361 if (!krb5_loaded)
362 load_krb5_dll();
363
364 if ( p_krb5_free_data_contents )
365 p_krb5_free_data_contents(CO,data);
366 }
367
368krb5_error_code
369kssl_krb5_mk_req_extended (krb5_context CO,
370 krb5_auth_context * pACO,
371 krb5_const krb5_flags F,
372 krb5_data * pD1,
373 krb5_creds * pC,
374 krb5_data * pD2)
375 {
376 if (!krb5_loaded)
377 load_krb5_dll();
378
379 if ( p_krb5_mk_req_extended )
380 return(p_krb5_mk_req_extended(CO,pACO,F,pD1,pC,pD2));
381 else
382 return KRB5KRB_ERR_GENERIC;
383 }
384krb5_error_code
385kssl_krb5_auth_con_init(krb5_context CO,
386 krb5_auth_context * pACO)
387 {
388 if (!krb5_loaded)
389 load_krb5_dll();
390
391 if ( p_krb5_auth_con_init )
392 return(p_krb5_auth_con_init(CO,pACO));
393 else
394 return KRB5KRB_ERR_GENERIC;
395 }
396krb5_error_code
397kssl_krb5_auth_con_free (krb5_context CO,
398 krb5_auth_context ACO)
399 {
400 if (!krb5_loaded)
401 load_krb5_dll();
402
403 if ( p_krb5_auth_con_free )
404 return(p_krb5_auth_con_free(CO,ACO));
405 else
406 return KRB5KRB_ERR_GENERIC;
407 }
408krb5_error_code
409kssl_krb5_get_credentials(krb5_context CO,
410 krb5_const krb5_flags F,
411 krb5_ccache CC,
412 krb5_creds * pCR,
413 krb5_creds ** ppCR)
414 {
415 if (!krb5_loaded)
416 load_krb5_dll();
417
418 if ( p_krb5_get_credentials )
419 return(p_krb5_get_credentials(CO,F,CC,pCR,ppCR));
420 else
421 return KRB5KRB_ERR_GENERIC;
422 }
423krb5_error_code
424kssl_krb5_sname_to_principal(krb5_context CO,
425 krb5_const char * pC1,
426 krb5_const char * pC2,
427 krb5_int32 I,
428 krb5_principal * pPR)
429 {
430 if (!krb5_loaded)
431 load_krb5_dll();
432
433 if ( p_krb5_sname_to_principal )
434 return(p_krb5_sname_to_principal(CO,pC1,pC2,I,pPR));
435 else
436 return KRB5KRB_ERR_GENERIC;
437 }
438
439krb5_error_code
440kssl_krb5_cc_default(krb5_context CO,
441 krb5_ccache * pCC)
442 {
443 if (!krb5_loaded)
444 load_krb5_dll();
445
446 if ( p_krb5_cc_default )
447 return(p_krb5_cc_default(CO,pCC));
448 else
449 return KRB5KRB_ERR_GENERIC;
450 }
451
452krb5_error_code
453kssl_krb5_init_context(krb5_context * pCO)
454 {
455 if (!krb5_loaded)
456 load_krb5_dll();
457
458 if ( p_krb5_init_context )
459 return(p_krb5_init_context(pCO));
460 else
461 return KRB5KRB_ERR_GENERIC;
462 }
463
464void
465kssl_krb5_free_context(krb5_context CO)
466 {
467 if (!krb5_loaded)
468 load_krb5_dll();
469
470 if ( p_krb5_free_context )
471 p_krb5_free_context(CO);
472 }
473
474void
475kssl_krb5_free_principal(krb5_context c, krb5_principal p)
476 {
477 if (!krb5_loaded)
478 load_krb5_dll();
479
480 if ( p_krb5_free_principal )
481 p_krb5_free_principal(c,p);
482 }
483
484krb5_error_code
485kssl_krb5_kt_resolve(krb5_context con,
486 krb5_const char * sz,
487 krb5_keytab * kt)
488 {
489 if (!krb5_loaded)
490 load_krb5_dll();
491
492 if ( p_krb5_kt_resolve )
493 return(p_krb5_kt_resolve(con,sz,kt));
494 else
495 return KRB5KRB_ERR_GENERIC;
496 }
497
498krb5_error_code
499kssl_krb5_kt_default(krb5_context con,
500 krb5_keytab * kt)
501 {
502 if (!krb5_loaded)
503 load_krb5_dll();
504
505 if ( p_krb5_kt_default )
506 return(p_krb5_kt_default(con,kt));
507 else
508 return KRB5KRB_ERR_GENERIC;
509 }
510
511krb5_error_code
512kssl_krb5_free_ticket(krb5_context con,
513 krb5_ticket * kt)
514 {
515 if (!krb5_loaded)
516 load_krb5_dll();
517
518 if ( p_krb5_free_ticket )
519 return(p_krb5_free_ticket(con,kt));
520 else
521 return KRB5KRB_ERR_GENERIC;
522 }
523
524krb5_error_code
525kssl_krb5_rd_req(krb5_context con, krb5_auth_context * pacon,
526 krb5_const krb5_data * data,
527 krb5_const_principal princ, krb5_keytab keytab,
528 krb5_flags * flags, krb5_ticket ** pptkt)
529 {
530 if (!krb5_loaded)
531 load_krb5_dll();
532
533 if ( p_krb5_rd_req )
534 return(p_krb5_rd_req(con,pacon,data,princ,keytab,flags,pptkt));
535 else
536 return KRB5KRB_ERR_GENERIC;
537 }
538
539krb5_boolean
540krb5_principal_compare(krb5_context con, krb5_const_principal princ1,
541 krb5_const_principal princ2)
542 {
543 if (!krb5_loaded)
544 load_krb5_dll();
545
546 if ( p_krb5_principal_compare )
547 return(p_krb5_principal_compare(con,princ1,princ2));
548 else
549 return KRB5KRB_ERR_GENERIC;
550 }
551
552krb5_error_code
553krb5_decrypt_tkt_part(krb5_context con, krb5_const krb5_keyblock *keys,
554 krb5_ticket *ticket)
555 {
556 if (!krb5_loaded)
557 load_krb5_dll();
558
559 if ( p_krb5_decrypt_tkt_part )
560 return(p_krb5_decrypt_tkt_part(con,keys,ticket));
561 else
562 return KRB5KRB_ERR_GENERIC;
563 }
564
565krb5_error_code
566krb5_timeofday(krb5_context con, krb5_int32 *timeret)
567 {
568 if (!krb5_loaded)
569 load_krb5_dll();
570
571 if ( p_krb5_timeofday )
572 return(p_krb5_timeofday(con,timeret));
573 else
574 return KRB5KRB_ERR_GENERIC;
575 }
576
577krb5_error_code
578krb5_rc_default(krb5_context con, krb5_rcache *rc)
579 {
580 if (!krb5_loaded)
581 load_krb5_dll();
582
583 if ( p_krb5_rc_default )
584 return(p_krb5_rc_default(con,rc));
585 else
586 return KRB5KRB_ERR_GENERIC;
587 }
588
589krb5_error_code
590krb5_rc_initialize(krb5_context con, krb5_rcache rc, krb5_deltat lifespan)
591 {
592 if (!krb5_loaded)
593 load_krb5_dll();
594
595 if ( p_krb5_rc_initialize )
596 return(p_krb5_rc_initialize(con, rc, lifespan));
597 else
598 return KRB5KRB_ERR_GENERIC;
599 }
600
601krb5_error_code
602krb5_rc_get_lifespan(krb5_context con, krb5_rcache rc, krb5_deltat *lifespanp)
603 {
604 if (!krb5_loaded)
605 load_krb5_dll();
606
607 if ( p_krb5_rc_get_lifespan )
608 return(p_krb5_rc_get_lifespan(con, rc, lifespanp));
609 else
610 return KRB5KRB_ERR_GENERIC;
611 }
612
613krb5_error_code
614krb5_rc_destroy(krb5_context con, krb5_rcache rc)
615 {
616 if (!krb5_loaded)
617 load_krb5_dll();
618
619 if ( p_krb5_rc_destroy )
620 return(p_krb5_rc_destroy(con, rc));
621 else
622 return KRB5KRB_ERR_GENERIC;
623 }
624
625size_t
626krb5_checksum_size(krb5_context context,krb5_cksumtype ctype)
627 {
628 if (!krb5_loaded)
629 load_krb5_dll();
630
631 if ( p_krb5_checksum_size )
632 return(p_krb5_checksum_size(context, ctype));
633 else
634 return KRB5KRB_ERR_GENERIC;
635 }
636
637krb5_boolean
638valid_cksumtype(krb5_cksumtype ctype)
639 {
640 if (!krb5_loaded)
641 load_krb5_dll();
642
643 if ( p_valid_cksumtype )
644 return(p_valid_cksumtype(ctype));
645 else
646 return KRB5KRB_ERR_GENERIC;
647 }
648
649krb5_error_code
650krb5_kt_free_entry(krb5_context con,krb5_keytab_entry * entry)
651 {
652 if (!krb5_loaded)
653 load_krb5_dll();
654
655 if ( p_krb5_kt_free_entry )
656 return(p_krb5_kt_free_entry(con,entry));
657 else
658 return KRB5KRB_ERR_GENERIC;
659 }
660
661/* Structure definitions */
662#ifndef NO_DEF_KRB5_CCACHE
663#ifndef krb5_x
664#define krb5_x(ptr,args) ((ptr)?((*(ptr)) args):(abort(),1))
665#define krb5_xc(ptr,args) ((ptr)?((*(ptr)) args):(abort(),(char*)0))
666#endif
667
668typedef krb5_pointer krb5_cc_cursor; /* cursor for sequential lookup */
669
670typedef struct _krb5_ccache
671 {
672 krb5_magic magic;
673 struct _krb5_cc_ops FAR *ops;
674 krb5_pointer data;
675 } *krb5_ccache;
676
677typedef struct _krb5_cc_ops
678 {
679 krb5_magic magic;
680 char *prefix;
681 char * (KRB5_CALLCONV *get_name)
682 (krb5_context, krb5_ccache);
683 krb5_error_code (KRB5_CALLCONV *resolve)
684 (krb5_context, krb5_ccache *, const char *);
685 krb5_error_code (KRB5_CALLCONV *gen_new)
686 (krb5_context, krb5_ccache *);
687 krb5_error_code (KRB5_CALLCONV *init)
688 (krb5_context, krb5_ccache, krb5_principal);
689 krb5_error_code (KRB5_CALLCONV *destroy)
690 (krb5_context, krb5_ccache);
691 krb5_error_code (KRB5_CALLCONV *close)
692 (krb5_context, krb5_ccache);
693 krb5_error_code (KRB5_CALLCONV *store)
694 (krb5_context, krb5_ccache, krb5_creds *);
695 krb5_error_code (KRB5_CALLCONV *retrieve)
696 (krb5_context, krb5_ccache,
697 krb5_flags, krb5_creds *, krb5_creds *);
698 krb5_error_code (KRB5_CALLCONV *get_princ)
699 (krb5_context, krb5_ccache, krb5_principal *);
700 krb5_error_code (KRB5_CALLCONV *get_first)
701 (krb5_context, krb5_ccache, krb5_cc_cursor *);
702 krb5_error_code (KRB5_CALLCONV *get_next)
703 (krb5_context, krb5_ccache,
704 krb5_cc_cursor *, krb5_creds *);
705 krb5_error_code (KRB5_CALLCONV *end_get)
706 (krb5_context, krb5_ccache, krb5_cc_cursor *);
707 krb5_error_code (KRB5_CALLCONV *remove_cred)
708 (krb5_context, krb5_ccache,
709 krb5_flags, krb5_creds *);
710 krb5_error_code (KRB5_CALLCONV *set_flags)
711 (krb5_context, krb5_ccache, krb5_flags);
712 } krb5_cc_ops;
713#endif /* NO_DEF_KRB5_CCACHE */
714
715krb5_error_code
716kssl_krb5_cc_get_principal
717 (krb5_context context, krb5_ccache cache,
718 krb5_principal *principal)
719 {
720 if ( p_krb5_cc_get_principal )
721 return(p_krb5_cc_get_principal(context,cache,principal));
722 else
723 return(krb5_x
724 ((cache)->ops->get_princ,(context, cache, principal)));
725 }
726
727krb5_error_code
728kssl_krb5_auth_con_setrcache(krb5_context con, krb5_auth_context acon,
729 krb5_rcache rcache)
730 {
731 if ( p_krb5_auth_con_setrcache )
732 return(p_krb5_auth_con_setrcache(con,acon,rcache));
733 else
734 return KRB5KRB_ERR_GENERIC;
735 }
736
737krb5_error_code
738kssl_krb5_get_server_rcache(krb5_context con, krb5_const krb5_data * data,
739 krb5_rcache * rcache)
740 {
741 if ( p_krb5_get_server_rcache )
742 return(p_krb5_get_server_rcache(con,data,rcache));
743 else
744 return KRB5KRB_ERR_GENERIC;
745 }
746
747krb5_error_code
748kssl_krb5_auth_con_getrcache(krb5_context con, krb5_auth_context acon,
749 krb5_rcache * prcache)
750 {
751 if ( p_krb5_auth_con_getrcache )
752 return(p_krb5_auth_con_getrcache(con,acon, prcache));
753 else
754 return KRB5KRB_ERR_GENERIC;
755 }
756
757krb5_error_code
758kssl_krb5_kt_close(krb5_context context, krb5_keytab keytab)
759 {
760 if ( p_krb5_kt_close )
761 return(p_krb5_kt_close(context,keytab));
762 else
763 return KRB5KRB_ERR_GENERIC;
764 }
765
766krb5_error_code
767kssl_krb5_kt_get_entry(krb5_context context, krb5_keytab keytab,
768 krb5_const_principal principal, krb5_kvno vno,
769 krb5_enctype enctype, krb5_keytab_entry *entry)
770 {
771 if ( p_krb5_kt_get_entry )
772 return(p_krb5_kt_get_entry(context,keytab,principal,vno,enctype,entry));
773 else
774 return KRB5KRB_ERR_GENERIC;
775 }
776#endif /* OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32 */
777
778char
779*kstring(char *string)
780 {
781 static char *null = "[NULL]";
782
783 return ((string == NULL)? null: string);
784 }
785
786#define MAXKNUM 255
787char
788*knumber(int len, krb5_octet *contents)
789 {
790 static char buf[MAXKNUM+1];
791 int i;
792
793 BIO_snprintf(buf, MAXKNUM, "[%d] ", len);
794
795 for (i=0; i < len && MAXKNUM > strlen(buf)+3; i++)
796 {
797 BIO_snprintf(&buf[strlen(buf)], 3, "%02x", contents[i]);
798 }
799
800 return (buf);
801 }
802
803
804/* Given KRB5 enctype (basically DES or 3DES),
805** return closest match openssl EVP_ encryption algorithm.
806** Return NULL for unknown or problematic (krb5_dk_encrypt) enctypes.
807** Assume ENCTYPE_*_RAW (krb5_raw_encrypt) are OK.
808*/
809const EVP_CIPHER *
810kssl_map_enc(krb5_enctype enctype)
811 {
812 switch (enctype)
813 {
814 case ENCTYPE_DES_HMAC_SHA1: /* EVP_des_cbc(); */
815 case ENCTYPE_DES_CBC_CRC:
816 case ENCTYPE_DES_CBC_MD4:
817 case ENCTYPE_DES_CBC_MD5:
818 case ENCTYPE_DES_CBC_RAW:
819 return EVP_des_cbc();
820 break;
821 case ENCTYPE_DES3_CBC_SHA1: /* EVP_des_ede3_cbc(); */
822 case ENCTYPE_DES3_CBC_SHA:
823 case ENCTYPE_DES3_CBC_RAW:
824 return EVP_des_ede3_cbc();
825 break;
826 default: return NULL;
827 break;
828 }
829 }
830
831
832/* Return true:1 if p "looks like" the start of the real authenticator
833** described in kssl_skip_confound() below. The ASN.1 pattern is
834** "62 xx 30 yy" (APPLICATION-2, SEQUENCE), where xx-yy =~ 2, and
835** xx and yy are possibly multi-byte length fields.
836*/
837int kssl_test_confound(unsigned char *p)
838 {
839 int len = 2;
840 int xx = 0, yy = 0;
841
842 if (*p++ != 0x62) return 0;
843 if (*p > 0x82) return 0;
844 switch(*p) {
845 case 0x82: p++; xx = (*p++ << 8); xx += *p++; break;
846 case 0x81: p++; xx = *p++; break;
847 case 0x80: return 0;
848 default: xx = *p++; break;
849 }
850 if (*p++ != 0x30) return 0;
851 if (*p > 0x82) return 0;
852 switch(*p) {
853 case 0x82: p++; len+=2; yy = (*p++ << 8); yy += *p++; break;
854 case 0x81: p++; len++; yy = *p++; break;
855 case 0x80: return 0;
856 default: yy = *p++; break;
857 }
858
859 return (xx - len == yy)? 1: 0;
860 }
861
862/* Allocate, fill, and return cksumlens array of checksum lengths.
863** This array holds just the unique elements from the krb5_cksumarray[].
864** array[n] == 0 signals end of data.
865**
866** The krb5_cksumarray[] was an internal variable that has since been
867** replaced by a more general method for storing the data. It should
868** not be used. Instead we use real API calls and make a guess for
869** what the highest assigned CKSUMTYPE_ constant is. As of 1.2.2
870** it is 0x000c (CKSUMTYPE_HMAC_SHA1_DES3). So we will use 0x0010.
871*/
872size_t *populate_cksumlens(void)
873 {
874 int i, j, n;
875 static size_t *cklens = NULL;
876
877#ifdef KRB5_MIT_OLD11
878 n = krb5_max_cksum;
879#else
880 n = 0x0010;
881#endif /* KRB5_MIT_OLD11 */
882
883#ifdef KRB5CHECKAUTH
884 if (!cklens && !(cklens = (size_t *) calloc(sizeof(int),n+1))) return NULL;
885
886 for (i=0; i < n; i++) {
887 if (!valid_cksumtype(i)) continue; /* array has holes */
888 for (j=0; j < n; j++) {
889 if (cklens[j] == 0) {
890 cklens[j] = krb5_checksum_size(NULL,i);
891 break; /* krb5 elem was new: add */
892 }
893 if (cklens[j] == krb5_checksum_size(NULL,i)) {
894 break; /* ignore duplicate elements */
895 }
896 }
897 }
898#endif /* KRB5CHECKAUTH */
899
900 return cklens;
901 }
902
903/* Return pointer to start of real authenticator within authenticator, or
904** return NULL on error.
905** Decrypted authenticator looks like this:
906** [0 or 8 byte confounder] [4-24 byte checksum] [real authent'r]
907** This hackery wouldn't be necessary if MIT KRB5 1.0.6 had the
908** krb5_auth_con_getcksumtype() function advertised in its krb5.h.
909*/
910unsigned char *kssl_skip_confound(krb5_enctype etype, unsigned char *a)
911 {
912 int i, conlen;
913 size_t cklen;
914 static size_t *cksumlens = NULL;
915 unsigned char *test_auth;
916
917 conlen = (etype)? 8: 0;
918
919 if (!cksumlens && !(cksumlens = populate_cksumlens())) return NULL;
920 for (i=0; (cklen = cksumlens[i]) != 0; i++)
921 {
922 test_auth = a + conlen + cklen;
923 if (kssl_test_confound(test_auth)) return test_auth;
924 }
925
926 return NULL;
927 }
928
929
930/* Set kssl_err error info when reason text is a simple string
931** kssl_err = struct { int reason; char text[KSSL_ERR_MAX+1]; }
932*/
933void
934kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text)
935 {
936 if (kssl_err == NULL) return;
937
938 kssl_err->reason = reason;
939 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX, text);
940 return;
941 }
942
943
944/* Display contents of krb5_data struct, for debugging
945*/
946void
947print_krb5_data(char *label, krb5_data *kdata)
948 {
949 int i;
950
951 printf("%s[%d] ", label, kdata->length);
952 for (i=0; i < kdata->length; i++)
953 {
954 if (0 && isprint((int) kdata->data[i]))
955 printf( "%c ", kdata->data[i]);
956 else
957 printf( "%02x ", (unsigned char) kdata->data[i]);
958 }
959 printf("\n");
960 }
961
962
963/* Display contents of krb5_authdata struct, for debugging
964*/
965void
966print_krb5_authdata(char *label, krb5_authdata **adata)
967 {
968 if (adata == NULL)
969 {
970 printf("%s, authdata==0\n", label);
971 return;
972 }
973 printf("%s [%p]\n", label, adata);
974#if 0
975 {
976 int i;
977 printf("%s[at%d:%d] ", label, adata->ad_type, adata->length);
978 for (i=0; i < adata->length; i++)
979 {
980 printf((isprint(adata->contents[i]))? "%c ": "%02x",
981 adata->contents[i]);
982 }
983 printf("\n");
984 }
985#endif
986 }
987
988
989/* Display contents of krb5_keyblock struct, for debugging
990*/
991void
992print_krb5_keyblock(char *label, krb5_keyblock *keyblk)
993 {
994 int i;
995
996 if (keyblk == NULL)
997 {
998 printf("%s, keyblk==0\n", label);
999 return;
1000 }
1001#ifdef KRB5_HEIMDAL
1002 printf("%s\n\t[et%d:%d]: ", label, keyblk->keytype,
1003 keyblk->keyvalue->length);
1004 for (i=0; i < keyblk->keyvalue->length; i++)
1005 {
1006 printf("%02x",(unsigned char *)(keyblk->keyvalue->contents)[i]);
1007 }
1008 printf("\n");
1009#else
1010 printf("%s\n\t[et%d:%d]: ", label, keyblk->enctype, keyblk->length);
1011 for (i=0; i < keyblk->length; i++)
1012 {
1013 printf("%02x",keyblk->contents[i]);
1014 }
1015 printf("\n");
1016#endif
1017 }
1018
1019
1020/* Display contents of krb5_principal_data struct, for debugging
1021** (krb5_principal is typedef'd == krb5_principal_data *)
1022*/
1023void
1024print_krb5_princ(char *label, krb5_principal_data *princ)
1025 {
1026 int i, ui, uj;
1027
1028 printf("%s principal Realm: ", label);
1029 if (princ == NULL) return;
1030 for (ui=0; ui < princ->realm.length; ui++) putchar(princ->realm.data[ui]);
1031 printf(" (nametype %d) has %d strings:\n", princ->type,princ->length);
1032 for (i=0; i < princ->length; i++)
1033 {
1034 printf("\t%d [%d]: ", i, princ->data[i].length);
1035 for (uj=0; uj < princ->data[i].length; uj++) {
1036 putchar(princ->data[i].data[uj]);
1037 }
1038 printf("\n");
1039 }
1040 return;
1041 }
1042
1043
1044/* Given krb5 service (typically "kssl") and hostname in kssl_ctx,
1045** Return encrypted Kerberos ticket for service @ hostname.
1046** If authenp is non-NULL, also return encrypted authenticator,
1047** whose data should be freed by caller.
1048** (Originally was: Create Kerberos AP_REQ message for SSL Client.)
1049**
1050** 19990628 VRS Started; Returns Kerberos AP_REQ message.
1051** 20010409 VRS Modified for RFC2712; Returns enc tkt.
1052** 20010606 VRS May also return optional authenticator.
1053*/
1054krb5_error_code
1055kssl_cget_tkt( /* UPDATE */ KSSL_CTX *kssl_ctx,
1056 /* OUT */ krb5_data **enc_ticketp,
1057 /* UPDATE */ krb5_data *authenp,
1058 /* OUT */ KSSL_ERR *kssl_err)
1059 {
1060 krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC;
1061 krb5_context krb5context = NULL;
1062 krb5_auth_context krb5auth_context = NULL;
1063 krb5_ccache krb5ccdef = NULL;
1064 krb5_creds krb5creds, *krb5credsp = NULL;
1065 krb5_data krb5_app_req;
1066
1067 kssl_err_set(kssl_err, 0, "");
1068 memset((char *)&krb5creds, 0, sizeof(krb5creds));
1069
1070 if (!kssl_ctx)
1071 {
1072 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1073 "No kssl_ctx defined.\n");
1074 goto err;
1075 }
1076 else if (!kssl_ctx->service_host)
1077 {
1078 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1079 "kssl_ctx service_host undefined.\n");
1080 goto err;
1081 }
1082
1083 if ((krb5rc = krb5_init_context(&krb5context)) != 0)
1084 {
1085 BIO_snprintf(kssl_err->text,KSSL_ERR_MAX,
1086 "krb5_init_context() fails: %d\n", krb5rc);
1087 kssl_err->reason = SSL_R_KRB5_C_INIT;
1088 goto err;
1089 }
1090
1091 if ((krb5rc = krb5_sname_to_principal(krb5context,
1092 kssl_ctx->service_host,
1093 (kssl_ctx->service_name)? kssl_ctx->service_name: KRB5SVC,
1094 KRB5_NT_SRV_HST, &krb5creds.server)) != 0)
1095 {
1096 BIO_snprintf(kssl_err->text,KSSL_ERR_MAX,
1097 "krb5_sname_to_principal() fails for %s/%s\n",
1098 kssl_ctx->service_host,
1099 (kssl_ctx->service_name)? kssl_ctx->service_name:
1100 KRB5SVC);
1101 kssl_err->reason = SSL_R_KRB5_C_INIT;
1102 goto err;
1103 }
1104
1105 if ((krb5rc = krb5_cc_default(krb5context, &krb5ccdef)) != 0)
1106 {
1107 kssl_err_set(kssl_err, SSL_R_KRB5_C_CC_PRINC,
1108 "krb5_cc_default fails.\n");
1109 goto err;
1110 }
1111
1112 if ((krb5rc = krb5_cc_get_principal(krb5context, krb5ccdef,
1113 &krb5creds.client)) != 0)
1114 {
1115 kssl_err_set(kssl_err, SSL_R_KRB5_C_CC_PRINC,
1116 "krb5_cc_get_principal() fails.\n");
1117 goto err;
1118 }
1119
1120 if ((krb5rc = krb5_get_credentials(krb5context, 0, krb5ccdef,
1121 &krb5creds, &krb5credsp)) != 0)
1122 {
1123 kssl_err_set(kssl_err, SSL_R_KRB5_C_GET_CRED,
1124 "krb5_get_credentials() fails.\n");
1125 goto err;
1126 }
1127
1128 *enc_ticketp = &krb5credsp->ticket;
1129#ifdef KRB5_HEIMDAL
1130 kssl_ctx->enctype = krb5credsp->session.keytype;
1131#else
1132 kssl_ctx->enctype = krb5credsp->keyblock.enctype;
1133#endif
1134
1135 krb5rc = KRB5KRB_ERR_GENERIC;
1136 /* caller should free data of krb5_app_req */
1137 /* 20010406 VRS deleted for real KerberosWrapper
1138 ** 20010605 VRS reinstated to offer Authenticator to KerberosWrapper
1139 */
1140 krb5_app_req.length = 0;
1141 if (authenp)
1142 {
1143 krb5_data krb5in_data;
1144 unsigned char *p;
1145 long arlen;
1146 KRB5_APREQBODY *ap_req;
1147
1148 authenp->length = 0;
1149 krb5in_data.data = NULL;
1150 krb5in_data.length = 0;
1151 if ((krb5rc = krb5_mk_req_extended(krb5context,
1152 &krb5auth_context, 0, &krb5in_data, krb5credsp,
1153 &krb5_app_req)) != 0)
1154 {
1155 kssl_err_set(kssl_err, SSL_R_KRB5_C_MK_REQ,
1156 "krb5_mk_req_extended() fails.\n");
1157 goto err;
1158 }
1159
1160 arlen = krb5_app_req.length;
1161 p = (unsigned char *)krb5_app_req.data;
1162 ap_req = (KRB5_APREQBODY *) d2i_KRB5_APREQ(NULL, &p, arlen);
1163 if (ap_req)
1164 {
1165 authenp->length = i2d_KRB5_ENCDATA(
1166 ap_req->authenticator, NULL);
1167 if (authenp->length &&
1168 (authenp->data = malloc(authenp->length)))
1169 {
1170 unsigned char *adp = (unsigned char *)authenp->data;
1171 authenp->length = i2d_KRB5_ENCDATA(
1172 ap_req->authenticator, &adp);
1173 }
1174 }
1175
1176 if (ap_req) KRB5_APREQ_free((KRB5_APREQ *) ap_req);
1177 if (krb5_app_req.length)
1178 kssl_krb5_free_data_contents(krb5context,&krb5_app_req);
1179 }
1180#ifdef KRB5_HEIMDAL
1181 if (kssl_ctx_setkey(kssl_ctx, &krb5credsp->session))
1182 {
1183 kssl_err_set(kssl_err, SSL_R_KRB5_C_INIT,
1184 "kssl_ctx_setkey() fails.\n");
1185 }
1186#else
1187 if (kssl_ctx_setkey(kssl_ctx, &krb5credsp->keyblock))
1188 {
1189 kssl_err_set(kssl_err, SSL_R_KRB5_C_INIT,
1190 "kssl_ctx_setkey() fails.\n");
1191 }
1192#endif
1193 else krb5rc = 0;
1194
1195 err:
1196#ifdef KSSL_DEBUG
1197 kssl_ctx_show(kssl_ctx);
1198#endif /* KSSL_DEBUG */
1199
1200 if (krb5creds.client) krb5_free_principal(krb5context,
1201 krb5creds.client);
1202 if (krb5creds.server) krb5_free_principal(krb5context,
1203 krb5creds.server);
1204 if (krb5auth_context) krb5_auth_con_free(krb5context,
1205 krb5auth_context);
1206 if (krb5context) krb5_free_context(krb5context);
1207 return (krb5rc);
1208 }
1209
1210
1211/* Given d2i_-decoded asn1ticket, allocate and return a new krb5_ticket.
1212** Return Kerberos error code and kssl_err struct on error.
1213** Allocates krb5_ticket and krb5_principal; caller should free these.
1214**
1215** 20010410 VRS Implemented krb5_decode_ticket() as
1216** old_krb5_decode_ticket(). Missing from MIT1.0.6.
1217** 20010615 VRS Re-cast as openssl/asn1 d2i_*() functions.
1218** Re-used some of the old krb5_decode_ticket()
1219** code here. This tkt should alloc/free just
1220** like the real thing.
1221*/
1222krb5_error_code
1223kssl_TKT2tkt( /* IN */ krb5_context krb5context,
1224 /* IN */ KRB5_TKTBODY *asn1ticket,
1225 /* OUT */ krb5_ticket **krb5ticket,
1226 /* OUT */ KSSL_ERR *kssl_err )
1227 {
1228 krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC;
1229 krb5_ticket *new5ticket = NULL;
1230 ASN1_GENERALSTRING *gstr_svc, *gstr_host;
1231
1232 *krb5ticket = NULL;
1233
1234 if (asn1ticket == NULL || asn1ticket->realm == NULL ||
1235 asn1ticket->sname == NULL ||
1236 sk_ASN1_GENERALSTRING_num(asn1ticket->sname->namestring) < 2)
1237 {
1238 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1239 "Null field in asn1ticket.\n");
1240 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1241 return KRB5KRB_ERR_GENERIC;
1242 }
1243
1244 if ((new5ticket = (krb5_ticket *) calloc(1, sizeof(krb5_ticket)))==NULL)
1245 {
1246 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1247 "Unable to allocate new krb5_ticket.\n");
1248 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1249 return ENOMEM; /* or KRB5KRB_ERR_GENERIC; */
1250 }
1251
1252 gstr_svc = sk_ASN1_GENERALSTRING_value(asn1ticket->sname->namestring, 0);
1253 gstr_host = sk_ASN1_GENERALSTRING_value(asn1ticket->sname->namestring, 1);
1254
1255 if ((krb5rc = kssl_build_principal_2(krb5context,
1256 &new5ticket->server,
1257 asn1ticket->realm->length, (char *)asn1ticket->realm->data,
1258 gstr_svc->length, (char *)gstr_svc->data,
1259 gstr_host->length, (char *)gstr_host->data)) != 0)
1260 {
1261 free(new5ticket);
1262 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1263 "Error building ticket server principal.\n");
1264 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1265 return krb5rc; /* or KRB5KRB_ERR_GENERIC; */
1266 }
1267
1268 krb5_princ_type(krb5context, new5ticket->server) =
1269 asn1ticket->sname->nametype->data[0];
1270 new5ticket->enc_part.enctype = asn1ticket->encdata->etype->data[0];
1271 new5ticket->enc_part.kvno = asn1ticket->encdata->kvno->data[0];
1272 new5ticket->enc_part.ciphertext.length =
1273 asn1ticket->encdata->cipher->length;
1274 if ((new5ticket->enc_part.ciphertext.data =
1275 calloc(1, asn1ticket->encdata->cipher->length)) == NULL)
1276 {
1277 free(new5ticket);
1278 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1279 "Error allocating cipher in krb5ticket.\n");
1280 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1281 return KRB5KRB_ERR_GENERIC;
1282 }
1283 else
1284 {
1285 memcpy(new5ticket->enc_part.ciphertext.data,
1286 asn1ticket->encdata->cipher->data,
1287 asn1ticket->encdata->cipher->length);
1288 }
1289
1290 *krb5ticket = new5ticket;
1291 return 0;
1292 }
1293
1294
1295/* Given krb5 service name in KSSL_CTX *kssl_ctx (typically "kssl"),
1296** and krb5 AP_REQ message & message length,
1297** Return Kerberos session key and client principle
1298** to SSL Server in KSSL_CTX *kssl_ctx.
1299**
1300** 19990702 VRS Started.
1301*/
1302krb5_error_code
1303kssl_sget_tkt( /* UPDATE */ KSSL_CTX *kssl_ctx,
1304 /* IN */ krb5_data *indata,
1305 /* OUT */ krb5_ticket_times *ttimes,
1306 /* OUT */ KSSL_ERR *kssl_err )
1307 {
1308 krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC;
1309 static krb5_context krb5context = NULL;
1310 static krb5_auth_context krb5auth_context = NULL;
1311 krb5_ticket *krb5ticket = NULL;
1312 KRB5_TKTBODY *asn1ticket = NULL;
1313 unsigned char *p;
1314 krb5_keytab krb5keytab = NULL;
1315 krb5_keytab_entry kt_entry;
1316 krb5_principal krb5server;
1317 krb5_rcache rcache = NULL;
1318
1319 kssl_err_set(kssl_err, 0, "");
1320
1321 if (!kssl_ctx)
1322 {
1323 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1324 "No kssl_ctx defined.\n");
1325 goto err;
1326 }
1327
1328#ifdef KSSL_DEBUG
1329 printf("in kssl_sget_tkt(%s)\n", kstring(kssl_ctx->service_name));
1330#endif /* KSSL_DEBUG */
1331
1332 if (!krb5context && (krb5rc = krb5_init_context(&krb5context)))
1333 {
1334 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1335 "krb5_init_context() fails.\n");
1336 goto err;
1337 }
1338 if (krb5auth_context &&
1339 (krb5rc = krb5_auth_con_free(krb5context, krb5auth_context)))
1340 {
1341 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1342 "krb5_auth_con_free() fails.\n");
1343 goto err;
1344 }
1345 else krb5auth_context = NULL;
1346 if (!krb5auth_context &&
1347 (krb5rc = krb5_auth_con_init(krb5context, &krb5auth_context)))
1348 {
1349 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1350 "krb5_auth_con_init() fails.\n");
1351 goto err;
1352 }
1353
1354
1355 if ((krb5rc = krb5_auth_con_getrcache(krb5context, krb5auth_context,
1356 &rcache)))
1357 {
1358 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1359 "krb5_auth_con_getrcache() fails.\n");
1360 goto err;
1361 }
1362
1363 if ((krb5rc = krb5_sname_to_principal(krb5context, NULL,
1364 (kssl_ctx->service_name)? kssl_ctx->service_name: KRB5SVC,
1365 KRB5_NT_SRV_HST, &krb5server)) != 0)
1366 {
1367 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1368 "krb5_sname_to_principal() fails.\n");
1369 goto err;
1370 }
1371
1372 if (rcache == NULL)
1373 {
1374 if ((krb5rc = krb5_get_server_rcache(krb5context,
1375 krb5_princ_component(krb5context, krb5server, 0),
1376 &rcache)))
1377 {
1378 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1379 "krb5_get_server_rcache() fails.\n");
1380 goto err;
1381 }
1382 }
1383
1384 if ((krb5rc = krb5_auth_con_setrcache(krb5context, krb5auth_context, rcache)))
1385 {
1386 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1387 "krb5_auth_con_setrcache() fails.\n");
1388 goto err;
1389 }
1390
1391
1392 /* kssl_ctx->keytab_file == NULL ==> use Kerberos default
1393 */
1394 if (kssl_ctx->keytab_file)
1395 {
1396 krb5rc = krb5_kt_resolve(krb5context, kssl_ctx->keytab_file,
1397 &krb5keytab);
1398 if (krb5rc)
1399 {
1400 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1401 "krb5_kt_resolve() fails.\n");
1402 goto err;
1403 }
1404 }
1405 else
1406 {
1407 krb5rc = krb5_kt_default(krb5context,&krb5keytab);
1408 if (krb5rc)
1409 {
1410 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
1411 "krb5_kt_default() fails.\n");
1412 goto err;
1413 }
1414 }
1415
1416 /* Actual Kerberos5 krb5_recvauth() has initial conversation here
1417 ** o check KRB5_SENDAUTH_BADAUTHVERS
1418 ** unless KRB5_RECVAUTH_SKIP_VERSION
1419 ** o check KRB5_SENDAUTH_BADAPPLVERS
1420 ** o send "0" msg if all OK
1421 */
1422
1423 /* 20010411 was using AP_REQ instead of true KerberosWrapper
1424 **
1425 ** if ((krb5rc = krb5_rd_req(krb5context, &krb5auth_context,
1426 ** &krb5in_data, krb5server, krb5keytab,
1427 ** &ap_option, &krb5ticket)) != 0) { Error }
1428 */
1429
1430 p = (unsigned char *)indata->data;
1431 if ((asn1ticket = (KRB5_TKTBODY *) d2i_KRB5_TICKET(NULL, &p,
1432 (long) indata->length)) == NULL)
1433 {
1434 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1435 "d2i_KRB5_TICKET() ASN.1 decode failure.\n");
1436 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1437 goto err;
1438 }
1439
1440 /* Was: krb5rc = krb5_decode_ticket(krb5in_data,&krb5ticket)) != 0) */
1441 if ((krb5rc = kssl_TKT2tkt(krb5context, asn1ticket, &krb5ticket,
1442 kssl_err)) != 0)
1443 {
1444 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1445 "Error converting ASN.1 ticket to krb5_ticket.\n");
1446 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1447 goto err;
1448 }
1449
1450 if (! krb5_principal_compare(krb5context, krb5server,
1451 krb5ticket->server)) {
1452 krb5rc = KRB5_PRINC_NOMATCH;
1453 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1454 "server principal != ticket principal\n");
1455 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1456 goto err;
1457 }
1458 if ((krb5rc = krb5_kt_get_entry(krb5context, krb5keytab,
1459 krb5ticket->server, krb5ticket->enc_part.kvno,
1460 krb5ticket->enc_part.enctype, &kt_entry)) != 0) {
1461 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1462 "krb5_kt_get_entry() fails with %x.\n", krb5rc);
1463 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1464 goto err;
1465 }
1466 if ((krb5rc = krb5_decrypt_tkt_part(krb5context, &kt_entry.key,
1467 krb5ticket)) != 0) {
1468 BIO_snprintf(kssl_err->text, KSSL_ERR_MAX,
1469 "krb5_decrypt_tkt_part() failed.\n");
1470 kssl_err->reason = SSL_R_KRB5_S_RD_REQ;
1471 goto err;
1472 }
1473 else {
1474 krb5_kt_free_entry(krb5context, &kt_entry);
1475#ifdef KSSL_DEBUG
1476 {
1477 int i; krb5_address **paddr = krb5ticket->enc_part2->caddrs;
1478 printf("Decrypted ticket fields:\n");
1479 printf("\tflags: %X, transit-type: %X",
1480 krb5ticket->enc_part2->flags,
1481 krb5ticket->enc_part2->transited.tr_type);
1482 print_krb5_data("\ttransit-data: ",
1483 &(krb5ticket->enc_part2->transited.tr_contents));
1484 printf("\tcaddrs: %p, authdata: %p\n",
1485 krb5ticket->enc_part2->caddrs,
1486 krb5ticket->enc_part2->authorization_data);
1487 if (paddr)
1488 {
1489 printf("\tcaddrs:\n");
1490 for (i=0; paddr[i] != NULL; i++)
1491 {
1492 krb5_data d;
1493 d.length=paddr[i]->length;
1494 d.data=paddr[i]->contents;
1495 print_krb5_data("\t\tIP: ", &d);
1496 }
1497 }
1498 printf("\tstart/auth/end times: %d / %d / %d\n",
1499 krb5ticket->enc_part2->times.starttime,
1500 krb5ticket->enc_part2->times.authtime,
1501 krb5ticket->enc_part2->times.endtime);
1502 }
1503#endif /* KSSL_DEBUG */
1504 }
1505
1506 krb5rc = KRB5_NO_TKT_SUPPLIED;
1507 if (!krb5ticket || !krb5ticket->enc_part2 ||
1508 !krb5ticket->enc_part2->client ||
1509 !krb5ticket->enc_part2->client->data ||
1510 !krb5ticket->enc_part2->session)
1511 {
1512 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,
1513 "bad ticket from krb5_rd_req.\n");
1514 }
1515 else if (kssl_ctx_setprinc(kssl_ctx, KSSL_CLIENT,
1516 &krb5ticket->enc_part2->client->realm,
1517 krb5ticket->enc_part2->client->data))
1518 {
1519 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,
1520 "kssl_ctx_setprinc() fails.\n");
1521 }
1522 else if (kssl_ctx_setkey(kssl_ctx, krb5ticket->enc_part2->session))
1523 {
1524 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,
1525 "kssl_ctx_setkey() fails.\n");
1526 }
1527 else if (krb5ticket->enc_part2->flags & TKT_FLG_INVALID)
1528 {
1529 krb5rc = KRB5KRB_AP_ERR_TKT_INVALID;
1530 kssl_err_set(kssl_err, SSL_R_KRB5_S_BAD_TICKET,
1531 "invalid ticket from krb5_rd_req.\n");
1532 }
1533 else krb5rc = 0;
1534
1535 kssl_ctx->enctype = krb5ticket->enc_part.enctype;
1536 ttimes->authtime = krb5ticket->enc_part2->times.authtime;
1537 ttimes->starttime = krb5ticket->enc_part2->times.starttime;
1538 ttimes->endtime = krb5ticket->enc_part2->times.endtime;
1539 ttimes->renew_till = krb5ticket->enc_part2->times.renew_till;
1540
1541 err:
1542#ifdef KSSL_DEBUG
1543 kssl_ctx_show(kssl_ctx);
1544#endif /* KSSL_DEBUG */
1545
1546 if (asn1ticket) KRB5_TICKET_free((KRB5_TICKET *) asn1ticket);
1547 if (krb5keytab) krb5_kt_close(krb5context, krb5keytab);
1548 if (krb5ticket) krb5_free_ticket(krb5context, krb5ticket);
1549 if (krb5server) krb5_free_principal(krb5context, krb5server);
1550 return (krb5rc);
1551 }
1552
1553
1554/* Allocate & return a new kssl_ctx struct.
1555*/
1556KSSL_CTX *
1557kssl_ctx_new(void)
1558 {
1559 return ((KSSL_CTX *) calloc(1, sizeof(KSSL_CTX)));
1560 }
1561
1562
1563/* Frees a kssl_ctx struct and any allocated memory it holds.
1564** Returns NULL.
1565*/
1566KSSL_CTX *
1567kssl_ctx_free(KSSL_CTX *kssl_ctx)
1568 {
1569 if (kssl_ctx == NULL) return kssl_ctx;
1570
1571 if (kssl_ctx->key) memset(kssl_ctx->key, 0,
1572 kssl_ctx->length);
1573 if (kssl_ctx->key) free(kssl_ctx->key);
1574 if (kssl_ctx->client_princ) free(kssl_ctx->client_princ);
1575 if (kssl_ctx->service_host) free(kssl_ctx->service_host);
1576 if (kssl_ctx->service_name) free(kssl_ctx->service_name);
1577 if (kssl_ctx->keytab_file) free(kssl_ctx->keytab_file);
1578
1579 free(kssl_ctx);
1580 return (KSSL_CTX *) NULL;
1581 }
1582
1583
1584/* Given a (krb5_data *) entity (and optional realm),
1585** set the plain (char *) client_princ or service_host member
1586** of the kssl_ctx struct.
1587*/
1588krb5_error_code
1589kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
1590 krb5_data *realm, krb5_data *entity)
1591 {
1592 char **princ;
1593 int length;
1594
1595 if (kssl_ctx == NULL || entity == NULL) return KSSL_CTX_ERR;
1596
1597 switch (which)
1598 {
1599 case KSSL_CLIENT: princ = &kssl_ctx->client_princ; break;
1600 case KSSL_SERVER: princ = &kssl_ctx->service_host; break;
1601 default: return KSSL_CTX_ERR; break;
1602 }
1603 if (*princ) free(*princ);
1604
1605 length = entity->length + ((realm)? realm->length + 2: 1);
1606 if ((*princ = calloc(1, length)) == NULL)
1607 return KSSL_CTX_ERR;
1608 else
1609 {
1610 strncpy(*princ, entity->data, entity->length);
1611 (*princ)[entity->length]='\0';
1612 if (realm)
1613 {
1614 strcat (*princ, "@");
1615 (void) strncat(*princ, realm->data, realm->length);
1616 (*princ)[entity->length+1+realm->length]='\0';
1617 }
1618 }
1619
1620 return KSSL_CTX_OK;
1621 }
1622
1623
1624/* Set one of the plain (char *) string members of the kssl_ctx struct.
1625** Default values should be:
1626** which == KSSL_SERVICE => "khost" (KRB5SVC)
1627** which == KSSL_KEYTAB => "/etc/krb5.keytab" (KRB5KEYTAB)
1628*/
1629krb5_error_code
1630kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text)
1631 {
1632 char **string;
1633
1634 if (!kssl_ctx) return KSSL_CTX_ERR;
1635
1636 switch (which)
1637 {
1638 case KSSL_SERVICE: string = &kssl_ctx->service_name; break;
1639 case KSSL_SERVER: string = &kssl_ctx->service_host; break;
1640 case KSSL_CLIENT: string = &kssl_ctx->client_princ; break;
1641 case KSSL_KEYTAB: string = &kssl_ctx->keytab_file; break;
1642 default: return KSSL_CTX_ERR; break;
1643 }
1644 if (*string) free(*string);
1645
1646 if (!text)
1647 {
1648 *string = '\0';
1649 return KSSL_CTX_OK;
1650 }
1651
1652 if ((*string = calloc(1, strlen(text) + 1)) == NULL)
1653 return KSSL_CTX_ERR;
1654 else
1655 strcpy(*string, text);
1656
1657 return KSSL_CTX_OK;
1658 }
1659
1660
1661/* Copy the Kerberos session key from a (krb5_keyblock *) to a kssl_ctx
1662** struct. Clear kssl_ctx->key if Kerberos session key is NULL.
1663*/
1664krb5_error_code
1665kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session)
1666 {
1667 int length;
1668 krb5_enctype enctype;
1669 krb5_octet FAR *contents = NULL;
1670
1671 if (!kssl_ctx) return KSSL_CTX_ERR;
1672
1673 if (kssl_ctx->key)
1674 {
1675 memset(kssl_ctx->key, 0, kssl_ctx->length);
1676 free(kssl_ctx->key);
1677 }
1678
1679 if (session)
1680 {
1681
1682#ifdef KRB5_HEIMDAL
1683 length = session->keyvalue->length;
1684 enctype = session->keytype;
1685 contents = session->keyvalue->contents;
1686#else
1687 length = session->length;
1688 enctype = session->enctype;
1689 contents = session->contents;
1690#endif
1691 kssl_ctx->enctype = enctype;
1692 kssl_ctx->length = length;
1693 }
1694 else
1695 {
1696 kssl_ctx->enctype = ENCTYPE_UNKNOWN;
1697 kssl_ctx->length = 0;
1698 return KSSL_CTX_OK;
1699 }
1700
1701 if ((kssl_ctx->key =
1702 (krb5_octet FAR *) calloc(1, kssl_ctx->length)) == NULL)
1703 {
1704 kssl_ctx->length = 0;
1705 return KSSL_CTX_ERR;
1706 }
1707 else
1708 memcpy(kssl_ctx->key, contents, length);
1709
1710 return KSSL_CTX_OK;
1711 }
1712
1713
1714/* Display contents of kssl_ctx struct
1715*/
1716void
1717kssl_ctx_show(KSSL_CTX *kssl_ctx)
1718 {
1719 int i;
1720
1721 printf("kssl_ctx: ");
1722 if (kssl_ctx == NULL)
1723 {
1724 printf("NULL\n");
1725 return;
1726 }
1727 else
1728 printf("%p\n", kssl_ctx);
1729
1730 printf("\tservice:\t%s\n",
1731 (kssl_ctx->service_name)? kssl_ctx->service_name: "NULL");
1732 printf("\tclient:\t%s\n",
1733 (kssl_ctx->client_princ)? kssl_ctx->client_princ: "NULL");
1734 printf("\tserver:\t%s\n",
1735 (kssl_ctx->service_host)? kssl_ctx->service_host: "NULL");
1736 printf("\tkeytab:\t%s\n",
1737 (kssl_ctx->keytab_file)? kssl_ctx->keytab_file: "NULL");
1738 printf("\tkey [%d:%d]:\t",
1739 kssl_ctx->enctype, kssl_ctx->length);
1740
1741 for (i=0; i < kssl_ctx->length && kssl_ctx->key; i++)
1742 {
1743 printf("%02x", kssl_ctx->key[i]);
1744 }
1745 printf("\n");
1746 return;
1747 }
1748
1749 int
1750 kssl_keytab_is_available(KSSL_CTX *kssl_ctx)
1751{
1752 krb5_context krb5context = NULL;
1753 krb5_keytab krb5keytab = NULL;
1754 krb5_keytab_entry entry;
1755 krb5_principal princ = NULL;
1756 krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC;
1757 int rc = 0;
1758
1759 if ((krb5rc = krb5_init_context(&krb5context)))
1760 return(0);
1761
1762 /* kssl_ctx->keytab_file == NULL ==> use Kerberos default
1763 */
1764 if (kssl_ctx->keytab_file)
1765 {
1766 krb5rc = krb5_kt_resolve(krb5context, kssl_ctx->keytab_file,
1767 &krb5keytab);
1768 if (krb5rc)
1769 goto exit;
1770 }
1771 else
1772 {
1773 krb5rc = krb5_kt_default(krb5context,&krb5keytab);
1774 if (krb5rc)
1775 goto exit;
1776 }
1777
1778 /* the host key we are looking for */
1779 krb5rc = krb5_sname_to_principal(krb5context, NULL,
1780 kssl_ctx->service_name ? kssl_ctx->service_name: KRB5SVC,
1781 KRB5_NT_SRV_HST, &princ);
1782
1783 krb5rc = krb5_kt_get_entry(krb5context, krb5keytab,
1784 princ,
1785 0 /* IGNORE_VNO */,
1786 0 /* IGNORE_ENCTYPE */,
1787 &entry);
1788 if ( krb5rc == KRB5_KT_NOTFOUND ) {
1789 rc = 1;
1790 goto exit;
1791 } else if ( krb5rc )
1792 goto exit;
1793
1794 krb5_kt_free_entry(krb5context, &entry);
1795 rc = 1;
1796
1797 exit:
1798 if (krb5keytab) krb5_kt_close(krb5context, krb5keytab);
1799 if (princ) krb5_free_principal(krb5context, princ);
1800 if (krb5context) krb5_free_context(krb5context);
1801 return(rc);
1802}
1803
1804int
1805kssl_tgt_is_available(KSSL_CTX *kssl_ctx)
1806 {
1807 krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC;
1808 krb5_context krb5context = NULL;
1809 krb5_ccache krb5ccdef = NULL;
1810 krb5_creds krb5creds, *krb5credsp = NULL;
1811 int rc = 0;
1812
1813 memset((char *)&krb5creds, 0, sizeof(krb5creds));
1814
1815 if (!kssl_ctx)
1816 return(0);
1817
1818 if (!kssl_ctx->service_host)
1819 return(0);
1820
1821 if ((krb5rc = krb5_init_context(&krb5context)) != 0)
1822 goto err;
1823
1824 if ((krb5rc = krb5_sname_to_principal(krb5context,
1825 kssl_ctx->service_host,
1826 (kssl_ctx->service_name)? kssl_ctx->service_name: KRB5SVC,
1827 KRB5_NT_SRV_HST, &krb5creds.server)) != 0)
1828 goto err;
1829
1830 if ((krb5rc = krb5_cc_default(krb5context, &krb5ccdef)) != 0)
1831 goto err;
1832
1833 if ((krb5rc = krb5_cc_get_principal(krb5context, krb5ccdef,
1834 &krb5creds.client)) != 0)
1835 goto err;
1836
1837 if ((krb5rc = krb5_get_credentials(krb5context, 0, krb5ccdef,
1838 &krb5creds, &krb5credsp)) != 0)
1839 goto err;
1840
1841 rc = 1;
1842
1843 err:
1844#ifdef KSSL_DEBUG
1845 kssl_ctx_show(kssl_ctx);
1846#endif /* KSSL_DEBUG */
1847
1848 if (krb5creds.client) krb5_free_principal(krb5context, krb5creds.client);
1849 if (krb5creds.server) krb5_free_principal(krb5context, krb5creds.server);
1850 if (krb5context) krb5_free_context(krb5context);
1851 return(rc);
1852 }
1853
1854#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_WIN32)
1855void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data)
1856 {
1857#ifdef KRB5_HEIMDAL
1858 data->length = 0;
1859 if (data->data)
1860 free(data->data);
1861#elif defined(KRB5_MIT_OLD11)
1862 if (data->data) {
1863 krb5_xfree(data->data);
1864 data->data = 0;
1865 }
1866#else
1867 krb5_free_data_contents(NULL, data);
1868#endif
1869 }
1870#endif /* !OPENSSL_SYS_WINDOWS && !OPENSSL_SYS_WIN32 */
1871
1872
1873/* Given pointers to KerberosTime and struct tm structs, convert the
1874** KerberosTime string to struct tm. Note that KerberosTime is a
1875** ASN1_GENERALIZEDTIME value, constrained to GMT with no fractional
1876** seconds as defined in RFC 1510.
1877** Return pointer to the (partially) filled in struct tm on success,
1878** return NULL on failure.
1879*/
1880struct tm *k_gmtime(ASN1_GENERALIZEDTIME *gtime, struct tm *k_tm)
1881 {
1882 char c, *p;
1883
1884 if (!k_tm) return NULL;
1885 if (gtime == NULL || gtime->length < 14) return NULL;
1886 if (gtime->data == NULL) return NULL;
1887
1888 p = (char *)&gtime->data[14];
1889
1890 c = *p; *p = '\0'; p -= 2; k_tm->tm_sec = atoi(p); *(p+2) = c;
1891 c = *p; *p = '\0'; p -= 2; k_tm->tm_min = atoi(p); *(p+2) = c;
1892 c = *p; *p = '\0'; p -= 2; k_tm->tm_hour = atoi(p); *(p+2) = c;
1893 c = *p; *p = '\0'; p -= 2; k_tm->tm_mday = atoi(p); *(p+2) = c;
1894 c = *p; *p = '\0'; p -= 2; k_tm->tm_mon = atoi(p)-1; *(p+2) = c;
1895 c = *p; *p = '\0'; p -= 4; k_tm->tm_year = atoi(p)-1900; *(p+4) = c;
1896
1897 return k_tm;
1898 }
1899
1900
1901/* Helper function for kssl_validate_times().
1902** We need context->clockskew, but krb5_context is an opaque struct.
1903** So we try to sneek the clockskew out through the replay cache.
1904** If that fails just return a likely default (300 seconds).
1905*/
1906krb5_deltat get_rc_clockskew(krb5_context context)
1907 {
1908 krb5_rcache rc;
1909 krb5_deltat clockskew;
1910
1911 if (krb5_rc_default(context, &rc)) return KSSL_CLOCKSKEW;
1912 if (krb5_rc_initialize(context, rc, 0)) return KSSL_CLOCKSKEW;
1913 if (krb5_rc_get_lifespan(context, rc, &clockskew)) {
1914 clockskew = KSSL_CLOCKSKEW;
1915 }
1916 (void) krb5_rc_destroy(context, rc);
1917 return clockskew;
1918 }
1919
1920
1921/* kssl_validate_times() combines (and more importantly exposes)
1922** the MIT KRB5 internal function krb5_validate_times() and the
1923** in_clock_skew() macro. The authenticator client time is checked
1924** to be within clockskew secs of the current time and the current
1925** time is checked to be within the ticket start and expire times.
1926** Either check may be omitted by supplying a NULL value.
1927** Returns 0 for valid times, SSL_R_KRB5* error codes otherwise.
1928** See Also: (Kerberos source)/krb5/lib/krb5/krb/valid_times.c
1929** 20010420 VRS
1930*/
1931krb5_error_code kssl_validate_times( krb5_timestamp atime,
1932 krb5_ticket_times *ttimes)
1933 {
1934 krb5_deltat skew;
1935 krb5_timestamp start, now;
1936 krb5_error_code rc;
1937 krb5_context context;
1938
1939 if ((rc = krb5_init_context(&context))) return SSL_R_KRB5_S_BAD_TICKET;
1940 skew = get_rc_clockskew(context);
1941 if ((rc = krb5_timeofday(context,&now))) return SSL_R_KRB5_S_BAD_TICKET;
1942 krb5_free_context(context);
1943
1944 if (atime && labs(atime - now) >= skew) return SSL_R_KRB5_S_TKT_SKEW;
1945
1946 if (! ttimes) return 0;
1947
1948 start = (ttimes->starttime != 0)? ttimes->starttime: ttimes->authtime;
1949 if (start - now > skew) return SSL_R_KRB5_S_TKT_NYV;
1950 if ((now - ttimes->endtime) > skew) return SSL_R_KRB5_S_TKT_EXPIRED;
1951
1952#ifdef KSSL_DEBUG
1953 printf("kssl_validate_times: %d |<- | %d - %d | < %d ->| %d\n",
1954 start, atime, now, skew, ttimes->endtime);
1955#endif /* KSSL_DEBUG */
1956
1957 return 0;
1958 }
1959
1960
1961/* Decode and decrypt given DER-encoded authenticator, then pass
1962** authenticator ctime back in *atimep (or 0 if time unavailable).
1963** Returns krb5_error_code and kssl_err on error. A NULL
1964** authenticator (authentp->length == 0) is not considered an error.
1965** Note that kssl_check_authent() makes use of the KRB5 session key;
1966** you must call kssl_sget_tkt() to get the key before calling this routine.
1967*/
1968krb5_error_code kssl_check_authent(
1969 /* IN */ KSSL_CTX *kssl_ctx,
1970 /* IN */ krb5_data *authentp,
1971 /* OUT */ krb5_timestamp *atimep,
1972 /* OUT */ KSSL_ERR *kssl_err )
1973 {
1974 krb5_error_code krb5rc = 0;
1975 KRB5_ENCDATA *dec_authent = NULL;
1976 KRB5_AUTHENTBODY *auth = NULL;
1977 krb5_enctype enctype;
1978 EVP_CIPHER_CTX ciph_ctx;
1979 const EVP_CIPHER *enc = NULL;
1980 unsigned char iv[EVP_MAX_IV_LENGTH];
1981 unsigned char *p, *unenc_authent;
1982 int padl, outl, unencbufsize;
1983 struct tm tm_time, *tm_l, *tm_g;
1984 time_t now, tl, tg, tr, tz_offset;
1985
1986 EVP_CIPHER_CTX_init(&ciph_ctx);
1987 *atimep = 0;
1988 kssl_err_set(kssl_err, 0, "");
1989
1990#ifndef KRB5CHECKAUTH
1991 authentp = NULL;
1992#else
1993#if KRB5CHECKAUTH == 0
1994 authentp = NULL;
1995#endif
1996#endif /* KRB5CHECKAUTH */
1997
1998 if (authentp == NULL || authentp->length == 0) return 0;
1999
2000#ifdef KSSL_DEBUG
2001 {
2002 unsigned int ui;
2003 printf("kssl_check_authent: authenticator[%d]:\n",authentp->length);
2004 p = authentp->data;
2005 for (ui=0; ui < authentp->length; ui++) printf("%02x ",p[ui]);
2006 printf("\n");
2007 }
2008#endif /* KSSL_DEBUG */
2009
2010 unencbufsize = 2 * authentp->length;
2011 if ((unenc_authent = calloc(1, unencbufsize)) == NULL)
2012 {
2013 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2014 "Unable to allocate authenticator buffer.\n");
2015 krb5rc = KRB5KRB_ERR_GENERIC;
2016 goto err;
2017 }
2018
2019 p = (unsigned char *)authentp->data;
2020 if ((dec_authent = d2i_KRB5_ENCDATA(NULL, &p,
2021 (long) authentp->length)) == NULL)
2022 {
2023 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2024 "Error decoding authenticator.\n");
2025 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2026 goto err;
2027 }
2028
2029 enctype = dec_authent->etype->data[0]; /* should = kssl_ctx->enctype */
2030#if !defined(KRB5_MIT_OLD11)
2031 switch ( enctype ) {
2032 case ENCTYPE_DES3_CBC_SHA1: /* EVP_des_ede3_cbc(); */
2033 case ENCTYPE_DES3_CBC_SHA:
2034 case ENCTYPE_DES3_CBC_RAW:
2035 krb5rc = 0; /* Skip, can't handle derived keys */
2036 goto err;
2037 }
2038#endif
2039 enc = kssl_map_enc(enctype);
2040 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */
2041
2042 if (enc == NULL)
2043 {
2044 /* Disable kssl_check_authent for ENCTYPE_DES3_CBC_SHA1.
2045 ** This enctype indicates the authenticator was encrypted
2046 ** using key-usage derived keys which openssl cannot decrypt.
2047 */
2048 goto err;
2049 }
2050 if (!EVP_DecryptInit_ex(&ciph_ctx, enc, NULL, kssl_ctx->key, iv))
2051 {
2052 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2053 "EVP_DecryptInit_ex error decrypting authenticator.\n");
2054 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2055 goto err;
2056 }
2057 if (!EVP_DecryptUpdate(&ciph_ctx, unenc_authent, &outl,
2058 dec_authent->cipher->data, dec_authent->cipher->length))
2059 {
2060 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2061 "EVP_DecryptUpdate error decrypting authenticator.\n");
2062 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2063 goto err;
2064 }
2065 if (outl > unencbufsize)
2066 {
2067 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2068 "Buffer overflow decrypting authenticator.\n");
2069 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2070 goto err;
2071 }
2072 if (!EVP_DecryptFinal_ex(&ciph_ctx, &(unenc_authent[outl]), &padl))
2073 {
2074 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2075 "EVP_DecryptFinal_ex error decrypting authenticator.\n");
2076 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2077 goto err;
2078 }
2079 outl += padl;
2080 if (outl > unencbufsize)
2081 {
2082 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2083 "Buffer overflow decrypting authenticator.\n");
2084 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2085 goto err;
2086 }
2087 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
2088
2089#ifdef KSSL_DEBUG
2090 printf("kssl_check_authent: decrypted authenticator[%d] =\n", outl);
2091 for (padl=0; padl < outl; padl++) printf("%02x ",unenc_authent[padl]);
2092 printf("\n");
2093#endif /* KSSL_DEBUG */
2094
2095 if ((p = kssl_skip_confound(enctype, unenc_authent)) == NULL)
2096 {
2097 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2098 "confounded by authenticator.\n");
2099 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2100 goto err;
2101 }
2102 outl -= p - unenc_authent;
2103
2104 if ((auth = (KRB5_AUTHENTBODY *) d2i_KRB5_AUTHENT(NULL, &p,
2105 (long) outl))==NULL)
2106 {
2107 kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT,
2108 "Error decoding authenticator body.\n");
2109 krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY;
2110 goto err;
2111 }
2112
2113 memset(&tm_time,0,sizeof(struct tm));
2114 if (k_gmtime(auth->ctime, &tm_time) &&
2115 ((tr = mktime(&tm_time)) != (time_t)(-1)))
2116 {
2117 now = time(&now);
2118 tm_l = localtime(&now); tl = mktime(tm_l);
2119 tm_g = gmtime(&now); tg = mktime(tm_g);
2120 tz_offset = tg - tl;
2121
2122 *atimep = tr - tz_offset;
2123 }
2124
2125#ifdef KSSL_DEBUG
2126 printf("kssl_check_authent: returns %d for client time ", *atimep);
2127 if (auth && auth->ctime && auth->ctime->length && auth->ctime->data)
2128 printf("%.*s\n", auth->ctime->length, auth->ctime->data);
2129 else printf("NULL\n");
2130#endif /* KSSL_DEBUG */
2131
2132 err:
2133 if (auth) KRB5_AUTHENT_free((KRB5_AUTHENT *) auth);
2134 if (dec_authent) KRB5_ENCDATA_free(dec_authent);
2135 if (unenc_authent) free(unenc_authent);
2136 return krb5rc;
2137 }
2138
2139
2140/* Replaces krb5_build_principal_ext(), with varargs length == 2 (svc, host),
2141** because I dont't know how to stub varargs.
2142** Returns krb5_error_code == ENOMEM on alloc error, otherwise
2143** passes back newly constructed principal, which should be freed by caller.
2144*/
2145krb5_error_code kssl_build_principal_2(
2146 /* UPDATE */ krb5_context context,
2147 /* OUT */ krb5_principal *princ,
2148 /* IN */ int rlen, const char *realm,
2149 /* IN */ int slen, const char *svc,
2150 /* IN */ int hlen, const char *host)
2151 {
2152 krb5_data *p_data = NULL;
2153 krb5_principal new_p = NULL;
2154 char *new_r = NULL;
2155
2156 if ((p_data = (krb5_data *) calloc(2, sizeof(krb5_data))) == NULL ||
2157 (new_p = (krb5_principal) calloc(1, sizeof(krb5_principal_data)))
2158 == NULL) goto err;
2159 new_p->length = 2;
2160 new_p->data = p_data;
2161
2162 if ((new_r = calloc(1, rlen + 1)) == NULL) goto err;
2163 memcpy(new_r, realm, rlen);
2164 krb5_princ_set_realm_length(context, new_p, rlen);
2165 krb5_princ_set_realm_data(context, new_p, new_r);
2166
2167 if ((new_p->data[0].data = calloc(1, slen + 1)) == NULL) goto err;
2168 memcpy(new_p->data[0].data, svc, slen);
2169 new_p->data[0].length = slen;
2170
2171 if ((new_p->data[1].data = calloc(1, hlen + 1)) == NULL) goto err;
2172 memcpy(new_p->data[1].data, host, hlen);
2173 new_p->data[1].length = hlen;
2174
2175 krb5_princ_type(context, new_p) = KRB5_NT_UNKNOWN;
2176 *princ = new_p;
2177 return 0;
2178
2179 err:
2180 if (new_p && new_p[0].data) free(new_p[0].data);
2181 if (new_p && new_p[1].data) free(new_p[1].data);
2182 if (new_p) free(new_p);
2183 if (new_r) free(new_r);
2184 return ENOMEM;
2185 }
2186
2187
2188#else /* !OPENSSL_NO_KRB5 */
2189
2190#if defined(PEDANTIC) || defined(OPENSSL_SYS_VMS)
2191static int dummy=(int)&dummy;
2192#endif
2193
2194#endif /* !OPENSSL_NO_KRB5 */
2195
diff --git a/src/lib/libssl/src/ssl/kssl.h b/src/lib/libssl/src/ssl/kssl.h
new file mode 100644
index 0000000000..cf7ebdd168
--- /dev/null
+++ b/src/lib/libssl/src/ssl/kssl.h
@@ -0,0 +1,173 @@
1/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.
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** 19990701 VRS Started.
61*/
62
63#ifndef KSSL_H
64#define KSSL_H
65
66#include <openssl/opensslconf.h>
67
68#ifndef OPENSSL_NO_KRB5
69
70#include <stdio.h>
71#include <ctype.h>
72#include <krb5.h>
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78/*
79** Depending on which KRB5 implementation used, some types from
80** the other may be missing. Resolve that here and now
81*/
82#ifdef KRB5_HEIMDAL
83typedef unsigned char krb5_octet;
84#define FAR
85#endif
86
87/* Uncomment this to debug kssl problems or
88** to trace usage of the Kerberos session key
89**
90** #define KSSL_DEBUG
91*/
92
93#ifndef KRB5SVC
94#define KRB5SVC "host"
95#endif
96
97#ifndef KRB5KEYTAB
98#define KRB5KEYTAB "/etc/krb5.keytab"
99#endif
100
101#ifndef KRB5SENDAUTH
102#define KRB5SENDAUTH 1
103#endif
104
105#ifndef KRB5CHECKAUTH
106#define KRB5CHECKAUTH 1
107#endif
108
109#ifndef KSSL_CLOCKSKEW
110#define KSSL_CLOCKSKEW 300;
111#endif
112
113#define KSSL_ERR_MAX 255
114typedef struct kssl_err_st {
115 int reason;
116 char text[KSSL_ERR_MAX+1];
117 } KSSL_ERR;
118
119
120/* Context for passing
121** (1) Kerberos session key to SSL, and
122** (2) Config data between application and SSL lib
123*/
124typedef struct kssl_ctx_st
125 {
126 /* used by: disposition: */
127 char *service_name; /* C,S default ok (kssl) */
128 char *service_host; /* C input, REQUIRED */
129 char *client_princ; /* S output from krb5 ticket */
130 char *keytab_file; /* S NULL (/etc/krb5.keytab) */
131 char *cred_cache; /* C NULL (default) */
132 krb5_enctype enctype;
133 int length;
134 krb5_octet FAR *key;
135 } KSSL_CTX;
136
137#define KSSL_CLIENT 1
138#define KSSL_SERVER 2
139#define KSSL_SERVICE 3
140#define KSSL_KEYTAB 4
141
142#define KSSL_CTX_OK 0
143#define KSSL_CTX_ERR 1
144#define KSSL_NOMEM 2
145
146/* Public (for use by applications that use OpenSSL with Kerberos 5 support */
147krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);
148KSSL_CTX *kssl_ctx_new(void);
149KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);
150void kssl_ctx_show(KSSL_CTX *kssl_ctx);
151krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,
152 krb5_data *realm, krb5_data *entity);
153krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,
154 krb5_data *authenp, KSSL_ERR *kssl_err);
155krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,
156 krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);
157krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);
158void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);
159void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);
160krb5_error_code kssl_build_principal_2(krb5_context context,
161 krb5_principal *princ, int rlen, const char *realm,
162 int slen, const char *svc, int hlen, const char *host);
163krb5_error_code kssl_validate_times(krb5_timestamp atime,
164 krb5_ticket_times *ttimes);
165krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,
166 krb5_timestamp *atimep, KSSL_ERR *kssl_err);
167unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);
168
169#ifdef __cplusplus
170}
171#endif
172#endif /* OPENSSL_NO_KRB5 */
173#endif /* KSSL_H */
diff --git a/src/lib/libssl/src/ssl/kssl_lcl.h b/src/lib/libssl/src/ssl/kssl_lcl.h
new file mode 100644
index 0000000000..4cd8dd2d7f
--- /dev/null
+++ b/src/lib/libssl/src/ssl/kssl_lcl.h
@@ -0,0 +1,87 @@
1/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.
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#ifndef KSSL_LCL_H
60#define KSSL_LCL_H
61
62#include <openssl/kssl.h>
63
64#ifndef OPENSSL_NO_KRB5
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/* Private (internal to OpenSSL) */
71void print_krb5_data(char *label, krb5_data *kdata);
72void print_krb5_authdata(char *label, krb5_authdata **adata);
73void print_krb5_keyblock(char *label, krb5_keyblock *keyblk);
74
75char *kstring(char *string);
76char *knumber(int len, krb5_octet *contents);
77
78EVP_CIPHER *kssl_map_enc(krb5_enctype enctype);
79
80int kssl_keytab_is_available(KSSL_CTX *kssl_ctx);
81int kssl_tgt_is_available(KSSL_CTX *kssl_ctx);
82
83#ifdef __cplusplus
84}
85#endif
86#endif /* OPENSSL_NO_KRB5 */
87#endif /* KSSL_LCL_H */
diff --git a/src/lib/libssl/src/ssl/s23_clnt.c b/src/lib/libssl/src/ssl/s23_clnt.c
index 5050a13ef2..b2be8340fb 100644
--- a/src/lib/libssl/src/ssl/s23_clnt.c
+++ b/src/lib/libssl/src/ssl/s23_clnt.c
@@ -68,7 +68,7 @@ static int ssl23_client_hello(SSL *s);
68static int ssl23_get_server_hello(SSL *s); 68static int ssl23_get_server_hello(SSL *s);
69static SSL_METHOD *ssl23_get_client_method(int ver) 69static SSL_METHOD *ssl23_get_client_method(int ver)
70 { 70 {
71#ifndef NO_SSL2 71#ifndef OPENSSL_NO_SSL2
72 if (ver == SSL2_VERSION) 72 if (ver == SSL2_VERSION)
73 return(SSLv2_client_method()); 73 return(SSLv2_client_method());
74#endif 74#endif
@@ -100,7 +100,7 @@ int ssl23_connect(SSL *s)
100 { 100 {
101 BUF_MEM *buf; 101 BUF_MEM *buf;
102 unsigned long Time=time(NULL); 102 unsigned long Time=time(NULL);
103 void (*cb)()=NULL; 103 void (*cb)(const SSL *ssl,int type,int val)=NULL;
104 int ret= -1; 104 int ret= -1;
105 int new_state,state; 105 int new_state,state;
106 106
@@ -113,8 +113,8 @@ int ssl23_connect(SSL *s)
113 else if (s->ctx->info_callback != NULL) 113 else if (s->ctx->info_callback != NULL)
114 cb=s->ctx->info_callback; 114 cb=s->ctx->info_callback;
115 115
116 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
117 s->in_handshake++; 116 s->in_handshake++;
117 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
118 118
119 for (;;) 119 for (;;)
120 { 120 {
@@ -211,6 +211,7 @@ static int ssl23_client_hello(SSL *s)
211 unsigned char *buf; 211 unsigned char *buf;
212 unsigned char *p,*d; 212 unsigned char *p,*d;
213 int i,ch_len; 213 int i,ch_len;
214 int ret;
214 215
215 buf=(unsigned char *)s->init_buf->data; 216 buf=(unsigned char *)s->init_buf->data;
216 if (s->state == SSL23_ST_CW_CLNT_HELLO_A) 217 if (s->state == SSL23_ST_CW_CLNT_HELLO_A)
@@ -302,7 +303,11 @@ static int ssl23_client_hello(SSL *s)
302 } 303 }
303 304
304 /* SSL3_ST_CW_CLNT_HELLO_B */ 305 /* SSL3_ST_CW_CLNT_HELLO_B */
305 return(ssl23_write_bytes(s)); 306 ret = ssl23_write_bytes(s);
307 if (ret >= 2)
308 if (s->msg_callback)
309 s->msg_callback(1, SSL2_VERSION, 0, s->init_buf->data+2, ret-2, s, s->msg_callback_arg); /* CLIENT-HELLO */
310 return ret;
306 } 311 }
307 312
308static int ssl23_get_server_hello(SSL *s) 313static int ssl23_get_server_hello(SSL *s)
@@ -322,7 +327,7 @@ static int ssl23_get_server_hello(SSL *s)
322 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && 327 if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) &&
323 (p[5] == 0x00) && (p[6] == 0x02)) 328 (p[5] == 0x00) && (p[6] == 0x02))
324 { 329 {
325#ifdef NO_SSL2 330#ifdef OPENSSL_NO_SSL2
326 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); 331 SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
327 goto err; 332 goto err;
328#else 333#else
@@ -435,7 +440,7 @@ static int ssl23_get_server_hello(SSL *s)
435 (p[3] == 0) && 440 (p[3] == 0) &&
436 (p[4] == 2)) 441 (p[4] == 2))
437 { 442 {
438 void (*cb)()=NULL; 443 void (*cb)(const SSL *ssl,int type,int val)=NULL;
439 int j; 444 int j;
440 445
441 /* An alert */ 446 /* An alert */
diff --git a/src/lib/libssl/src/ssl/s23_lib.c b/src/lib/libssl/src/ssl/s23_lib.c
index ad2d8dadf7..b70002a647 100644
--- a/src/lib/libssl/src/ssl/s23_lib.c
+++ b/src/lib/libssl/src/ssl/s23_lib.c
@@ -111,7 +111,7 @@ SSL_METHOD *sslv23_base_method(void)
111static int ssl23_num_ciphers(void) 111static int ssl23_num_ciphers(void)
112 { 112 {
113 return(ssl3_num_ciphers() 113 return(ssl3_num_ciphers()
114#ifndef NO_SSL2 114#ifndef OPENSSL_NO_SSL2
115 + ssl2_num_ciphers() 115 + ssl2_num_ciphers()
116#endif 116#endif
117 ); 117 );
@@ -124,7 +124,7 @@ static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
124 if (u < uu) 124 if (u < uu)
125 return(ssl3_get_cipher(u)); 125 return(ssl3_get_cipher(u));
126 else 126 else
127#ifndef NO_SSL2 127#ifndef OPENSSL_NO_SSL2
128 return(ssl2_get_cipher(u-uu)); 128 return(ssl2_get_cipher(u-uu));
129#else 129#else
130 return(NULL); 130 return(NULL);
@@ -144,7 +144,7 @@ static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
144 ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; 144 ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
145 c.id=id; 145 c.id=id;
146 cp=ssl3_get_cipher_by_char(p); 146 cp=ssl3_get_cipher_by_char(p);
147#ifndef NO_SSL2 147#ifndef OPENSSL_NO_SSL2
148 if (cp == NULL) 148 if (cp == NULL)
149 cp=ssl2_get_cipher_by_char(p); 149 cp=ssl2_get_cipher_by_char(p);
150#endif 150#endif
diff --git a/src/lib/libssl/src/ssl/s23_srvr.c b/src/lib/libssl/src/ssl/s23_srvr.c
index 050618235f..9e89cc7f9a 100644
--- a/src/lib/libssl/src/ssl/s23_srvr.c
+++ b/src/lib/libssl/src/ssl/s23_srvr.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 <openssl/buffer.h> 113#include <openssl/buffer.h>
@@ -67,7 +120,7 @@ static SSL_METHOD *ssl23_get_server_method(int ver);
67int ssl23_get_client_hello(SSL *s); 120int ssl23_get_client_hello(SSL *s);
68static SSL_METHOD *ssl23_get_server_method(int ver) 121static SSL_METHOD *ssl23_get_server_method(int ver)
69 { 122 {
70#ifndef NO_SSL2 123#ifndef OPENSSL_NO_SSL2
71 if (ver == SSL2_VERSION) 124 if (ver == SSL2_VERSION)
72 return(SSLv2_server_method()); 125 return(SSLv2_server_method());
73#endif 126#endif
@@ -99,7 +152,7 @@ int ssl23_accept(SSL *s)
99 { 152 {
100 BUF_MEM *buf; 153 BUF_MEM *buf;
101 unsigned long Time=time(NULL); 154 unsigned long Time=time(NULL);
102 void (*cb)()=NULL; 155 void (*cb)(const SSL *ssl,int type,int val)=NULL;
103 int ret= -1; 156 int ret= -1;
104 int new_state,state; 157 int new_state,state;
105 158
@@ -112,8 +165,8 @@ int ssl23_accept(SSL *s)
112 else if (s->ctx->info_callback != NULL) 165 else if (s->ctx->info_callback != NULL)
113 cb=s->ctx->info_callback; 166 cb=s->ctx->info_callback;
114 167
115 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
116 s->in_handshake++; 168 s->in_handshake++;
169 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
117 170
118 for (;;) 171 for (;;)
119 { 172 {
@@ -179,9 +232,9 @@ int ssl23_accept(SSL *s)
179 } 232 }
180 } 233 }
181end: 234end:
235 s->in_handshake--;
182 if (cb != NULL) 236 if (cb != NULL)
183 cb(s,SSL_CB_ACCEPT_EXIT,ret); 237 cb(s,SSL_CB_ACCEPT_EXIT,ret);
184 s->in_handshake--;
185 return(ret); 238 return(ret);
186 } 239 }
187 240
@@ -202,13 +255,13 @@ int ssl23_get_client_hello(SSL *s)
202 * 9/10 client_version / 255 * 9/10 client_version /
203 */ 256 */
204 char *buf= &(buf_space[0]); 257 char *buf= &(buf_space[0]);
205 unsigned char *p,*d,*dd; 258 unsigned char *p,*d,*d_len,*dd;
206 unsigned int i; 259 unsigned int i;
207 unsigned int csl,sil,cl; 260 unsigned int csl,sil,cl;
208 int n=0,j; 261 int n=0,j;
209 int type=0; 262 int type=0;
210 int v[2]; 263 int v[2];
211#ifndef NO_RSA 264#ifndef OPENSSL_NO_RSA
212 int use_sslv2_strong=0; 265 int use_sslv2_strong=0;
213#endif 266#endif
214 267
@@ -270,72 +323,6 @@ int ssl23_get_client_hello(SSL *s)
270 else if (!(s->options & SSL_OP_NO_SSLv2)) 323 else if (!(s->options & SSL_OP_NO_SSLv2))
271 type=1; 324 type=1;
272 325
273 if (s->options & SSL_OP_NON_EXPORT_FIRST)
274 /* Not only utterly confusing, but broken
275 * ('fractured programming'?) -- the details
276 * of this block nearly make it work
277 * as intended in this environment, but on one
278 * of the fine points (w.r.t. restarts) it fails.
279 * The obvious fix would be even more devastating
280 * to program structure; if you want the functionality,
281 * throw this away and implement it in a way
282 * that makes sense */
283 {
284#if 0
285 STACK_OF(SSL_CIPHER) *sk;
286 SSL_CIPHER *c;
287 int ne2,ne3;
288
289 j=((p[0]&0x7f)<<8)|p[1];
290 if (j > (1024*4))
291 {
292 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE);
293 goto err;
294 }
295
296 n=ssl23_read_bytes(s,j+2);
297 if (n <= 0) return(n);
298 p=s->packet;
299
300 if ((buf=OPENSSL_malloc(n)) == NULL)
301 {
302 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,ERR_R_MALLOC_FAILURE);
303 goto err;
304 }
305 memcpy(buf,p,n);
306
307 p+=5;
308 n2s(p,csl);
309 p+=4;
310
311 sk=ssl_bytes_to_cipher_list(
312 s,p,csl,NULL);
313 if (sk != NULL)
314 {
315 ne2=ne3=0;
316 for (j=0; j<sk_SSL_CIPHER_num(sk); j++)
317 {
318 c=sk_SSL_CIPHER_value(sk,j);
319 if (!SSL_C_IS_EXPORT(c))
320 {
321 if ((c->id>>24L) == 2L)
322 ne2=1;
323 else
324 ne3=1;
325 }
326 }
327 if (ne2 && !ne3)
328 {
329 type=1;
330 use_sslv2_strong=1;
331 goto next_bit;
332 }
333 }
334#else
335 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_OPTION);
336 goto err;
337#endif
338 }
339 } 326 }
340 } 327 }
341 else if ((p[0] == SSL3_RT_HANDSHAKE) && 328 else if ((p[0] == SSL3_RT_HANDSHAKE) &&
@@ -352,17 +339,22 @@ int ssl23_get_client_hello(SSL *s)
352 /* We must look at client_version inside the Client Hello message 339 /* We must look at client_version inside the Client Hello message
353 * to get the correct minor version. 340 * to get the correct minor version.
354 * However if we have only a pathologically small fragment of the 341 * However if we have only a pathologically small fragment of the
355 * Client Hello message, this would be difficult, we'd have 342 * Client Hello message, this would be difficult, and we'd have
356 * to read at least one additional record to find out. 343 * to read more records to find out.
357 * This doesn't usually happen in real life, so we just complain 344 * No known SSL 3.0 client fragments ClientHello like this,
358 * for now. 345 * so we simply assume TLS 1.0 to avoid protocol version downgrade
359 */ 346 * attacks. */
360 if (p[3] == 0 && p[4] < 6) 347 if (p[3] == 0 && p[4] < 6)
361 { 348 {
349#if 0
362 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); 350 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL);
363 goto err; 351 goto err;
352#else
353 v[1] = TLS1_VERSION_MINOR;
354#endif
364 } 355 }
365 v[1]=p[10]; /* minor version according to client_version */ 356 else
357 v[1]=p[10]; /* minor version according to client_version */
366 if (v[1] >= TLS1_VERSION_MINOR) 358 if (v[1] >= TLS1_VERSION_MINOR)
367 { 359 {
368 if (!(s->options & SSL_OP_NO_TLSv1)) 360 if (!(s->options & SSL_OP_NO_TLSv1))
@@ -376,10 +368,21 @@ int ssl23_get_client_hello(SSL *s)
376 type=3; 368 type=3;
377 } 369 }
378 } 370 }
379 else if (!(s->options & SSL_OP_NO_SSLv3)) 371 else
380 { 372 {
381 s->version=SSL3_VERSION; 373 /* client requests SSL 3.0 */
382 type=3; 374 if (!(s->options & SSL_OP_NO_SSLv3))
375 {
376 s->version=SSL3_VERSION;
377 type=3;
378 }
379 else if (!(s->options & SSL_OP_NO_TLSv1))
380 {
381 /* we won't be able to use TLS of course,
382 * but this will send an appropriate alert */
383 s->version=TLS1_VERSION;
384 type=3;
385 }
383 } 386 }
384 } 387 }
385 else if ((strncmp("GET ", (char *)p,4) == 0) || 388 else if ((strncmp("GET ", (char *)p,4) == 0) ||
@@ -417,7 +420,9 @@ int ssl23_get_client_hello(SSL *s)
417 j=ssl23_read_bytes(s,n+2); 420 j=ssl23_read_bytes(s,n+2);
418 if (j <= 0) return(j); 421 if (j <= 0) return(j);
419 422
420 ssl3_finish_mac(s,&(s->packet[2]),s->packet_length-2); 423 ssl3_finish_mac(s, s->packet+2, s->packet_length-2);
424 if (s->msg_callback)
425 s->msg_callback(0, SSL2_VERSION, 0, s->packet+2, s->packet_length-2, s, s->msg_callback_arg); /* CLIENT-HELLO */
421 426
422 p=s->packet; 427 p=s->packet;
423 p+=5; 428 p+=5;
@@ -431,6 +436,13 @@ int ssl23_get_client_hello(SSL *s)
431 goto err; 436 goto err;
432 } 437 }
433 438
439 /* record header: msg_type ... */
440 *(d++) = SSL3_MT_CLIENT_HELLO;
441 /* ... and length (actual value will be written later) */
442 d_len = d;
443 d += 3;
444
445 /* client_version */
434 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ 446 *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */
435 *(d++) = v[1]; 447 *(d++) = v[1];
436 448
@@ -461,7 +473,8 @@ int ssl23_get_client_hello(SSL *s)
461 *(d++)=1; 473 *(d++)=1;
462 *(d++)=0; 474 *(d++)=0;
463 475
464 i=(d-(unsigned char *)s->init_buf->data); 476 i = (d-(unsigned char *)s->init_buf->data) - 4;
477 l2n3((long)i, d_len);
465 478
466 /* get the data reused from the init_buf */ 479 /* get the data reused from the init_buf */
467 s->s3->tmp.reuse_message=1; 480 s->s3->tmp.reuse_message=1;
@@ -474,7 +487,7 @@ int ssl23_get_client_hello(SSL *s)
474 487
475 if (type == 1) 488 if (type == 1)
476 { 489 {
477#ifdef NO_SSL2 490#ifdef OPENSSL_NO_SSL2
478 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); 491 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
479 goto err; 492 goto err;
480#else 493#else
diff --git a/src/lib/libssl/src/ssl/s2_clnt.c b/src/lib/libssl/src/ssl/s2_clnt.c
index 28d6d65296..4cb1184161 100644
--- a/src/lib/libssl/src/ssl/s2_clnt.c
+++ b/src/lib/libssl/src/ssl/s2_clnt.c
@@ -55,9 +55,62 @@
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 "ssl_locl.h" 112#include "ssl_locl.h"
60#ifndef NO_SSL2 113#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 114#include <stdio.h>
62#include <openssl/rand.h> 115#include <openssl/rand.h>
63#include <openssl/buffer.h> 116#include <openssl/buffer.h>
@@ -105,7 +158,7 @@ int ssl2_connect(SSL *s)
105 unsigned long l=time(NULL); 158 unsigned long l=time(NULL);
106 BUF_MEM *buf=NULL; 159 BUF_MEM *buf=NULL;
107 int ret= -1; 160 int ret= -1;
108 void (*cb)()=NULL; 161 void (*cb)(const SSL *ssl,int type,int val)=NULL;
109 int new_state,state; 162 int new_state,state;
110 163
111 RAND_add(&l,sizeof(l),0); 164 RAND_add(&l,sizeof(l),0);
@@ -118,8 +171,8 @@ int ssl2_connect(SSL *s)
118 cb=s->ctx->info_callback; 171 cb=s->ctx->info_callback;
119 172
120 /* init things to blank */ 173 /* init things to blank */
121 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
122 s->in_handshake++; 174 s->in_handshake++;
175 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
123 176
124 for (;;) 177 for (;;)
125 { 178 {
@@ -287,7 +340,8 @@ static int get_server_hello(SSL *s)
287 unsigned char *buf; 340 unsigned char *buf;
288 unsigned char *p; 341 unsigned char *p;
289 int i,j; 342 int i,j;
290 STACK_OF(SSL_CIPHER) *sk=NULL,*cl; 343 unsigned long len;
344 STACK_OF(SSL_CIPHER) *sk=NULL,*cl, *prio, *allow;
291 345
292 buf=(unsigned char *)s->init_buf->data; 346 buf=(unsigned char *)s->init_buf->data;
293 p=buf; 347 p=buf;
@@ -296,6 +350,7 @@ static int get_server_hello(SSL *s)
296 i=ssl2_read(s,(char *)&(buf[s->init_num]),11-s->init_num); 350 i=ssl2_read(s,(char *)&(buf[s->init_num]),11-s->init_num);
297 if (i < (11-s->init_num)) 351 if (i < (11-s->init_num))
298 return(ssl2_part_read(s,SSL_F_GET_SERVER_HELLO,i)); 352 return(ssl2_part_read(s,SSL_F_GET_SERVER_HELLO,i));
353 s->init_num = 11;
299 354
300 if (*(p++) != SSL2_MT_SERVER_HELLO) 355 if (*(p++) != SSL2_MT_SERVER_HELLO)
301 { 356 {
@@ -324,18 +379,24 @@ static int get_server_hello(SSL *s)
324 n2s(p,i); s->s2->tmp.csl=i; 379 n2s(p,i); s->s2->tmp.csl=i;
325 n2s(p,i); s->s2->tmp.conn_id_length=i; 380 n2s(p,i); s->s2->tmp.conn_id_length=i;
326 s->state=SSL2_ST_GET_SERVER_HELLO_B; 381 s->state=SSL2_ST_GET_SERVER_HELLO_B;
327 s->init_num=0;
328 } 382 }
329 383
330 /* SSL2_ST_GET_SERVER_HELLO_B */ 384 /* SSL2_ST_GET_SERVER_HELLO_B */
331 j=s->s2->tmp.cert_length+s->s2->tmp.csl+s->s2->tmp.conn_id_length 385 len = 11 + (unsigned long)s->s2->tmp.cert_length + (unsigned long)s->s2->tmp.csl + (unsigned long)s->s2->tmp.conn_id_length;
332 - s->init_num; 386 if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)
333 i=ssl2_read(s,(char *)&(buf[s->init_num]),j); 387 {
388 SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_MESSAGE_TOO_LONG);
389 return -1;
390 }
391 j = (int)len - s->init_num;
392 i = ssl2_read(s,(char *)&(buf[s->init_num]),j);
334 if (i != j) return(ssl2_part_read(s,SSL_F_GET_SERVER_HELLO,i)); 393 if (i != j) return(ssl2_part_read(s,SSL_F_GET_SERVER_HELLO,i));
394 if (s->msg_callback)
395 s->msg_callback(0, s->version, 0, buf, (size_t)len, s, s->msg_callback_arg); /* SERVER-HELLO */
335 396
336 /* things are looking good */ 397 /* things are looking good */
337 398
338 p=buf; 399 p = buf + 11;
339 if (s->hit) 400 if (s->hit)
340 { 401 {
341 if (s->s2->tmp.cert_length != 0) 402 if (s->s2->tmp.cert_length != 0)
@@ -414,33 +475,49 @@ static int get_server_hello(SSL *s)
414 sk_SSL_CIPHER_set_cmp_func(sk,ssl_cipher_ptr_id_cmp); 475 sk_SSL_CIPHER_set_cmp_func(sk,ssl_cipher_ptr_id_cmp);
415 476
416 /* get the array of ciphers we will accept */ 477 /* get the array of ciphers we will accept */
417 cl=ssl_get_ciphers_by_id(s); 478 cl=SSL_get_ciphers(s);
418 479 sk_SSL_CIPHER_set_cmp_func(cl,ssl_cipher_ptr_id_cmp);
480
481 /*
482 * If server preference flag set, choose the first
483 * (highest priority) cipher the server sends, otherwise
484 * client preference has priority.
485 */
486 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
487 {
488 prio = sk;
489 allow = cl;
490 }
491 else
492 {
493 prio = cl;
494 allow = sk;
495 }
419 /* In theory we could have ciphers sent back that we 496 /* In theory we could have ciphers sent back that we
420 * don't want to use but that does not matter since we 497 * don't want to use but that does not matter since we
421 * will check against the list we originally sent and 498 * will check against the list we originally sent and
422 * for performance reasons we should not bother to match 499 * for performance reasons we should not bother to match
423 * the two lists up just to check. */ 500 * the two lists up just to check. */
424 for (i=0; i<sk_SSL_CIPHER_num(cl); i++) 501 for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
425 { 502 {
426 if (sk_SSL_CIPHER_find(sk, 503 if (sk_SSL_CIPHER_find(allow,
427 sk_SSL_CIPHER_value(cl,i)) >= 0) 504 sk_SSL_CIPHER_value(prio,i)) >= 0)
428 break; 505 break;
429 } 506 }
430 507
431 if (i >= sk_SSL_CIPHER_num(cl)) 508 if (i >= sk_SSL_CIPHER_num(prio))
432 { 509 {
433 ssl2_return_error(s,SSL2_PE_NO_CIPHER); 510 ssl2_return_error(s,SSL2_PE_NO_CIPHER);
434 SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_NO_CIPHER_MATCH); 511 SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_NO_CIPHER_MATCH);
435 return(-1); 512 return(-1);
436 } 513 }
437 s->session->cipher=sk_SSL_CIPHER_value(cl,i); 514 s->session->cipher=sk_SSL_CIPHER_value(prio,i);
438 515
439 516
440 if (s->session->peer != NULL) /* can't happen*/ 517 if (s->session->peer != NULL) /* can't happen*/
441 { 518 {
442 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); 519 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
443 SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR); 520 SSLerr(SSL_F_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR);
444 return(-1); 521 return(-1);
445 } 522 }
446 523
@@ -453,7 +530,7 @@ static int get_server_hello(SSL *s)
453 /* can't happen */ 530 /* can't happen */
454 { 531 {
455 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); 532 ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
456 SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR); 533 SSLerr(SSL_F_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR);
457 return(-1); 534 return(-1);
458 } 535 }
459 536
@@ -645,11 +722,10 @@ static int client_certificate(SSL *s)
645 unsigned char *p,*d; 722 unsigned char *p,*d;
646 int i; 723 int i;
647 unsigned int n; 724 unsigned int n;
648 int cert_ch_len=0; 725 int cert_ch_len;
649 unsigned char *cert_ch; 726 unsigned char *cert_ch;
650 727
651 buf=(unsigned char *)s->init_buf->data; 728 buf=(unsigned char *)s->init_buf->data;
652 cert_ch= &(buf[2]);
653 729
654 /* We have a cert associated with the SSL, so attach it to 730 /* We have a cert associated with the SSL, so attach it to
655 * the session if it does not have one */ 731 * the session if it does not have one */
@@ -660,6 +736,9 @@ static int client_certificate(SSL *s)
660 SSL2_MAX_CERT_CHALLENGE_LENGTH+1-s->init_num); 736 SSL2_MAX_CERT_CHALLENGE_LENGTH+1-s->init_num);
661 if (i<(SSL2_MIN_CERT_CHALLENGE_LENGTH+1-s->init_num)) 737 if (i<(SSL2_MIN_CERT_CHALLENGE_LENGTH+1-s->init_num))
662 return(ssl2_part_read(s,SSL_F_CLIENT_CERTIFICATE,i)); 738 return(ssl2_part_read(s,SSL_F_CLIENT_CERTIFICATE,i));
739 s->init_num += i;
740 if (s->msg_callback)
741 s->msg_callback(0, s->version, 0, buf, (size_t)s->init_num, s, s->msg_callback_arg); /* REQUEST-CERTIFICATE */
663 742
664 /* type=buf[0]; */ 743 /* type=buf[0]; */
665 /* type eq x509 */ 744 /* type eq x509 */
@@ -669,7 +748,6 @@ static int client_certificate(SSL *s)
669 SSLerr(SSL_F_CLIENT_CERTIFICATE,SSL_R_BAD_AUTHENTICATION_TYPE); 748 SSLerr(SSL_F_CLIENT_CERTIFICATE,SSL_R_BAD_AUTHENTICATION_TYPE);
670 return(-1); 749 return(-1);
671 } 750 }
672 cert_ch_len=i-1;
673 751
674 if ((s->cert == NULL) || 752 if ((s->cert == NULL) ||
675 (s->cert->key->x509 == NULL) || 753 (s->cert->key->x509 == NULL) ||
@@ -681,6 +759,9 @@ static int client_certificate(SSL *s)
681 s->state=SSL2_ST_SEND_CLIENT_CERTIFICATE_C; 759 s->state=SSL2_ST_SEND_CLIENT_CERTIFICATE_C;
682 } 760 }
683 761
762 cert_ch = buf + 2;
763 cert_ch_len = s->init_num - 2;
764
684 if (s->state == SSL2_ST_X509_GET_CLIENT_CERTIFICATE) 765 if (s->state == SSL2_ST_X509_GET_CLIENT_CERTIFICATE)
685 { 766 {
686 X509 *x509=NULL; 767 X509 *x509=NULL;
@@ -750,7 +831,8 @@ static int client_certificate(SSL *s)
750 /* ok, now we calculate the checksum 831 /* ok, now we calculate the checksum
751 * do it first so we can reuse buf :-) */ 832 * do it first so we can reuse buf :-) */
752 p=buf; 833 p=buf;
753 EVP_SignInit(&ctx,s->ctx->rsa_md5); 834 EVP_MD_CTX_init(&ctx);
835 EVP_SignInit_ex(&ctx,s->ctx->rsa_md5, NULL);
754 EVP_SignUpdate(&ctx,s->s2->key_material, 836 EVP_SignUpdate(&ctx,s->s2->key_material,
755 (unsigned int)s->s2->key_material_length); 837 (unsigned int)s->s2->key_material_length);
756 EVP_SignUpdate(&ctx,cert_ch,(unsigned int)cert_ch_len); 838 EVP_SignUpdate(&ctx,cert_ch,(unsigned int)cert_ch_len);
@@ -771,7 +853,7 @@ static int client_certificate(SSL *s)
771 * We will continue with a 0 length signature 853 * We will continue with a 0 length signature
772 */ 854 */
773 } 855 }
774 memset(&ctx,0,sizeof(ctx)); 856 EVP_MD_CTX_cleanup(&ctx);
775 s2n(n,p); 857 s2n(n,p);
776 d+=n; 858 d+=n;
777 859
@@ -786,7 +868,7 @@ static int client_certificate(SSL *s)
786static int get_server_verify(SSL *s) 868static int get_server_verify(SSL *s)
787 { 869 {
788 unsigned char *p; 870 unsigned char *p;
789 int i; 871 int i, n, len;
790 872
791 p=(unsigned char *)s->init_buf->data; 873 p=(unsigned char *)s->init_buf->data;
792 if (s->state == SSL2_ST_GET_SERVER_VERIFY_A) 874 if (s->state == SSL2_ST_GET_SERVER_VERIFY_A)
@@ -794,9 +876,9 @@ static int get_server_verify(SSL *s)
794 i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num); 876 i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num);
795 if (i < (1-s->init_num)) 877 if (i < (1-s->init_num))
796 return(ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i)); 878 return(ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i));
879 s->init_num += i;
797 880
798 s->state= SSL2_ST_GET_SERVER_VERIFY_B; 881 s->state= SSL2_ST_GET_SERVER_VERIFY_B;
799 s->init_num=0;
800 if (*p != SSL2_MT_SERVER_VERIFY) 882 if (*p != SSL2_MT_SERVER_VERIFY)
801 { 883 {
802 if (p[0] != SSL2_MT_ERROR) 884 if (p[0] != SSL2_MT_ERROR)
@@ -806,17 +888,26 @@ static int get_server_verify(SSL *s)
806 SSL_R_READ_WRONG_PACKET_TYPE); 888 SSL_R_READ_WRONG_PACKET_TYPE);
807 } 889 }
808 else 890 else
809 SSLerr(SSL_F_GET_SERVER_VERIFY, 891 {
810 SSL_R_PEER_ERROR); 892 SSLerr(SSL_F_GET_SERVER_VERIFY,SSL_R_PEER_ERROR);
893 /* try to read the error message */
894 i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
895 return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
896 }
811 return(-1); 897 return(-1);
812 } 898 }
813 } 899 }
814 900
815 p=(unsigned char *)s->init_buf->data; 901 p=(unsigned char *)s->init_buf->data;
816 i=ssl2_read(s,(char *)&(p[s->init_num]), 902 len = 1 + s->s2->challenge_length;
817 (unsigned int)s->s2->challenge_length-s->init_num); 903 n = len - s->init_num;
818 if (i < ((int)s->s2->challenge_length-s->init_num)) 904 i = ssl2_read(s,(char *)&(p[s->init_num]),n);
905 if (i < n)
819 return(ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i)); 906 return(ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i));
907 if (s->msg_callback)
908 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* SERVER-VERIFY */
909 p += 1;
910
820 if (memcmp(p,s->s2->challenge,(unsigned int)s->s2->challenge_length) != 0) 911 if (memcmp(p,s->s2->challenge,(unsigned int)s->s2->challenge_length) != 0)
821 { 912 {
822 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 913 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
@@ -830,7 +921,7 @@ static int get_server_finished(SSL *s)
830 { 921 {
831 unsigned char *buf; 922 unsigned char *buf;
832 unsigned char *p; 923 unsigned char *p;
833 int i; 924 int i, n, len;
834 925
835 buf=(unsigned char *)s->init_buf->data; 926 buf=(unsigned char *)s->init_buf->data;
836 p=buf; 927 p=buf;
@@ -839,7 +930,8 @@ static int get_server_finished(SSL *s)
839 i=ssl2_read(s,(char *)&(buf[s->init_num]),1-s->init_num); 930 i=ssl2_read(s,(char *)&(buf[s->init_num]),1-s->init_num);
840 if (i < (1-s->init_num)) 931 if (i < (1-s->init_num))
841 return(ssl2_part_read(s,SSL_F_GET_SERVER_FINISHED,i)); 932 return(ssl2_part_read(s,SSL_F_GET_SERVER_FINISHED,i));
842 s->init_num=i; 933 s->init_num += i;
934
843 if (*p == SSL2_MT_REQUEST_CERTIFICATE) 935 if (*p == SSL2_MT_REQUEST_CERTIFICATE)
844 { 936 {
845 s->state=SSL2_ST_SEND_CLIENT_CERTIFICATE_A; 937 s->state=SSL2_ST_SEND_CLIENT_CERTIFICATE_A;
@@ -853,17 +945,25 @@ static int get_server_finished(SSL *s)
853 SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE); 945 SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE);
854 } 946 }
855 else 947 else
948 {
856 SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_PEER_ERROR); 949 SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_PEER_ERROR);
950 /* try to read the error message */
951 i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
952 return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
953 }
857 return(-1); 954 return(-1);
858 } 955 }
859 s->state=SSL_ST_OK; 956 s->state=SSL2_ST_GET_SERVER_FINISHED_B;
860 s->init_num=0;
861 } 957 }
862 958
863 i=ssl2_read(s,(char *)&(buf[s->init_num]), 959 len = 1 + SSL2_SSL_SESSION_ID_LENGTH;
864 SSL2_SSL_SESSION_ID_LENGTH-s->init_num); 960 n = len - s->init_num;
865 if (i < (SSL2_SSL_SESSION_ID_LENGTH-s->init_num)) 961 i = ssl2_read(s,(char *)&(buf[s->init_num]), n);
962 if (i < n) /* XXX could be shorter than SSL2_SSL_SESSION_ID_LENGTH, that's the maximum */
866 return(ssl2_part_read(s,SSL_F_GET_SERVER_FINISHED,i)); 963 return(ssl2_part_read(s,SSL_F_GET_SERVER_FINISHED,i));
964 s->init_num += i;
965 if (s->msg_callback)
966 s->msg_callback(0, s->version, 0, buf, (size_t)s->init_num, s, s->msg_callback_arg); /* SERVER-FINISHED */
867 967
868 if (!s->hit) /* new session */ 968 if (!s->hit) /* new session */
869 { 969 {
@@ -887,6 +987,7 @@ static int get_server_finished(SSL *s)
887 } 987 }
888 } 988 }
889 } 989 }
990 s->state = SSL_ST_OK;
890 return(1); 991 return(1);
891 } 992 }
892 993
@@ -985,7 +1086,7 @@ end:
985 EVP_PKEY_free(pkey); 1086 EVP_PKEY_free(pkey);
986 return(i); 1087 return(i);
987 } 1088 }
988#else /* !NO_SSL2 */ 1089#else /* !OPENSSL_NO_SSL2 */
989 1090
990# if PEDANTIC 1091# if PEDANTIC
991static void *dummy=&dummy; 1092static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s2_enc.c b/src/lib/libssl/src/ssl/s2_enc.c
index 35acdf8276..a28e747d2d 100644
--- a/src/lib/libssl/src/ssl/s2_enc.c
+++ b/src/lib/libssl/src/ssl/s2_enc.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#include "ssl_locl.h" 59#include "ssl_locl.h"
60#ifndef NO_SSL2 60#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 61#include <stdio.h>
62 62
63int ssl2_enc_init(SSL *s, int client) 63int ssl2_enc_init(SSL *s, int client)
@@ -98,9 +98,9 @@ int ssl2_enc_init(SSL *s, int client)
98 98
99 ssl2_generate_key_material(s); 99 ssl2_generate_key_material(s);
100 100
101 EVP_EncryptInit(ws,c,&(s->s2->key_material[(client)?num:0]), 101 EVP_EncryptInit_ex(ws,c,NULL,&(s->s2->key_material[(client)?num:0]),
102 s->session->key_arg); 102 s->session->key_arg);
103 EVP_DecryptInit(rs,c,&(s->s2->key_material[(client)?0:num]), 103 EVP_DecryptInit_ex(rs,c,NULL,&(s->s2->key_material[(client)?0:num]),
104 s->session->key_arg); 104 s->session->key_arg);
105 s->s2->read_key= &(s->s2->key_material[(client)?0:num]); 105 s->s2->read_key= &(s->s2->key_material[(client)?0:num]);
106 s->s2->write_key= &(s->s2->key_material[(client)?num:0]); 106 s->s2->write_key= &(s->s2->key_material[(client)?num:0]);
@@ -111,8 +111,8 @@ err:
111 } 111 }
112 112
113/* read/writes from s->s2->mac_data using length for encrypt and 113/* read/writes from s->s2->mac_data using length for encrypt and
114 * decrypt. It sets the s->s2->padding, s->[rw]length and 114 * decrypt. It sets s->s2->padding and s->[rw]length
115 * s->s2->pad_data ptr if we are encrypting */ 115 * if we are encrypting */
116void ssl2_enc(SSL *s, int send) 116void ssl2_enc(SSL *s, int send)
117 { 117 {
118 EVP_CIPHER_CTX *ds; 118 EVP_CIPHER_CTX *ds;
@@ -169,16 +169,17 @@ void ssl2_mac(SSL *s, unsigned char *md, int send)
169 l2n(seq,p); 169 l2n(seq,p);
170 170
171 /* There has to be a MAC algorithm. */ 171 /* There has to be a MAC algorithm. */
172 EVP_DigestInit(&c,s->read_hash); 172 EVP_MD_CTX_init(&c);
173 EVP_DigestInit_ex(&c, s->read_hash, NULL);
173 EVP_DigestUpdate(&c,sec, 174 EVP_DigestUpdate(&c,sec,
174 EVP_CIPHER_CTX_key_length(s->enc_read_ctx)); 175 EVP_CIPHER_CTX_key_length(s->enc_read_ctx));
175 EVP_DigestUpdate(&c,act,len); 176 EVP_DigestUpdate(&c,act,len);
176 /* the above line also does the pad data */ 177 /* the above line also does the pad data */
177 EVP_DigestUpdate(&c,sequence,4); 178 EVP_DigestUpdate(&c,sequence,4);
178 EVP_DigestFinal(&c,md,NULL); 179 EVP_DigestFinal_ex(&c,md,NULL);
179 /* some would say I should zero the md context */ 180 EVP_MD_CTX_cleanup(&c);
180 } 181 }
181#else /* !NO_SSL2 */ 182#else /* !OPENSSL_NO_SSL2 */
182 183
183# if PEDANTIC 184# if PEDANTIC
184static void *dummy=&dummy; 185static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s2_lib.c b/src/lib/libssl/src/ssl/s2_lib.c
index a590dbfa5c..bce2b4e83f 100644
--- a/src/lib/libssl/src/ssl/s2_lib.c
+++ b/src/lib/libssl/src/ssl/s2_lib.c
@@ -57,10 +57,11 @@
57 */ 57 */
58 58
59#include "ssl_locl.h" 59#include "ssl_locl.h"
60#ifndef NO_SSL2 60#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 61#include <stdio.h>
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/evp.h>
64#include <openssl/md5.h> 65#include <openssl/md5.h>
65 66
66static long ssl2_default_timeout(void ); 67static long ssl2_default_timeout(void );
@@ -329,7 +330,7 @@ void ssl2_clear(SSL *s)
329 s->packet_length=0; 330 s->packet_length=0;
330 } 331 }
331 332
332long ssl2_ctrl(SSL *s, int cmd, long larg, char *parg) 333long ssl2_ctrl(SSL *s, int cmd, long larg, void *parg)
333 { 334 {
334 int ret=0; 335 int ret=0;
335 336
@@ -349,7 +350,7 @@ long ssl2_callback_ctrl(SSL *s, int cmd, void (*fp)())
349 return(0); 350 return(0);
350 } 351 }
351 352
352long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg) 353long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
353 { 354 {
354 return(0); 355 return(0);
355 } 356 }
@@ -415,7 +416,7 @@ int ssl2_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
415void ssl2_generate_key_material(SSL *s) 416void ssl2_generate_key_material(SSL *s)
416 { 417 {
417 unsigned int i; 418 unsigned int i;
418 MD5_CTX ctx; 419 EVP_MD_CTX ctx;
419 unsigned char *km; 420 unsigned char *km;
420 unsigned char c='0'; 421 unsigned char c='0';
421 422
@@ -423,20 +424,21 @@ void ssl2_generate_key_material(SSL *s)
423 c = os_toascii['0']; /* Must be an ASCII '0', not EBCDIC '0', 424 c = os_toascii['0']; /* Must be an ASCII '0', not EBCDIC '0',
424 see SSLv2 docu */ 425 see SSLv2 docu */
425#endif 426#endif
426 427 EVP_MD_CTX_init(&ctx);
427 km=s->s2->key_material; 428 km=s->s2->key_material;
428 for (i=0; i<s->s2->key_material_length; i+=MD5_DIGEST_LENGTH) 429 for (i=0; i<s->s2->key_material_length; i+=MD5_DIGEST_LENGTH)
429 { 430 {
430 MD5_Init(&ctx); 431 EVP_DigestInit_ex(&ctx,EVP_md5(), NULL);
431 432
432 MD5_Update(&ctx,s->session->master_key,s->session->master_key_length); 433 EVP_DigestUpdate(&ctx,s->session->master_key,s->session->master_key_length);
433 MD5_Update(&ctx,&c,1); 434 EVP_DigestUpdate(&ctx,&c,1);
434 c++; 435 c++;
435 MD5_Update(&ctx,s->s2->challenge,s->s2->challenge_length); 436 EVP_DigestUpdate(&ctx,s->s2->challenge,s->s2->challenge_length);
436 MD5_Update(&ctx,s->s2->conn_id,s->s2->conn_id_length); 437 EVP_DigestUpdate(&ctx,s->s2->conn_id,s->s2->conn_id_length);
437 MD5_Final(km,&ctx); 438 EVP_DigestFinal_ex(&ctx,km,NULL);
438 km+=MD5_DIGEST_LENGTH; 439 km+=MD5_DIGEST_LENGTH;
439 } 440 }
441 EVP_MD_CTX_cleanup(&ctx);
440 } 442 }
441 443
442void ssl2_return_error(SSL *s, int err) 444void ssl2_return_error(SSL *s, int err)
@@ -468,10 +470,14 @@ void ssl2_write_error(SSL *s)
468 470
469 if (i < 0) 471 if (i < 0)
470 s->error=error; 472 s->error=error;
471 else if (i != s->error) 473 else
474 {
472 s->error=error-i; 475 s->error=error-i;
473 /* else 476
474 s->error=0; */ 477 if (s->error == 0)
478 if (s->msg_callback)
479 s->msg_callback(1, s->version, 0, buf, 3, s, s->msg_callback_arg); /* ERROR */
480 }
475 } 481 }
476 482
477int ssl2_shutdown(SSL *s) 483int ssl2_shutdown(SSL *s)
@@ -479,7 +485,7 @@ int ssl2_shutdown(SSL *s)
479 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); 485 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
480 return(1); 486 return(1);
481 } 487 }
482#else /* !NO_SSL2 */ 488#else /* !OPENSSL_NO_SSL2 */
483 489
484# if PEDANTIC 490# if PEDANTIC
485static void *dummy=&dummy; 491static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s2_meth.c b/src/lib/libssl/src/ssl/s2_meth.c
index deb9e1d6f3..d30b7179f7 100644
--- a/src/lib/libssl/src/ssl/s2_meth.c
+++ b/src/lib/libssl/src/ssl/s2_meth.c
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#include "ssl_locl.h" 59#include "ssl_locl.h"
60#ifndef NO_SSL2 60#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 61#include <stdio.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63 63
@@ -86,7 +86,7 @@ SSL_METHOD *SSLv2_method(void)
86 } 86 }
87 return(&SSLv2_data); 87 return(&SSLv2_data);
88 } 88 }
89#else /* !NO_SSL2 */ 89#else /* !OPENSSL_NO_SSL2 */
90 90
91# if PEDANTIC 91# if PEDANTIC
92static void *dummy=&dummy; 92static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s2_pkt.c b/src/lib/libssl/src/ssl/s2_pkt.c
index f2f46ff377..cf0aee2bd6 100644
--- a/src/lib/libssl/src/ssl/s2_pkt.c
+++ b/src/lib/libssl/src/ssl/s2_pkt.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
@@ -110,7 +110,7 @@
110 */ 110 */
111 111
112#include "ssl_locl.h" 112#include "ssl_locl.h"
113#ifndef NO_SSL2 113#ifndef OPENSSL_NO_SSL2
114#include <stdio.h> 114#include <stdio.h>
115#include <errno.h> 115#include <errno.h>
116#define USE_SOCKETS 116#define USE_SOCKETS
@@ -130,7 +130,7 @@ static int ssl2_read_internal(SSL *s, void *buf, int len, int peek)
130 unsigned char mac[MAX_MAC_SIZE]; 130 unsigned char mac[MAX_MAC_SIZE];
131 unsigned char *p; 131 unsigned char *p;
132 int i; 132 int i;
133 unsigned int mac_size=0; 133 unsigned int mac_size;
134 134
135 ssl2_read_again: 135 ssl2_read_again:
136 if (SSL_in_init(s) && !s->in_handshake) 136 if (SSL_in_init(s) && !s->in_handshake)
@@ -235,17 +235,25 @@ static int ssl2_read_internal(SSL *s, void *buf, int len, int peek)
235 /* Data portion */ 235 /* Data portion */
236 if (s->s2->clear_text) 236 if (s->s2->clear_text)
237 { 237 {
238 mac_size = 0;
238 s->s2->mac_data=p; 239 s->s2->mac_data=p;
239 s->s2->ract_data=p; 240 s->s2->ract_data=p;
240 s->s2->pad_data=NULL; 241 if (s->s2->padding)
242 {
243 SSLerr(SSL_F_SSL2_READ_INTERNAL,SSL_R_ILLEGAL_PADDING);
244 return(-1);
245 }
241 } 246 }
242 else 247 else
243 { 248 {
244 mac_size=EVP_MD_size(s->read_hash); 249 mac_size=EVP_MD_size(s->read_hash);
245 s->s2->mac_data=p; 250 s->s2->mac_data=p;
246 s->s2->ract_data= &p[mac_size]; 251 s->s2->ract_data= &p[mac_size];
247 s->s2->pad_data= &p[mac_size+ 252 if (s->s2->padding + mac_size > s->s2->rlength)
248 s->s2->rlength-s->s2->padding]; 253 {
254 SSLerr(SSL_F_SSL2_READ_INTERNAL,SSL_R_ILLEGAL_PADDING);
255 return(-1);
256 }
249 } 257 }
250 258
251 s->s2->ract_data_length=s->s2->rlength; 259 s->s2->ract_data_length=s->s2->rlength;
@@ -593,10 +601,8 @@ static int do_ssl_write(SSL *s, const unsigned char *buf, unsigned int len)
593 s->s2->wact_data= &(s->s2->wbuf[3+mac_size]); 601 s->s2->wact_data= &(s->s2->wbuf[3+mac_size]);
594 /* we copy the data into s->s2->wbuf */ 602 /* we copy the data into s->s2->wbuf */
595 memcpy(s->s2->wact_data,buf,len); 603 memcpy(s->s2->wact_data,buf,len);
596#ifdef PURIFY
597 if (p) 604 if (p)
598 memset(&(s->s2->wact_data[len]),0,p); 605 memset(&(s->s2->wact_data[len]),0,p); /* arbitrary padding */
599#endif
600 606
601 if (!s->s2->clear_text) 607 if (!s->s2->clear_text)
602 { 608 {
@@ -645,27 +651,36 @@ int ssl2_part_read(SSL *s, unsigned long f, int i)
645 unsigned char *p; 651 unsigned char *p;
646 int j; 652 int j;
647 653
648 /* check for error */
649 if ((s->init_num == 0) && (i >= 3))
650 {
651 p=(unsigned char *)s->init_buf->data;
652 if (p[0] == SSL2_MT_ERROR)
653 {
654 j=(p[1]<<8)|p[2];
655 SSLerr((int)f,ssl_mt_error(j));
656 }
657 }
658
659 if (i < 0) 654 if (i < 0)
660 { 655 {
661 /* ssl2_return_error(s); */ 656 /* ssl2_return_error(s); */
662 /* for non-blocking io, 657 /* for non-blocking io,
663 * this is not fatal */ 658 * this is not necessarily fatal */
664 return(i); 659 return(i);
665 } 660 }
666 else 661 else
667 { 662 {
668 s->init_num+=i; 663 s->init_num+=i;
664
665 /* Check for error. While there are recoverable errors,
666 * this function is not called when those must be expected;
667 * any error detected here is fatal. */
668 if (s->init_num >= 3)
669 {
670 p=(unsigned char *)s->init_buf->data;
671 if (p[0] == SSL2_MT_ERROR)
672 {
673 j=(p[1]<<8)|p[2];
674 SSLerr((int)f,ssl_mt_error(j));
675 s->init_num -= 3;
676 if (s->init_num > 0)
677 memmove(p, p+3, s->init_num);
678 }
679 }
680
681 /* If it's not an error message, we have some error anyway --
682 * the message was shorter than expected. This too is treated
683 * as fatal (at least if SSL_get_error is asked for its opinion). */
669 return(0); 684 return(0);
670 } 685 }
671 } 686 }
@@ -676,7 +691,11 @@ int ssl2_do_write(SSL *s)
676 691
677 ret=ssl2_write(s,&s->init_buf->data[s->init_off],s->init_num); 692 ret=ssl2_write(s,&s->init_buf->data[s->init_off],s->init_num);
678 if (ret == s->init_num) 693 if (ret == s->init_num)
694 {
695 if (s->msg_callback)
696 s->msg_callback(1, s->version, 0, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg);
679 return(1); 697 return(1);
698 }
680 if (ret < 0) 699 if (ret < 0)
681 return(-1); 700 return(-1);
682 s->init_off+=ret; 701 s->init_off+=ret;
@@ -708,7 +727,7 @@ static int ssl_mt_error(int n)
708 } 727 }
709 return(ret); 728 return(ret);
710 } 729 }
711#else /* !NO_SSL2 */ 730#else /* !OPENSSL_NO_SSL2 */
712 731
713# if PEDANTIC 732# if PEDANTIC
714static void *dummy=&dummy; 733static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s2_srvr.c b/src/lib/libssl/src/ssl/s2_srvr.c
index 2fa2f310a8..56da65195e 100644
--- a/src/lib/libssl/src/ssl/s2_srvr.c
+++ b/src/lib/libssl/src/ssl/s2_srvr.c
@@ -55,9 +55,62 @@
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 "ssl_locl.h" 112#include "ssl_locl.h"
60#ifndef NO_SSL2 113#ifndef OPENSSL_NO_SSL2
61#include <stdio.h> 114#include <stdio.h>
62#include <openssl/bio.h> 115#include <openssl/bio.h>
63#include <openssl/rand.h> 116#include <openssl/rand.h>
@@ -106,7 +159,7 @@ int ssl2_accept(SSL *s)
106 BUF_MEM *buf=NULL; 159 BUF_MEM *buf=NULL;
107 int ret= -1; 160 int ret= -1;
108 long num1; 161 long num1;
109 void (*cb)()=NULL; 162 void (*cb)(const SSL *ssl,int type,int val)=NULL;
110 int new_state,state; 163 int new_state,state;
111 164
112 RAND_add(&l,sizeof(l),0); 165 RAND_add(&l,sizeof(l),0);
@@ -119,8 +172,8 @@ int ssl2_accept(SSL *s)
119 cb=s->ctx->info_callback; 172 cb=s->ctx->info_callback;
120 173
121 /* init things to blank */ 174 /* init things to blank */
122 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
123 s->in_handshake++; 175 s->in_handshake++;
176 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
124 177
125 if (s->cert == NULL) 178 if (s->cert == NULL)
126 { 179 {
@@ -322,6 +375,7 @@ end:
322static int get_client_master_key(SSL *s) 375static int get_client_master_key(SSL *s)
323 { 376 {
324 int is_export,i,n,keya,ek; 377 int is_export,i,n,keya,ek;
378 unsigned long len;
325 unsigned char *p; 379 unsigned char *p;
326 SSL_CIPHER *cp; 380 SSL_CIPHER *cp;
327 const EVP_CIPHER *c; 381 const EVP_CIPHER *c;
@@ -334,6 +388,8 @@ static int get_client_master_key(SSL *s)
334 388
335 if (i < (10-s->init_num)) 389 if (i < (10-s->init_num))
336 return(ssl2_part_read(s,SSL_F_GET_CLIENT_MASTER_KEY,i)); 390 return(ssl2_part_read(s,SSL_F_GET_CLIENT_MASTER_KEY,i));
391 s->init_num = 10;
392
337 if (*(p++) != SSL2_MT_CLIENT_MASTER_KEY) 393 if (*(p++) != SSL2_MT_CLIENT_MASTER_KEY)
338 { 394 {
339 if (p[-1] != SSL2_MT_ERROR) 395 if (p[-1] != SSL2_MT_ERROR)
@@ -362,15 +418,23 @@ static int get_client_master_key(SSL *s)
362 n2s(p,i); s->s2->tmp.enc=i; 418 n2s(p,i); s->s2->tmp.enc=i;
363 n2s(p,i); s->session->key_arg_length=i; 419 n2s(p,i); s->session->key_arg_length=i;
364 s->state=SSL2_ST_GET_CLIENT_MASTER_KEY_B; 420 s->state=SSL2_ST_GET_CLIENT_MASTER_KEY_B;
365 s->init_num=0;
366 } 421 }
367 422
368 /* SSL2_ST_GET_CLIENT_MASTER_KEY_B */ 423 /* SSL2_ST_GET_CLIENT_MASTER_KEY_B */
369 p=(unsigned char *)s->init_buf->data; 424 p=(unsigned char *)s->init_buf->data;
370 keya=s->session->key_arg_length; 425 keya=s->session->key_arg_length;
371 n=s->s2->tmp.clear+s->s2->tmp.enc+keya - s->init_num; 426 len = 10 + (unsigned long)s->s2->tmp.clear + (unsigned long)s->s2->tmp.enc + (unsigned long)keya;
372 i=ssl2_read(s,(char *)&(p[s->init_num]),n); 427 if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)
428 {
429 SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,SSL_R_MESSAGE_TOO_LONG);
430 return -1;
431 }
432 n = (int)len - s->init_num;
433 i = ssl2_read(s,(char *)&(p[s->init_num]),n);
373 if (i != n) return(ssl2_part_read(s,SSL_F_GET_CLIENT_MASTER_KEY,i)); 434 if (i != n) return(ssl2_part_read(s,SSL_F_GET_CLIENT_MASTER_KEY,i));
435 if (s->msg_callback)
436 s->msg_callback(0, s->version, 0, p, (size_t)len, s, s->msg_callback_arg); /* CLIENT-MASTER-KEY */
437 p += 10;
374 438
375 memcpy(s->session->key_arg,&(p[s->s2->tmp.clear+s->s2->tmp.enc]), 439 memcpy(s->session->key_arg,&(p[s->s2->tmp.clear+s->s2->tmp.enc]),
376 (unsigned int)keya); 440 (unsigned int)keya);
@@ -408,8 +472,8 @@ static int get_client_master_key(SSL *s)
408 * random master secret (Bleichenbacher attack) */ 472 * random master secret (Bleichenbacher attack) */
409 if ((i < 0) || 473 if ((i < 0) ||
410 ((!is_export && (i != EVP_CIPHER_key_length(c))) 474 ((!is_export && (i != EVP_CIPHER_key_length(c)))
411 || (is_export && ((i != ek) || (s->s2->tmp.clear+i != 475 || (is_export && ((i != ek) || (s->s2->tmp.clear+(unsigned int)i !=
412 EVP_CIPHER_key_length(c)))))) 476 (unsigned int)EVP_CIPHER_key_length(c))))))
413 { 477 {
414 ERR_clear_error(); 478 ERR_clear_error();
415 if (is_export) 479 if (is_export)
@@ -448,9 +512,11 @@ static int get_client_master_key(SSL *s)
448static int get_client_hello(SSL *s) 512static int get_client_hello(SSL *s)
449 { 513 {
450 int i,n; 514 int i,n;
515 unsigned long len;
451 unsigned char *p; 516 unsigned char *p;
452 STACK_OF(SSL_CIPHER) *cs; /* a stack of SSL_CIPHERS */ 517 STACK_OF(SSL_CIPHER) *cs; /* a stack of SSL_CIPHERS */
453 STACK_OF(SSL_CIPHER) *cl; /* the ones we want to use */ 518 STACK_OF(SSL_CIPHER) *cl; /* the ones we want to use */
519 STACK_OF(SSL_CIPHER) *prio, *allow;
454 int z; 520 int z;
455 521
456 /* This is a bit of a hack to check for the correct packet 522 /* This is a bit of a hack to check for the correct packet
@@ -467,6 +533,7 @@ static int get_client_hello(SSL *s)
467 i=ssl2_read(s,(char *)&(p[s->init_num]),9-s->init_num); 533 i=ssl2_read(s,(char *)&(p[s->init_num]),9-s->init_num);
468 if (i < (9-s->init_num)) 534 if (i < (9-s->init_num))
469 return(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i)); 535 return(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i));
536 s->init_num = 9;
470 537
471 if (*(p++) != SSL2_MT_CLIENT_HELLO) 538 if (*(p++) != SSL2_MT_CLIENT_HELLO)
472 { 539 {
@@ -491,15 +558,22 @@ static int get_client_hello(SSL *s)
491 return(-1); 558 return(-1);
492 } 559 }
493 s->state=SSL2_ST_GET_CLIENT_HELLO_C; 560 s->state=SSL2_ST_GET_CLIENT_HELLO_C;
494 s->init_num=0;
495 } 561 }
496 562
497 /* SSL2_ST_GET_CLIENT_HELLO_C */ 563 /* SSL2_ST_GET_CLIENT_HELLO_C */
498 p=(unsigned char *)s->init_buf->data; 564 p=(unsigned char *)s->init_buf->data;
499 n=s->s2->tmp.cipher_spec_length+s->s2->challenge_length+ 565 len = 9 + (unsigned long)s->s2->tmp.cipher_spec_length + (unsigned long)s->s2->challenge_length + (unsigned long)s->s2->tmp.session_id_length;
500 s->s2->tmp.session_id_length-s->init_num; 566 if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)
501 i=ssl2_read(s,(char *)&(p[s->init_num]),n); 567 {
568 SSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_MESSAGE_TOO_LONG);
569 return -1;
570 }
571 n = (int)len - s->init_num;
572 i = ssl2_read(s,(char *)&(p[s->init_num]),n);
502 if (i != n) return(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i)); 573 if (i != n) return(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i));
574 if (s->msg_callback)
575 s->msg_callback(0, s->version, 0, p, (size_t)len, s, s->msg_callback_arg); /* CLIENT-HELLO */
576 p += 9;
503 577
504 /* get session-id before cipher stuff so we can get out session 578 /* get session-id before cipher stuff so we can get out session
505 * structure if it is cached */ 579 * structure if it is cached */
@@ -556,21 +630,37 @@ static int get_client_hello(SSL *s)
556 &s->session->ciphers); 630 &s->session->ciphers);
557 if (cs == NULL) goto mem_err; 631 if (cs == NULL) goto mem_err;
558 632
559 cl=ssl_get_ciphers_by_id(s); 633 cl=SSL_get_ciphers(s);
560 634
561 for (z=0; z<sk_SSL_CIPHER_num(cs); z++) 635 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
636 {
637 prio=sk_SSL_CIPHER_dup(cl);
638 if (prio == NULL) goto mem_err;
639 allow = cs;
640 }
641 else
642 {
643 prio = cs;
644 allow = cl;
645 }
646 for (z=0; z<sk_SSL_CIPHER_num(prio); z++)
562 { 647 {
563 if (sk_SSL_CIPHER_find(cl,sk_SSL_CIPHER_value(cs,z)) < 0) 648 if (sk_SSL_CIPHER_find(allow,sk_SSL_CIPHER_value(prio,z)) < 0)
564 { 649 {
565 sk_SSL_CIPHER_delete(cs,z); 650 sk_SSL_CIPHER_delete(prio,z);
566 z--; 651 z--;
567 } 652 }
568 } 653 }
569 654 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
655 {
656 sk_SSL_CIPHER_free(s->session->ciphers);
657 s->session->ciphers = prio;
658 }
570 /* s->session->ciphers should now have a list of 659 /* s->session->ciphers should now have a list of
571 * ciphers that are on both the client and server. 660 * ciphers that are on both the client and server.
572 * This list is ordered by the order the client sent 661 * This list is ordered by the order the client sent
573 * the ciphers. 662 * the ciphers or in the order of the server's preference
663 * if SSL_OP_CIPHER_SERVER_PREFERENCE was set.
574 */ 664 */
575 } 665 }
576 p+=s->s2->tmp.cipher_spec_length; 666 p+=s->s2->tmp.cipher_spec_length;
@@ -705,7 +795,8 @@ static int server_hello(SSL *s)
705static int get_client_finished(SSL *s) 795static int get_client_finished(SSL *s)
706 { 796 {
707 unsigned char *p; 797 unsigned char *p;
708 int i; 798 int i, n;
799 unsigned long len;
709 800
710 p=(unsigned char *)s->init_buf->data; 801 p=(unsigned char *)s->init_buf->data;
711 if (s->state == SSL2_ST_GET_CLIENT_FINISHED_A) 802 if (s->state == SSL2_ST_GET_CLIENT_FINISHED_A)
@@ -713,6 +804,7 @@ static int get_client_finished(SSL *s)
713 i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num); 804 i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num);
714 if (i < 1-s->init_num) 805 if (i < 1-s->init_num)
715 return(ssl2_part_read(s,SSL_F_GET_CLIENT_FINISHED,i)); 806 return(ssl2_part_read(s,SSL_F_GET_CLIENT_FINISHED,i));
807 s->init_num += i;
716 808
717 if (*p != SSL2_MT_CLIENT_FINISHED) 809 if (*p != SSL2_MT_CLIENT_FINISHED)
718 { 810 {
@@ -722,19 +814,28 @@ static int get_client_finished(SSL *s)
722 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE); 814 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE);
723 } 815 }
724 else 816 else
817 {
725 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_PEER_ERROR); 818 SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_PEER_ERROR);
819 /* try to read the error message */
820 i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
821 return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
822 }
726 return(-1); 823 return(-1);
727 } 824 }
728 s->init_num=0;
729 s->state=SSL2_ST_GET_CLIENT_FINISHED_B; 825 s->state=SSL2_ST_GET_CLIENT_FINISHED_B;
730 } 826 }
731 827
732 /* SSL2_ST_GET_CLIENT_FINISHED_B */ 828 /* SSL2_ST_GET_CLIENT_FINISHED_B */
733 i=ssl2_read(s,(char *)&(p[s->init_num]),s->s2->conn_id_length-s->init_num); 829 len = 1 + (unsigned long)s->s2->conn_id_length;
734 if (i < (int)s->s2->conn_id_length-s->init_num) 830 n = (int)len - s->init_num;
831 i = ssl2_read(s,(char *)&(p[s->init_num]),n);
832 if (i < n)
735 { 833 {
736 return(ssl2_part_read(s,SSL_F_GET_CLIENT_FINISHED,i)); 834 return(ssl2_part_read(s,SSL_F_GET_CLIENT_FINISHED,i));
737 } 835 }
836 if (s->msg_callback)
837 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* CLIENT-FINISHED */
838 p += 1;
738 if (memcmp(p,s->s2->conn_id,(unsigned int)s->s2->conn_id_length) != 0) 839 if (memcmp(p,s->s2->conn_id,(unsigned int)s->s2->conn_id_length) != 0)
739 { 840 {
740 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 841 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
@@ -790,6 +891,7 @@ static int request_certificate(SSL *s)
790 unsigned char *p,*p2,*buf2; 891 unsigned char *p,*p2,*buf2;
791 unsigned char *ccd; 892 unsigned char *ccd;
792 int i,j,ctype,ret= -1; 893 int i,j,ctype,ret= -1;
894 unsigned long len;
793 X509 *x509=NULL; 895 X509 *x509=NULL;
794 STACK_OF(X509) *sk=NULL; 896 STACK_OF(X509) *sk=NULL;
795 897
@@ -823,16 +925,31 @@ static int request_certificate(SSL *s)
823 if (s->state == SSL2_ST_SEND_REQUEST_CERTIFICATE_C) 925 if (s->state == SSL2_ST_SEND_REQUEST_CERTIFICATE_C)
824 { 926 {
825 p=(unsigned char *)s->init_buf->data; 927 p=(unsigned char *)s->init_buf->data;
826 i=ssl2_read(s,(char *)&(p[s->init_num]),6-s->init_num); 928 i=ssl2_read(s,(char *)&(p[s->init_num]),6-s->init_num); /* try to read 6 octets ... */
827 if (i < 3) 929 if (i < 3-s->init_num) /* ... but don't call ssl2_part_read now if we got at least 3
930 * (probably NO-CERTIFICATE-ERROR) */
828 { 931 {
829 ret=ssl2_part_read(s,SSL_F_REQUEST_CERTIFICATE,i); 932 ret=ssl2_part_read(s,SSL_F_REQUEST_CERTIFICATE,i);
830 goto end; 933 goto end;
831 } 934 }
935 s->init_num += i;
832 936
833 if ((*p == SSL2_MT_ERROR) && (i >= 3)) 937 if ((s->init_num >= 3) && (p[0] == SSL2_MT_ERROR))
834 { 938 {
835 n2s(p,i); 939 n2s(p,i);
940 if (i != SSL2_PE_NO_CERTIFICATE)
941 {
942 /* not the error message we expected -- let ssl2_part_read handle it */
943 s->init_num -= 3;
944 ret = ssl2_part_read(s,SSL_F_REQUEST_CERTIFICATE, 3);
945 goto end;
946 }
947
948 if (s->msg_callback)
949 s->msg_callback(0, s->version, 0, p, 3, s, s->msg_callback_arg); /* ERROR */
950
951 /* this is the one place where we can recover from an SSL 2.0 error */
952
836 if (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) 953 if (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
837 { 954 {
838 ssl2_return_error(s,SSL2_PE_BAD_CERTIFICATE); 955 ssl2_return_error(s,SSL2_PE_BAD_CERTIFICATE);
@@ -842,12 +959,18 @@ static int request_certificate(SSL *s)
842 ret=1; 959 ret=1;
843 goto end; 960 goto end;
844 } 961 }
845 if ((*(p++) != SSL2_MT_CLIENT_CERTIFICATE) || (i < 6)) 962 if ((*(p++) != SSL2_MT_CLIENT_CERTIFICATE) || (s->init_num < 6))
846 { 963 {
847 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR); 964 ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
848 SSLerr(SSL_F_REQUEST_CERTIFICATE,SSL_R_SHORT_READ); 965 SSLerr(SSL_F_REQUEST_CERTIFICATE,SSL_R_SHORT_READ);
849 goto end; 966 goto end;
850 } 967 }
968 if (s->init_num != 6)
969 {
970 SSLerr(SSL_F_REQUEST_CERTIFICATE, ERR_R_INTERNAL_ERROR);
971 goto end;
972 }
973
851 /* ok we have a response */ 974 /* ok we have a response */
852 /* certificate type, there is only one right now. */ 975 /* certificate type, there is only one right now. */
853 ctype= *(p++); 976 ctype= *(p++);
@@ -860,18 +983,26 @@ static int request_certificate(SSL *s)
860 n2s(p,i); s->s2->tmp.clen=i; 983 n2s(p,i); s->s2->tmp.clen=i;
861 n2s(p,i); s->s2->tmp.rlen=i; 984 n2s(p,i); s->s2->tmp.rlen=i;
862 s->state=SSL2_ST_SEND_REQUEST_CERTIFICATE_D; 985 s->state=SSL2_ST_SEND_REQUEST_CERTIFICATE_D;
863 s->init_num=0;
864 } 986 }
865 987
866 /* SSL2_ST_SEND_REQUEST_CERTIFICATE_D */ 988 /* SSL2_ST_SEND_REQUEST_CERTIFICATE_D */
867 p=(unsigned char *)s->init_buf->data; 989 p=(unsigned char *)s->init_buf->data;
868 j=s->s2->tmp.clen+s->s2->tmp.rlen-s->init_num; 990 len = 6 + (unsigned long)s->s2->tmp.clen + (unsigned long)s->s2->tmp.rlen;
869 i=ssl2_read(s,(char *)&(p[s->init_num]),j); 991 if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)
992 {
993 SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,SSL_R_MESSAGE_TOO_LONG);
994 goto end;
995 }
996 j = (int)len - s->init_num;
997 i = ssl2_read(s,(char *)&(p[s->init_num]),j);
870 if (i < j) 998 if (i < j)
871 { 999 {
872 ret=ssl2_part_read(s,SSL_F_REQUEST_CERTIFICATE,i); 1000 ret=ssl2_part_read(s,SSL_F_REQUEST_CERTIFICATE,i);
873 goto end; 1001 goto end;
874 } 1002 }
1003 if (s->msg_callback)
1004 s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* CLIENT-CERTIFICATE */
1005 p += 6;
875 1006
876 x509=(X509 *)d2i_X509(NULL,&p,(long)s->s2->tmp.clen); 1007 x509=(X509 *)d2i_X509(NULL,&p,(long)s->s2->tmp.clen);
877 if (x509 == NULL) 1008 if (x509 == NULL)
@@ -893,7 +1024,8 @@ static int request_certificate(SSL *s)
893 EVP_MD_CTX ctx; 1024 EVP_MD_CTX ctx;
894 EVP_PKEY *pkey=NULL; 1025 EVP_PKEY *pkey=NULL;
895 1026
896 EVP_VerifyInit(&ctx,s->ctx->rsa_md5); 1027 EVP_MD_CTX_init(&ctx);
1028 EVP_VerifyInit_ex(&ctx,s->ctx->rsa_md5, NULL);
897 EVP_VerifyUpdate(&ctx,s->s2->key_material, 1029 EVP_VerifyUpdate(&ctx,s->s2->key_material,
898 (unsigned int)s->s2->key_material_length); 1030 (unsigned int)s->s2->key_material_length);
899 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH); 1031 EVP_VerifyUpdate(&ctx,ccd,SSL2_MIN_CERT_CHALLENGE_LENGTH);
@@ -914,7 +1046,7 @@ static int request_certificate(SSL *s)
914 if (pkey == NULL) goto end; 1046 if (pkey == NULL) goto end;
915 i=EVP_VerifyFinal(&ctx,p,s->s2->tmp.rlen,pkey); 1047 i=EVP_VerifyFinal(&ctx,p,s->s2->tmp.rlen,pkey);
916 EVP_PKEY_free(pkey); 1048 EVP_PKEY_free(pkey);
917 memset(&ctx,0,sizeof(ctx)); 1049 EVP_MD_CTX_cleanup(&ctx);
918 1050
919 if (i) 1051 if (i)
920 { 1052 {
@@ -967,7 +1099,7 @@ static int ssl_rsa_private_decrypt(CERT *c, int len, unsigned char *from,
967 SSLerr(SSL_F_SSL_RSA_PRIVATE_DECRYPT,ERR_R_RSA_LIB); 1099 SSLerr(SSL_F_SSL_RSA_PRIVATE_DECRYPT,ERR_R_RSA_LIB);
968 return(i); 1100 return(i);
969 } 1101 }
970#else /* !NO_SSL2 */ 1102#else /* !OPENSSL_NO_SSL2 */
971 1103
972# if PEDANTIC 1104# if PEDANTIC
973static void *dummy=&dummy; 1105static void *dummy=&dummy;
diff --git a/src/lib/libssl/src/ssl/s3_both.c b/src/lib/libssl/src/ssl/s3_both.c
index 10d8d3b15a..58a24cd883 100644
--- a/src/lib/libssl/src/ssl/s3_both.c
+++ b/src/lib/libssl/src/ssl/s3_both.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-2002 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
@@ -109,6 +109,7 @@
109 * 109 *
110 */ 110 */
111 111
112#include <limits.h>
112#include <string.h> 113#include <string.h>
113#include <stdio.h> 114#include <stdio.h>
114#include <openssl/buffer.h> 115#include <openssl/buffer.h>
@@ -118,7 +119,7 @@
118#include <openssl/x509.h> 119#include <openssl/x509.h>
119#include "ssl_locl.h" 120#include "ssl_locl.h"
120 121
121/* send s->init_buf in records of type 'type' */ 122/* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */
122int ssl3_do_write(SSL *s, int type) 123int ssl3_do_write(SSL *s, int type)
123 { 124 {
124 int ret; 125 int ret;
@@ -132,7 +133,11 @@ int ssl3_do_write(SSL *s, int type)
132 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret); 133 ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret);
133 134
134 if (ret == s->init_num) 135 if (ret == s->init_num)
136 {
137 if (s->msg_callback)
138 s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg);
135 return(1); 139 return(1);
140 }
136 s->init_off+=ret; 141 s->init_off+=ret;
137 s->init_num-=ret; 142 s->init_num-=ret;
138 return(0); 143 return(0);
@@ -158,7 +163,7 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
158 p+=i; 163 p+=i;
159 l=i; 164 l=i;
160 165
161#ifdef WIN16 166#ifdef OPENSSL_SYS_WIN16
162 /* MSVC 1.5 does not clear the top bytes of the word unless 167 /* MSVC 1.5 does not clear the top bytes of the word unless
163 * I do this. 168 * I do this.
164 */ 169 */
@@ -205,7 +210,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
205 } 210 }
206 s->s3->change_cipher_spec=0; 211 s->s3->change_cipher_spec=0;
207 212
208 p = (unsigned char *)s->init_buf->data; 213 p = (unsigned char *)s->init_msg;
209 i = s->s3->tmp.peer_finish_md_len; 214 i = s->s3->tmp.peer_finish_md_len;
210 215
211 if (i != n) 216 if (i != n)
@@ -272,7 +277,11 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x)
272 } 277 }
273 if (x != NULL) 278 if (x != NULL)
274 { 279 {
275 X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL); 280 if(!X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL))
281 {
282 SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB);
283 return(0);
284 }
276 285
277 for (;;) 286 for (;;)
278 { 287 {
@@ -351,7 +360,9 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
351 goto f_err; 360 goto f_err;
352 } 361 }
353 *ok=1; 362 *ok=1;
354 return((int)s->s3->tmp.message_size); 363 s->init_msg = s->init_buf->data + 4;
364 s->init_num = (int)s->s3->tmp.message_size;
365 return s->init_num;
355 } 366 }
356 367
357 p=(unsigned char *)s->init_buf->data; 368 p=(unsigned char *)s->init_buf->data;
@@ -383,7 +394,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
383 * if their format is correct. Does not count for 394 * if their format is correct. Does not count for
384 * 'Finished' MAC. */ 395 * 'Finished' MAC. */
385 if (p[1] == 0 && p[2] == 0 &&p[3] == 0) 396 if (p[1] == 0 && p[2] == 0 &&p[3] == 0)
397 {
398 s->init_num = 0;
386 skip_message = 1; 399 skip_message = 1;
400
401 if (s->msg_callback)
402 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, 4, s, s->msg_callback_arg);
403 }
387 } 404 }
388 while (skip_message); 405 while (skip_message);
389 406
@@ -407,8 +424,6 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
407 ssl3_init_finished_mac(s); 424 ssl3_init_finished_mac(s);
408 } 425 }
409 426
410 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);
411
412 s->s3->tmp.message_type= *(p++); 427 s->s3->tmp.message_type= *(p++);
413 428
414 n2l3(p,l); 429 n2l3(p,l);
@@ -418,7 +433,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
418 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); 433 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
419 goto f_err; 434 goto f_err;
420 } 435 }
421 if (l && !BUF_MEM_grow(s->init_buf,(int)l)) 436 if (l > (INT_MAX-4)) /* BUF_MEM_grow takes an 'int' parameter */
437 {
438 al=SSL_AD_ILLEGAL_PARAMETER;
439 SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
440 goto f_err;
441 }
442 if (l && !BUF_MEM_grow(s->init_buf,(int)l+4))
422 { 443 {
423 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); 444 SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);
424 goto err; 445 goto err;
@@ -426,12 +447,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
426 s->s3->tmp.message_size=l; 447 s->s3->tmp.message_size=l;
427 s->state=stn; 448 s->state=stn;
428 449
429 s->init_num=0; 450 s->init_msg = s->init_buf->data + 4;
451 s->init_num = 0;
430 } 452 }
431 453
432 /* next state (stn) */ 454 /* next state (stn) */
433 p=(unsigned char *)s->init_buf->data; 455 p = s->init_msg;
434 n=s->s3->tmp.message_size; 456 n = s->s3->tmp.message_size - s->init_num;
435 while (n > 0) 457 while (n > 0)
436 { 458 {
437 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0); 459 i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0);
@@ -444,7 +466,9 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
444 s->init_num += i; 466 s->init_num += i;
445 n -= i; 467 n -= i;
446 } 468 }
447 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num); 469 ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num + 4);
470 if (s->msg_callback)
471 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data, (size_t)s->init_num + 4, s, s->msg_callback_arg);
448 *ok=1; 472 *ok=1;
449 return s->init_num; 473 return s->init_num;
450f_err: 474f_err:
@@ -512,6 +536,7 @@ int ssl_verify_alarm_type(long type)
512 { 536 {
513 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: 537 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
514 case X509_V_ERR_UNABLE_TO_GET_CRL: 538 case X509_V_ERR_UNABLE_TO_GET_CRL:
539 case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:
515 al=SSL_AD_UNKNOWN_CA; 540 al=SSL_AD_UNKNOWN_CA;
516 break; 541 break;
517 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: 542 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
@@ -523,6 +548,8 @@ int ssl_verify_alarm_type(long type)
523 case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: 548 case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
524 case X509_V_ERR_CERT_NOT_YET_VALID: 549 case X509_V_ERR_CERT_NOT_YET_VALID:
525 case X509_V_ERR_CRL_NOT_YET_VALID: 550 case X509_V_ERR_CRL_NOT_YET_VALID:
551 case X509_V_ERR_CERT_UNTRUSTED:
552 case X509_V_ERR_CERT_REJECTED:
526 al=SSL_AD_BAD_CERTIFICATE; 553 al=SSL_AD_BAD_CERTIFICATE;
527 break; 554 break;
528 case X509_V_ERR_CERT_SIGNATURE_FAILURE: 555 case X509_V_ERR_CERT_SIGNATURE_FAILURE:
@@ -544,11 +571,16 @@ int ssl_verify_alarm_type(long type)
544 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: 571 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
545 case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: 572 case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
546 case X509_V_ERR_CERT_CHAIN_TOO_LONG: 573 case X509_V_ERR_CERT_CHAIN_TOO_LONG:
574 case X509_V_ERR_PATH_LENGTH_EXCEEDED:
575 case X509_V_ERR_INVALID_CA:
547 al=SSL_AD_UNKNOWN_CA; 576 al=SSL_AD_UNKNOWN_CA;
548 break; 577 break;
549 case X509_V_ERR_APPLICATION_VERIFICATION: 578 case X509_V_ERR_APPLICATION_VERIFICATION:
550 al=SSL_AD_HANDSHAKE_FAILURE; 579 al=SSL_AD_HANDSHAKE_FAILURE;
551 break; 580 break;
581 case X509_V_ERR_INVALID_PURPOSE:
582 al=SSL_AD_UNSUPPORTED_CERTIFICATE;
583 break;
552 default: 584 default:
553 al=SSL_AD_CERTIFICATE_UNKNOWN; 585 al=SSL_AD_CERTIFICATE_UNKNOWN;
554 break; 586 break;
@@ -560,6 +592,7 @@ int ssl3_setup_buffers(SSL *s)
560 { 592 {
561 unsigned char *p; 593 unsigned char *p;
562 unsigned int extra; 594 unsigned int extra;
595 size_t len;
563 596
564 if (s->s3->rbuf.buf == NULL) 597 if (s->s3->rbuf.buf == NULL)
565 { 598 {
@@ -567,18 +600,21 @@ int ssl3_setup_buffers(SSL *s)
567 extra=SSL3_RT_MAX_EXTRA; 600 extra=SSL3_RT_MAX_EXTRA;
568 else 601 else
569 extra=0; 602 extra=0;
570 if ((p=OPENSSL_malloc(SSL3_RT_MAX_PACKET_SIZE+extra)) 603 len = SSL3_RT_MAX_PACKET_SIZE + extra;
571 == NULL) 604 if ((p=OPENSSL_malloc(len)) == NULL)
572 goto err; 605 goto err;
573 s->s3->rbuf.buf=p; 606 s->s3->rbuf.buf = p;
607 s->s3->rbuf.len = len;
574 } 608 }
575 609
576 if (s->s3->wbuf.buf == NULL) 610 if (s->s3->wbuf.buf == NULL)
577 { 611 {
578 if ((p=OPENSSL_malloc(SSL3_RT_MAX_PACKET_SIZE)) 612 len = SSL3_RT_MAX_PACKET_SIZE;
579 == NULL) 613 len += SSL3_RT_HEADER_LENGTH + 256; /* extra space for empty fragment */
614 if ((p=OPENSSL_malloc(len)) == NULL)
580 goto err; 615 goto err;
581 s->s3->wbuf.buf=p; 616 s->s3->wbuf.buf = p;
617 s->s3->wbuf.len = len;
582 } 618 }
583 s->packet= &(s->s3->rbuf.buf[0]); 619 s->packet= &(s->s3->rbuf.buf[0]);
584 return(1); 620 return(1);
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c
index eec45cfa48..e5853ede95 100644
--- a/src/lib/libssl/src/ssl/s3_clnt.c
+++ b/src/lib/libssl/src/ssl/s3_clnt.c
@@ -55,15 +55,68 @@
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 <openssl/buffer.h> 113#include <openssl/buffer.h>
61#include <openssl/rand.h> 114#include <openssl/rand.h>
62#include <openssl/objects.h> 115#include <openssl/objects.h>
63#include <openssl/md5.h>
64#include <openssl/sha.h>
65#include <openssl/evp.h> 116#include <openssl/evp.h>
66#include "ssl_locl.h" 117#include "ssl_locl.h"
118#include "kssl_lcl.h"
119#include <openssl/md5.h>
67 120
68static SSL_METHOD *ssl3_get_client_method(int ver); 121static SSL_METHOD *ssl3_get_client_method(int ver);
69static int ssl3_client_hello(SSL *s); 122static int ssl3_client_hello(SSL *s);
@@ -106,7 +159,7 @@ int ssl3_connect(SSL *s)
106 BUF_MEM *buf; 159 BUF_MEM *buf;
107 unsigned long Time=time(NULL),l; 160 unsigned long Time=time(NULL),l;
108 long num1; 161 long num1;
109 void (*cb)()=NULL; 162 void (*cb)(const SSL *ssl,int type,int val)=NULL;
110 int ret= -1; 163 int ret= -1;
111 int new_state,state,skip=0;; 164 int new_state,state,skip=0;;
112 165
@@ -119,8 +172,8 @@ int ssl3_connect(SSL *s)
119 else if (s->ctx->info_callback != NULL) 172 else if (s->ctx->info_callback != NULL)
120 cb=s->ctx->info_callback; 173 cb=s->ctx->info_callback;
121 174
122 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
123 s->in_handshake++; 175 s->in_handshake++;
176 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
124 177
125 for (;;) 178 for (;;)
126 { 179 {
@@ -143,7 +196,7 @@ int ssl3_connect(SSL *s)
143 196
144 if ((s->version & 0xff00 ) != 0x0300) 197 if ((s->version & 0xff00 ) != 0x0300)
145 { 198 {
146 SSLerr(SSL_F_SSL3_CONNECT, SSL_R_INTERNAL_ERROR); 199 SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);
147 ret = -1; 200 ret = -1;
148 goto end; 201 goto end;
149 } 202 }
@@ -441,9 +494,9 @@ int ssl3_connect(SSL *s)
441 skip=0; 494 skip=0;
442 } 495 }
443end: 496end:
497 s->in_handshake--;
444 if (cb != NULL) 498 if (cb != NULL)
445 cb(s,SSL_CB_CONNECT_EXIT,ret); 499 cb(s,SSL_CB_CONNECT_EXIT,ret);
446 s->in_handshake--;
447 return(ret); 500 return(ret);
448 } 501 }
449 502
@@ -554,7 +607,7 @@ static int ssl3_get_server_hello(SSL *s)
554 &ok); 607 &ok);
555 608
556 if (!ok) return((int)n); 609 if (!ok) return((int)n);
557 d=p=(unsigned char *)s->init_buf->data; 610 d=p=(unsigned char *)s->init_msg;
558 611
559 if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) 612 if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff)))
560 { 613 {
@@ -687,16 +740,13 @@ static int ssl3_get_server_certificate(SSL *s)
687 STACK_OF(X509) *sk=NULL; 740 STACK_OF(X509) *sk=NULL;
688 SESS_CERT *sc; 741 SESS_CERT *sc;
689 EVP_PKEY *pkey=NULL; 742 EVP_PKEY *pkey=NULL;
743 int need_cert = 1; /* VRS: 0=> will allow null cert if auth == KRB5 */
690 744
691 n=ssl3_get_message(s, 745 n=ssl3_get_message(s,
692 SSL3_ST_CR_CERT_A, 746 SSL3_ST_CR_CERT_A,
693 SSL3_ST_CR_CERT_B, 747 SSL3_ST_CR_CERT_B,
694 -1, 748 -1,
695#if defined(MSDOS) && !defined(WIN32) 749 s->max_cert_list,
696 1024*30, /* 30k max cert list :-) */
697#else
698 1024*100, /* 100k max cert list :-) */
699#endif
700 &ok); 750 &ok);
701 751
702 if (!ok) return((int)n); 752 if (!ok) return((int)n);
@@ -713,7 +763,7 @@ static int ssl3_get_server_certificate(SSL *s)
713 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); 763 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE);
714 goto f_err; 764 goto f_err;
715 } 765 }
716 d=p=(unsigned char *)s->init_buf->data; 766 d=p=(unsigned char *)s->init_msg;
717 767
718 if ((sk=sk_X509_new_null()) == NULL) 768 if ((sk=sk_X509_new_null()) == NULL)
719 { 769 {
@@ -763,7 +813,12 @@ static int ssl3_get_server_certificate(SSL *s)
763 } 813 }
764 814
765 i=ssl_verify_cert_chain(s,sk); 815 i=ssl_verify_cert_chain(s,sk);
766 if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)) 816 if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)
817#ifndef OPENSSL_NO_KRB5
818 && (s->s3->tmp.new_cipher->algorithms & (SSL_MKEY_MASK|SSL_AUTH_MASK))
819 != (SSL_aKRB5|SSL_kKRB5)
820#endif /* OPENSSL_NO_KRB5 */
821 )
767 { 822 {
768 al=ssl_verify_alarm_type(s->verify_result); 823 al=ssl_verify_alarm_type(s->verify_result);
769 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); 824 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED);
@@ -782,39 +837,66 @@ static int ssl3_get_server_certificate(SSL *s)
782 * certificate, which we don't include in s3_srvr.c */ 837 * certificate, which we don't include in s3_srvr.c */
783 x=sk_X509_value(sk,0); 838 x=sk_X509_value(sk,0);
784 sk=NULL; 839 sk=NULL;
840 /* VRS 19990621: possible memory leak; sk=null ==> !sk_pop_free() @end*/
785 841
786 pkey=X509_get_pubkey(x); 842 pkey=X509_get_pubkey(x);
787 843
788 if ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)) 844 /* VRS: allow null cert if auth == KRB5 */
845 need_cert = ((s->s3->tmp.new_cipher->algorithms
846 & (SSL_MKEY_MASK|SSL_AUTH_MASK))
847 == (SSL_aKRB5|SSL_kKRB5))? 0: 1;
848
849#ifdef KSSL_DEBUG
850 printf("pkey,x = %p, %p\n", pkey,x);
851 printf("ssl_cert_type(x,pkey) = %d\n", ssl_cert_type(x,pkey));
852 printf("cipher, alg, nc = %s, %lx, %d\n", s->s3->tmp.new_cipher->name,
853 s->s3->tmp.new_cipher->algorithms, need_cert);
854#endif /* KSSL_DEBUG */
855
856 if (need_cert && ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)))
789 { 857 {
790 x=NULL; 858 x=NULL;
791 al=SSL3_AL_FATAL; 859 al=SSL3_AL_FATAL;
792 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); 860 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,
861 SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS);
793 goto f_err; 862 goto f_err;
794 } 863 }
795 864
796 i=ssl_cert_type(x,pkey); 865 i=ssl_cert_type(x,pkey);
797 if (i < 0) 866 if (need_cert && i < 0)
798 { 867 {
799 x=NULL; 868 x=NULL;
800 al=SSL3_AL_FATAL; 869 al=SSL3_AL_FATAL;
801 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNKNOWN_CERTIFICATE_TYPE); 870 SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,
871 SSL_R_UNKNOWN_CERTIFICATE_TYPE);
802 goto f_err; 872 goto f_err;
803 } 873 }
804 874
805 sc->peer_cert_type=i; 875 if (need_cert)
806 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); 876 {
807 if (sc->peer_pkeys[i].x509 != NULL) /* Why would this ever happen? 877 sc->peer_cert_type=i;
808 * We just created sc a couple of 878 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
809 * lines ago. */ 879 /* Why would the following ever happen?
810 X509_free(sc->peer_pkeys[i].x509); 880 * We just created sc a couple of lines ago. */
811 sc->peer_pkeys[i].x509=x; 881 if (sc->peer_pkeys[i].x509 != NULL)
812 sc->peer_key= &(sc->peer_pkeys[i]); 882 X509_free(sc->peer_pkeys[i].x509);
813 883 sc->peer_pkeys[i].x509=x;
814 if (s->session->peer != NULL) 884 sc->peer_key= &(sc->peer_pkeys[i]);
815 X509_free(s->session->peer); 885
816 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); 886 if (s->session->peer != NULL)
817 s->session->peer=x; 887 X509_free(s->session->peer);
888 CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
889 s->session->peer=x;
890 }
891 else
892 {
893 sc->peer_cert_type=i;
894 sc->peer_key= NULL;
895
896 if (s->session->peer != NULL)
897 X509_free(s->session->peer);
898 s->session->peer=NULL;
899 }
818 s->session->verify_result = s->verify_result; 900 s->session->verify_result = s->verify_result;
819 901
820 x=NULL; 902 x=NULL;
@@ -834,7 +916,7 @@ err:
834 916
835static int ssl3_get_key_exchange(SSL *s) 917static int ssl3_get_key_exchange(SSL *s)
836 { 918 {
837#ifndef NO_RSA 919#ifndef OPENSSL_NO_RSA
838 unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; 920 unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2];
839#endif 921#endif
840 EVP_MD_CTX md_ctx; 922 EVP_MD_CTX md_ctx;
@@ -842,18 +924,20 @@ static int ssl3_get_key_exchange(SSL *s)
842 int al,i,j,param_len,ok; 924 int al,i,j,param_len,ok;
843 long n,alg; 925 long n,alg;
844 EVP_PKEY *pkey=NULL; 926 EVP_PKEY *pkey=NULL;
845#ifndef NO_RSA 927#ifndef OPENSSL_NO_RSA
846 RSA *rsa=NULL; 928 RSA *rsa=NULL;
847#endif 929#endif
848#ifndef NO_DH 930#ifndef OPENSSL_NO_DH
849 DH *dh=NULL; 931 DH *dh=NULL;
850#endif 932#endif
851 933
934 /* use same message size as in ssl3_get_certificate_request()
935 * as ServerKeyExchange message may be skipped */
852 n=ssl3_get_message(s, 936 n=ssl3_get_message(s,
853 SSL3_ST_CR_KEY_EXCH_A, 937 SSL3_ST_CR_KEY_EXCH_A,
854 SSL3_ST_CR_KEY_EXCH_B, 938 SSL3_ST_CR_KEY_EXCH_B,
855 -1, 939 -1,
856 1024*8, /* ?? */ 940 s->max_cert_list,
857 &ok); 941 &ok);
858 942
859 if (!ok) return((int)n); 943 if (!ok) return((int)n);
@@ -864,18 +948,18 @@ static int ssl3_get_key_exchange(SSL *s)
864 return(1); 948 return(1);
865 } 949 }
866 950
867 param=p=(unsigned char *)s->init_buf->data; 951 param=p=(unsigned char *)s->init_msg;
868 952
869 if (s->session->sess_cert != NULL) 953 if (s->session->sess_cert != NULL)
870 { 954 {
871#ifndef NO_RSA 955#ifndef OPENSSL_NO_RSA
872 if (s->session->sess_cert->peer_rsa_tmp != NULL) 956 if (s->session->sess_cert->peer_rsa_tmp != NULL)
873 { 957 {
874 RSA_free(s->session->sess_cert->peer_rsa_tmp); 958 RSA_free(s->session->sess_cert->peer_rsa_tmp);
875 s->session->sess_cert->peer_rsa_tmp=NULL; 959 s->session->sess_cert->peer_rsa_tmp=NULL;
876 } 960 }
877#endif 961#endif
878#ifndef NO_DH 962#ifndef OPENSSL_NO_DH
879 if (s->session->sess_cert->peer_dh_tmp) 963 if (s->session->sess_cert->peer_dh_tmp)
880 { 964 {
881 DH_free(s->session->sess_cert->peer_dh_tmp); 965 DH_free(s->session->sess_cert->peer_dh_tmp);
@@ -890,8 +974,9 @@ static int ssl3_get_key_exchange(SSL *s)
890 974
891 param_len=0; 975 param_len=0;
892 alg=s->s3->tmp.new_cipher->algorithms; 976 alg=s->s3->tmp.new_cipher->algorithms;
977 EVP_MD_CTX_init(&md_ctx);
893 978
894#ifndef NO_RSA 979#ifndef OPENSSL_NO_RSA
895 if (alg & SSL_kRSA) 980 if (alg & SSL_kRSA)
896 { 981 {
897 if ((rsa=RSA_new()) == NULL) 982 if ((rsa=RSA_new()) == NULL)
@@ -935,17 +1020,17 @@ static int ssl3_get_key_exchange(SSL *s)
935 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); 1020 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
936 else 1021 else
937 { 1022 {
938 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1023 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
939 goto err; 1024 goto err;
940 } 1025 }
941 s->session->sess_cert->peer_rsa_tmp=rsa; 1026 s->session->sess_cert->peer_rsa_tmp=rsa;
942 rsa=NULL; 1027 rsa=NULL;
943 } 1028 }
944#else /* NO_RSA */ 1029#else /* OPENSSL_NO_RSA */
945 if (0) 1030 if (0)
946 ; 1031 ;
947#endif 1032#endif
948#ifndef NO_DH 1033#ifndef OPENSSL_NO_DH
949 else if (alg & SSL_kEDH) 1034 else if (alg & SSL_kEDH)
950 { 1035 {
951 if ((dh=DH_new()) == NULL) 1036 if ((dh=DH_new()) == NULL)
@@ -999,14 +1084,14 @@ static int ssl3_get_key_exchange(SSL *s)
999 p+=i; 1084 p+=i;
1000 n-=param_len; 1085 n-=param_len;
1001 1086
1002#ifndef NO_RSA 1087#ifndef OPENSSL_NO_RSA
1003 if (alg & SSL_aRSA) 1088 if (alg & SSL_aRSA)
1004 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); 1089 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
1005#else 1090#else
1006 if (0) 1091 if (0)
1007 ; 1092 ;
1008#endif 1093#endif
1009#ifndef NO_DSA 1094#ifndef OPENSSL_NO_DSA
1010 else if (alg & SSL_aDSS) 1095 else if (alg & SSL_aDSS)
1011 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509); 1096 pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
1012#endif 1097#endif
@@ -1021,7 +1106,7 @@ static int ssl3_get_key_exchange(SSL *s)
1021 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); 1106 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER);
1022 goto f_err; 1107 goto f_err;
1023 } 1108 }
1024#endif /* !NO_DH */ 1109#endif /* !OPENSSL_NO_DH */
1025 if (alg & SSL_aFZA) 1110 if (alg & SSL_aFZA)
1026 { 1111 {
1027 al=SSL_AD_HANDSHAKE_FAILURE; 1112 al=SSL_AD_HANDSHAKE_FAILURE;
@@ -1048,7 +1133,7 @@ static int ssl3_get_key_exchange(SSL *s)
1048 goto f_err; 1133 goto f_err;
1049 } 1134 }
1050 1135
1051#ifndef NO_RSA 1136#ifndef OPENSSL_NO_RSA
1052 if (pkey->type == EVP_PKEY_RSA) 1137 if (pkey->type == EVP_PKEY_RSA)
1053 { 1138 {
1054 int num; 1139 int num;
@@ -1057,12 +1142,12 @@ static int ssl3_get_key_exchange(SSL *s)
1057 q=md_buf; 1142 q=md_buf;
1058 for (num=2; num > 0; num--) 1143 for (num=2; num > 0; num--)
1059 { 1144 {
1060 EVP_DigestInit(&md_ctx,(num == 2) 1145 EVP_DigestInit_ex(&md_ctx,(num == 2)
1061 ?s->ctx->md5:s->ctx->sha1); 1146 ?s->ctx->md5:s->ctx->sha1, NULL);
1062 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1147 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1063 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1148 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1064 EVP_DigestUpdate(&md_ctx,param,param_len); 1149 EVP_DigestUpdate(&md_ctx,param,param_len);
1065 EVP_DigestFinal(&md_ctx,q,(unsigned int *)&i); 1150 EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i);
1066 q+=i; 1151 q+=i;
1067 j+=i; 1152 j+=i;
1068 } 1153 }
@@ -1084,11 +1169,11 @@ static int ssl3_get_key_exchange(SSL *s)
1084 } 1169 }
1085 else 1170 else
1086#endif 1171#endif
1087#ifndef NO_DSA 1172#ifndef OPENSSL_NO_DSA
1088 if (pkey->type == EVP_PKEY_DSA) 1173 if (pkey->type == EVP_PKEY_DSA)
1089 { 1174 {
1090 /* lets do DSS */ 1175 /* lets do DSS */
1091 EVP_VerifyInit(&md_ctx,EVP_dss1()); 1176 EVP_VerifyInit_ex(&md_ctx,EVP_dss1(), NULL);
1092 EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1177 EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1093 EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1178 EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1094 EVP_VerifyUpdate(&md_ctx,param,param_len); 1179 EVP_VerifyUpdate(&md_ctx,param,param_len);
@@ -1103,7 +1188,7 @@ static int ssl3_get_key_exchange(SSL *s)
1103 else 1188 else
1104#endif 1189#endif
1105 { 1190 {
1106 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1191 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1107 goto err; 1192 goto err;
1108 } 1193 }
1109 } 1194 }
@@ -1112,7 +1197,7 @@ static int ssl3_get_key_exchange(SSL *s)
1112 /* still data left over */ 1197 /* still data left over */
1113 if (!(alg & SSL_aNULL)) 1198 if (!(alg & SSL_aNULL))
1114 { 1199 {
1115 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1200 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1116 goto err; 1201 goto err;
1117 } 1202 }
1118 if (n != 0) 1203 if (n != 0)
@@ -1123,19 +1208,21 @@ static int ssl3_get_key_exchange(SSL *s)
1123 } 1208 }
1124 } 1209 }
1125 EVP_PKEY_free(pkey); 1210 EVP_PKEY_free(pkey);
1211 EVP_MD_CTX_cleanup(&md_ctx);
1126 return(1); 1212 return(1);
1127f_err: 1213f_err:
1128 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1214 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1129err: 1215err:
1130 EVP_PKEY_free(pkey); 1216 EVP_PKEY_free(pkey);
1131#ifndef NO_RSA 1217#ifndef OPENSSL_NO_RSA
1132 if (rsa != NULL) 1218 if (rsa != NULL)
1133 RSA_free(rsa); 1219 RSA_free(rsa);
1134#endif 1220#endif
1135#ifndef NO_DH 1221#ifndef OPENSSL_NO_DH
1136 if (dh != NULL) 1222 if (dh != NULL)
1137 DH_free(dh); 1223 DH_free(dh);
1138#endif 1224#endif
1225 EVP_MD_CTX_cleanup(&md_ctx);
1139 return(-1); 1226 return(-1);
1140 } 1227 }
1141 1228
@@ -1152,11 +1239,7 @@ static int ssl3_get_certificate_request(SSL *s)
1152 SSL3_ST_CR_CERT_REQ_A, 1239 SSL3_ST_CR_CERT_REQ_A,
1153 SSL3_ST_CR_CERT_REQ_B, 1240 SSL3_ST_CR_CERT_REQ_B,
1154 -1, 1241 -1,
1155#if defined(MSDOS) && !defined(WIN32) 1242 s->max_cert_list,
1156 1024*30, /* 30k max cert list :-) */
1157#else
1158 1024*100, /* 100k max cert list :-) */
1159#endif
1160 &ok); 1243 &ok);
1161 1244
1162 if (!ok) return((int)n); 1245 if (!ok) return((int)n);
@@ -1188,7 +1271,7 @@ static int ssl3_get_certificate_request(SSL *s)
1188 } 1271 }
1189 } 1272 }
1190 1273
1191 d=p=(unsigned char *)s->init_buf->data; 1274 d=p=(unsigned char *)s->init_msg;
1192 1275
1193 if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL) 1276 if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL)
1194 { 1277 {
@@ -1308,6 +1391,7 @@ static int ssl3_get_server_done(SSL *s)
1308 /* should contain no data */ 1391 /* should contain no data */
1309 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); 1392 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR);
1310 SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); 1393 SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH);
1394 return -1;
1311 } 1395 }
1312 ret=1; 1396 ret=1;
1313 return(ret); 1397 return(ret);
@@ -1318,10 +1402,13 @@ static int ssl3_send_client_key_exchange(SSL *s)
1318 unsigned char *p,*d; 1402 unsigned char *p,*d;
1319 int n; 1403 int n;
1320 unsigned long l; 1404 unsigned long l;
1321#ifndef NO_RSA 1405#ifndef OPENSSL_NO_RSA
1322 unsigned char *q; 1406 unsigned char *q;
1323 EVP_PKEY *pkey=NULL; 1407 EVP_PKEY *pkey=NULL;
1324#endif 1408#endif
1409#ifndef OPENSSL_NO_KRB5
1410 KSSL_ERR kssl_err;
1411#endif /* OPENSSL_NO_KRB5 */
1325 1412
1326 if (s->state == SSL3_ST_CW_KEY_EXCH_A) 1413 if (s->state == SSL3_ST_CW_KEY_EXCH_A)
1327 { 1414 {
@@ -1330,8 +1417,10 @@ static int ssl3_send_client_key_exchange(SSL *s)
1330 1417
1331 l=s->s3->tmp.new_cipher->algorithms; 1418 l=s->s3->tmp.new_cipher->algorithms;
1332 1419
1333#ifndef NO_RSA 1420 /* Fool emacs indentation */
1334 if (l & SSL_kRSA) 1421 if (0) {}
1422#ifndef OPENSSL_NO_RSA
1423 else if (l & SSL_kRSA)
1335 { 1424 {
1336 RSA *rsa; 1425 RSA *rsa;
1337 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; 1426 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
@@ -1345,7 +1434,7 @@ static int ssl3_send_client_key_exchange(SSL *s)
1345 (pkey->type != EVP_PKEY_RSA) || 1434 (pkey->type != EVP_PKEY_RSA) ||
1346 (pkey->pkey.rsa == NULL)) 1435 (pkey->pkey.rsa == NULL))
1347 { 1436 {
1348 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1437 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1349 goto err; 1438 goto err;
1350 } 1439 }
1351 rsa=pkey->pkey.rsa; 1440 rsa=pkey->pkey.rsa;
@@ -1388,10 +1477,136 @@ static int ssl3_send_client_key_exchange(SSL *s)
1388 tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); 1477 tmp_buf,SSL_MAX_MASTER_KEY_LENGTH);
1389 memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); 1478 memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH);
1390 } 1479 }
1391 else
1392#endif 1480#endif
1393#ifndef NO_DH 1481#ifndef OPENSSL_NO_KRB5
1394 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1482 else if (l & SSL_kKRB5)
1483 {
1484 krb5_error_code krb5rc;
1485 KSSL_CTX *kssl_ctx = s->kssl_ctx;
1486 /* krb5_data krb5_ap_req; */
1487 krb5_data *enc_ticket;
1488 krb5_data authenticator, *authp = NULL;
1489 EVP_CIPHER_CTX ciph_ctx;
1490 EVP_CIPHER *enc = NULL;
1491 unsigned char iv[EVP_MAX_IV_LENGTH];
1492 unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
1493 unsigned char epms[SSL_MAX_MASTER_KEY_LENGTH
1494 + EVP_MAX_IV_LENGTH];
1495 int padl, outl = sizeof(epms);
1496
1497 EVP_CIPHER_CTX_init(&ciph_ctx);
1498
1499#ifdef KSSL_DEBUG
1500 printf("ssl3_send_client_key_exchange(%lx & %lx)\n",
1501 l, SSL_kKRB5);
1502#endif /* KSSL_DEBUG */
1503
1504 authp = NULL;
1505#ifdef KRB5SENDAUTH
1506 if (KRB5SENDAUTH) authp = &authenticator;
1507#endif /* KRB5SENDAUTH */
1508
1509 krb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp,
1510 &kssl_err);
1511 enc = kssl_map_enc(kssl_ctx->enctype);
1512 if (enc == NULL)
1513 goto err;
1514#ifdef KSSL_DEBUG
1515 {
1516 printf("kssl_cget_tkt rtn %d\n", krb5rc);
1517 if (krb5rc && kssl_err.text)
1518 printf("kssl_cget_tkt kssl_err=%s\n", kssl_err.text);
1519 }
1520#endif /* KSSL_DEBUG */
1521
1522 if (krb5rc)
1523 {
1524 ssl3_send_alert(s,SSL3_AL_FATAL,
1525 SSL_AD_HANDSHAKE_FAILURE);
1526 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1527 kssl_err.reason);
1528 goto err;
1529 }
1530
1531 /* 20010406 VRS - Earlier versions used KRB5 AP_REQ
1532 ** in place of RFC 2712 KerberosWrapper, as in:
1533 **
1534 ** Send ticket (copy to *p, set n = length)
1535 ** n = krb5_ap_req.length;
1536 ** memcpy(p, krb5_ap_req.data, krb5_ap_req.length);
1537 ** if (krb5_ap_req.data)
1538 ** kssl_krb5_free_data_contents(NULL,&krb5_ap_req);
1539 **
1540 ** Now using real RFC 2712 KerberosWrapper
1541 ** (Thanks to Simon Wilkinson <sxw@sxw.org.uk>)
1542 ** Note: 2712 "opaque" types are here replaced
1543 ** with a 2-byte length followed by the value.
1544 ** Example:
1545 ** KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms
1546 ** Where "xx xx" = length bytes. Shown here with
1547 ** optional authenticator omitted.
1548 */
1549
1550 /* KerberosWrapper.Ticket */
1551 s2n(enc_ticket->length,p);
1552 memcpy(p, enc_ticket->data, enc_ticket->length);
1553 p+= enc_ticket->length;
1554 n = enc_ticket->length + 2;
1555
1556 /* KerberosWrapper.Authenticator */
1557 if (authp && authp->length)
1558 {
1559 s2n(authp->length,p);
1560 memcpy(p, authp->data, authp->length);
1561 p+= authp->length;
1562 n+= authp->length + 2;
1563
1564 free(authp->data);
1565 authp->data = NULL;
1566 authp->length = 0;
1567 }
1568 else
1569 {
1570 s2n(0,p);/* null authenticator length */
1571 n+=2;
1572 }
1573
1574 if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0)
1575 goto err;
1576
1577 /* 20010420 VRS. Tried it this way; failed.
1578 ** EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL);
1579 ** EVP_CIPHER_CTX_set_key_length(&ciph_ctx,
1580 ** kssl_ctx->length);
1581 ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv);
1582 */
1583
1584 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */
1585 EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,
1586 kssl_ctx->key,iv);
1587 EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf,
1588 SSL_MAX_MASTER_KEY_LENGTH);
1589 EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl);
1590 outl += padl;
1591 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
1592
1593 /* KerberosWrapper.EncryptedPreMasterSecret */
1594 s2n(outl,p);
1595 memcpy(p, epms, outl);
1596 p+=outl;
1597 n+=outl + 2;
1598
1599 s->session->master_key_length=
1600 s->method->ssl3_enc->generate_master_secret(s,
1601 s->session->master_key,
1602 tmp_buf, SSL_MAX_MASTER_KEY_LENGTH);
1603
1604 memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH);
1605 memset(epms, 0, outl);
1606 }
1607#endif
1608#ifndef OPENSSL_NO_DH
1609 else if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1395 { 1610 {
1396 DH *dh_srvr,*dh_clnt; 1611 DH *dh_srvr,*dh_clnt;
1397 1612
@@ -1445,11 +1660,11 @@ static int ssl3_send_client_key_exchange(SSL *s)
1445 1660
1446 /* perhaps clean things up a bit EAY EAY EAY EAY*/ 1661 /* perhaps clean things up a bit EAY EAY EAY EAY*/
1447 } 1662 }
1448 else
1449#endif 1663#endif
1664 else
1450 { 1665 {
1451 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); 1666 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE);
1452 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); 1667 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR);
1453 goto err; 1668 goto err;
1454 } 1669 }
1455 1670
@@ -1473,11 +1688,11 @@ static int ssl3_send_client_verify(SSL *s)
1473 unsigned char *p,*d; 1688 unsigned char *p,*d;
1474 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1689 unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
1475 EVP_PKEY *pkey; 1690 EVP_PKEY *pkey;
1476#ifndef NO_RSA 1691#ifndef OPENSSL_NO_RSA
1477 unsigned u=0; 1692 unsigned u=0;
1478#endif 1693#endif
1479 unsigned long n; 1694 unsigned long n;
1480#ifndef NO_DSA 1695#ifndef OPENSSL_NO_DSA
1481 int j; 1696 int j;
1482#endif 1697#endif
1483 1698
@@ -1490,7 +1705,7 @@ static int ssl3_send_client_verify(SSL *s)
1490 s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), 1705 s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2),
1491 &(data[MD5_DIGEST_LENGTH])); 1706 &(data[MD5_DIGEST_LENGTH]));
1492 1707
1493#ifndef NO_RSA 1708#ifndef OPENSSL_NO_RSA
1494 if (pkey->type == EVP_PKEY_RSA) 1709 if (pkey->type == EVP_PKEY_RSA)
1495 { 1710 {
1496 s->method->ssl3_enc->cert_verify_mac(s, 1711 s->method->ssl3_enc->cert_verify_mac(s,
@@ -1507,7 +1722,7 @@ static int ssl3_send_client_verify(SSL *s)
1507 } 1722 }
1508 else 1723 else
1509#endif 1724#endif
1510#ifndef NO_DSA 1725#ifndef OPENSSL_NO_DSA
1511 if (pkey->type == EVP_PKEY_DSA) 1726 if (pkey->type == EVP_PKEY_DSA)
1512 { 1727 {
1513 if (!DSA_sign(pkey->save_type, 1728 if (!DSA_sign(pkey->save_type,
@@ -1524,7 +1739,7 @@ static int ssl3_send_client_verify(SSL *s)
1524 else 1739 else
1525#endif 1740#endif
1526 { 1741 {
1527 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,SSL_R_INTERNAL_ERROR); 1742 SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_INTERNAL_ERROR);
1528 goto err; 1743 goto err;
1529 } 1744 }
1530 *(d++)=SSL3_MT_CERTIFICATE_VERIFY; 1745 *(d++)=SSL3_MT_CERTIFICATE_VERIFY;
@@ -1623,10 +1838,10 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1623 long algs; 1838 long algs;
1624 EVP_PKEY *pkey=NULL; 1839 EVP_PKEY *pkey=NULL;
1625 SESS_CERT *sc; 1840 SESS_CERT *sc;
1626#ifndef NO_RSA 1841#ifndef OPENSSL_NO_RSA
1627 RSA *rsa; 1842 RSA *rsa;
1628#endif 1843#endif
1629#ifndef NO_DH 1844#ifndef OPENSSL_NO_DH
1630 DH *dh; 1845 DH *dh;
1631#endif 1846#endif
1632 1847
@@ -1634,20 +1849,20 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1634 1849
1635 if (sc == NULL) 1850 if (sc == NULL)
1636 { 1851 {
1637 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_INTERNAL_ERROR); 1852 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR);
1638 goto err; 1853 goto err;
1639 } 1854 }
1640 1855
1641 algs=s->s3->tmp.new_cipher->algorithms; 1856 algs=s->s3->tmp.new_cipher->algorithms;
1642 1857
1643 /* we don't have a certificate */ 1858 /* we don't have a certificate */
1644 if (algs & (SSL_aDH|SSL_aNULL)) 1859 if (algs & (SSL_aDH|SSL_aNULL|SSL_aKRB5))
1645 return(1); 1860 return(1);
1646 1861
1647#ifndef NO_RSA 1862#ifndef OPENSSL_NO_RSA
1648 rsa=s->session->sess_cert->peer_rsa_tmp; 1863 rsa=s->session->sess_cert->peer_rsa_tmp;
1649#endif 1864#endif
1650#ifndef NO_DH 1865#ifndef OPENSSL_NO_DH
1651 dh=s->session->sess_cert->peer_dh_tmp; 1866 dh=s->session->sess_cert->peer_dh_tmp;
1652#endif 1867#endif
1653 1868
@@ -1665,14 +1880,14 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1665 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); 1880 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT);
1666 goto f_err; 1881 goto f_err;
1667 } 1882 }
1668#ifndef NO_DSA 1883#ifndef OPENSSL_NO_DSA
1669 else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) 1884 else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN))
1670 { 1885 {
1671 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); 1886 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT);
1672 goto f_err; 1887 goto f_err;
1673 } 1888 }
1674#endif 1889#endif
1675#ifndef NO_RSA 1890#ifndef OPENSSL_NO_RSA
1676 if ((algs & SSL_kRSA) && 1891 if ((algs & SSL_kRSA) &&
1677 !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) 1892 !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL)))
1678 { 1893 {
@@ -1680,7 +1895,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1680 goto f_err; 1895 goto f_err;
1681 } 1896 }
1682#endif 1897#endif
1683#ifndef NO_DH 1898#ifndef OPENSSL_NO_DH
1684 if ((algs & SSL_kEDH) && 1899 if ((algs & SSL_kEDH) &&
1685 !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) 1900 !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL)))
1686 { 1901 {
@@ -1692,7 +1907,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1692 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); 1907 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT);
1693 goto f_err; 1908 goto f_err;
1694 } 1909 }
1695#ifndef NO_DSA 1910#ifndef OPENSSL_NO_DSA
1696 else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) 1911 else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA))
1697 { 1912 {
1698 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); 1913 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT);
@@ -1703,7 +1918,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1703 1918
1704 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) 1919 if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP))
1705 { 1920 {
1706#ifndef NO_RSA 1921#ifndef OPENSSL_NO_RSA
1707 if (algs & SSL_kRSA) 1922 if (algs & SSL_kRSA)
1708 { 1923 {
1709 if (rsa == NULL 1924 if (rsa == NULL
@@ -1715,7 +1930,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s)
1715 } 1930 }
1716 else 1931 else
1717#endif 1932#endif
1718#ifndef NO_DH 1933#ifndef OPENSSL_NO_DH
1719 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1934 if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1720 { 1935 {
1721 if (dh == NULL 1936 if (dh == NULL
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c
index 8709da9175..6dfef5caaf 100644
--- a/src/lib/libssl/src/ssl/s3_enc.c
+++ b/src/lib/libssl/src/ssl/s3_enc.c
@@ -55,12 +55,64 @@
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 <openssl/md5.h>
61#include <openssl/sha.h>
62#include <openssl/evp.h> 113#include <openssl/evp.h>
63#include "ssl_locl.h" 114#include "ssl_locl.h"
115#include <openssl/md5.h>
64 116
65static unsigned char ssl3_pad_1[48]={ 117static unsigned char ssl3_pad_1[48]={
66 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36, 118 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
@@ -81,11 +133,11 @@ static unsigned char ssl3_pad_2[48]={
81static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx, 133static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
82 const char *sender, int len, unsigned char *p); 134 const char *sender, int len, unsigned char *p);
83 135
84static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num) 136static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
85 { 137 {
86 MD5_CTX m5; 138 EVP_MD_CTX m5;
87 SHA_CTX s1; 139 EVP_MD_CTX s1;
88 unsigned char buf[8],smd[SHA_DIGEST_LENGTH]; 140 unsigned char buf[16],smd[SHA_DIGEST_LENGTH];
89 unsigned char c='A'; 141 unsigned char c='A';
90 int i,j,k; 142 int i,j,k;
91 143
@@ -93,35 +145,47 @@ static void ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
93 c = os_toascii[c]; /*'A' in ASCII */ 145 c = os_toascii[c]; /*'A' in ASCII */
94#endif 146#endif
95 k=0; 147 k=0;
148 EVP_MD_CTX_init(&m5);
149 EVP_MD_CTX_init(&s1);
96 for (i=0; i<num; i+=MD5_DIGEST_LENGTH) 150 for (i=0; i<num; i+=MD5_DIGEST_LENGTH)
97 { 151 {
98 k++; 152 k++;
153 if (k > sizeof buf)
154 {
155 /* bug: 'buf' is too small for this ciphersuite */
156 SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_INTERNAL_ERROR);
157 return 0;
158 }
159
99 for (j=0; j<k; j++) 160 for (j=0; j<k; j++)
100 buf[j]=c; 161 buf[j]=c;
101 c++; 162 c++;
102 SHA1_Init( &s1); 163 EVP_DigestInit_ex(&s1,EVP_sha1(), NULL);
103 SHA1_Update(&s1,buf,k); 164 EVP_DigestUpdate(&s1,buf,k);
104 SHA1_Update(&s1,s->session->master_key, 165 EVP_DigestUpdate(&s1,s->session->master_key,
105 s->session->master_key_length); 166 s->session->master_key_length);
106 SHA1_Update(&s1,s->s3->server_random,SSL3_RANDOM_SIZE); 167 EVP_DigestUpdate(&s1,s->s3->server_random,SSL3_RANDOM_SIZE);
107 SHA1_Update(&s1,s->s3->client_random,SSL3_RANDOM_SIZE); 168 EVP_DigestUpdate(&s1,s->s3->client_random,SSL3_RANDOM_SIZE);
108 SHA1_Final( smd,&s1); 169 EVP_DigestFinal_ex(&s1,smd,NULL);
109 170
110 MD5_Init( &m5); 171 EVP_DigestInit_ex(&m5,EVP_md5(), NULL);
111 MD5_Update(&m5,s->session->master_key, 172 EVP_DigestUpdate(&m5,s->session->master_key,
112 s->session->master_key_length); 173 s->session->master_key_length);
113 MD5_Update(&m5,smd,SHA_DIGEST_LENGTH); 174 EVP_DigestUpdate(&m5,smd,SHA_DIGEST_LENGTH);
114 if ((i+MD5_DIGEST_LENGTH) > num) 175 if ((i+MD5_DIGEST_LENGTH) > num)
115 { 176 {
116 MD5_Final(smd,&m5); 177 EVP_DigestFinal_ex(&m5,smd,NULL);
117 memcpy(km,smd,(num-i)); 178 memcpy(km,smd,(num-i));
118 } 179 }
119 else 180 else
120 MD5_Final(km,&m5); 181 EVP_DigestFinal_ex(&m5,km,NULL);
121 182
122 km+=MD5_DIGEST_LENGTH; 183 km+=MD5_DIGEST_LENGTH;
123 } 184 }
124 memset(smd,0,SHA_DIGEST_LENGTH); 185 memset(smd,0,SHA_DIGEST_LENGTH);
186 EVP_MD_CTX_cleanup(&m5);
187 EVP_MD_CTX_cleanup(&s1);
188 return 1;
125 } 189 }
126 190
127int ssl3_change_cipher_state(SSL *s, int which) 191int ssl3_change_cipher_state(SSL *s, int which)
@@ -134,8 +198,9 @@ int ssl3_change_cipher_state(SSL *s, int which)
134 const EVP_CIPHER *c; 198 const EVP_CIPHER *c;
135 COMP_METHOD *comp; 199 COMP_METHOD *comp;
136 const EVP_MD *m; 200 const EVP_MD *m;
137 MD5_CTX md; 201 EVP_MD_CTX md;
138 int exp,n,i,j,k,cl; 202 int exp,n,i,j,k,cl;
203 int reuse_dd = 0;
139 204
140 exp=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher); 205 exp=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
141 c=s->s3->tmp.new_sym_enc; 206 c=s->s3->tmp.new_sym_enc;
@@ -148,9 +213,9 @@ int ssl3_change_cipher_state(SSL *s, int which)
148 213
149 if (which & SSL3_CC_READ) 214 if (which & SSL3_CC_READ)
150 { 215 {
151 if ((s->enc_read_ctx == NULL) && 216 if (s->enc_read_ctx != NULL)
152 ((s->enc_read_ctx=(EVP_CIPHER_CTX *) 217 reuse_dd = 1;
153 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 218 else if ((s->enc_read_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
154 goto err; 219 goto err;
155 dd= s->enc_read_ctx; 220 dd= s->enc_read_ctx;
156 s->read_hash=m; 221 s->read_hash=m;
@@ -179,9 +244,9 @@ int ssl3_change_cipher_state(SSL *s, int which)
179 } 244 }
180 else 245 else
181 { 246 {
182 if ((s->enc_write_ctx == NULL) && 247 if (s->enc_write_ctx != NULL)
183 ((s->enc_write_ctx=(EVP_CIPHER_CTX *) 248 reuse_dd = 1;
184 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 249 else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
185 goto err; 250 goto err;
186 dd= s->enc_write_ctx; 251 dd= s->enc_write_ctx;
187 s->write_hash=m; 252 s->write_hash=m;
@@ -204,6 +269,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
204 mac_secret= &(s->s3->write_mac_secret[0]); 269 mac_secret= &(s->s3->write_mac_secret[0]);
205 } 270 }
206 271
272 if (reuse_dd)
273 EVP_CIPHER_CTX_cleanup(dd);
207 EVP_CIPHER_CTX_init(dd); 274 EVP_CIPHER_CTX_init(dd);
208 275
209 p=s->s3->tmp.key_block; 276 p=s->s3->tmp.key_block;
@@ -234,39 +301,41 @@ int ssl3_change_cipher_state(SSL *s, int which)
234 301
235 if (n > s->s3->tmp.key_block_length) 302 if (n > s->s3->tmp.key_block_length)
236 { 303 {
237 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,SSL_R_INTERNAL_ERROR); 304 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,ERR_R_INTERNAL_ERROR);
238 goto err2; 305 goto err2;
239 } 306 }
240 307
308 EVP_MD_CTX_init(&md);
241 memcpy(mac_secret,ms,i); 309 memcpy(mac_secret,ms,i);
242 if (exp) 310 if (exp)
243 { 311 {
244 /* In here I set both the read and write key/iv to the 312 /* In here I set both the read and write key/iv to the
245 * same value since only the correct one will be used :-). 313 * same value since only the correct one will be used :-).
246 */ 314 */
247 MD5_Init(&md); 315 EVP_DigestInit_ex(&md,EVP_md5(), NULL);
248 MD5_Update(&md,key,j); 316 EVP_DigestUpdate(&md,key,j);
249 MD5_Update(&md,er1,SSL3_RANDOM_SIZE); 317 EVP_DigestUpdate(&md,er1,SSL3_RANDOM_SIZE);
250 MD5_Update(&md,er2,SSL3_RANDOM_SIZE); 318 EVP_DigestUpdate(&md,er2,SSL3_RANDOM_SIZE);
251 MD5_Final(&(exp_key[0]),&md); 319 EVP_DigestFinal_ex(&md,&(exp_key[0]),NULL);
252 key= &(exp_key[0]); 320 key= &(exp_key[0]);
253 321
254 if (k > 0) 322 if (k > 0)
255 { 323 {
256 MD5_Init(&md); 324 EVP_DigestInit_ex(&md,EVP_md5(), NULL);
257 MD5_Update(&md,er1,SSL3_RANDOM_SIZE); 325 EVP_DigestUpdate(&md,er1,SSL3_RANDOM_SIZE);
258 MD5_Update(&md,er2,SSL3_RANDOM_SIZE); 326 EVP_DigestUpdate(&md,er2,SSL3_RANDOM_SIZE);
259 MD5_Final(&(exp_iv[0]),&md); 327 EVP_DigestFinal_ex(&md,&(exp_iv[0]),NULL);
260 iv= &(exp_iv[0]); 328 iv= &(exp_iv[0]);
261 } 329 }
262 } 330 }
263 331
264 s->session->key_arg_length=0; 332 s->session->key_arg_length=0;
265 333
266 EVP_CipherInit(dd,c,key,iv,(which & SSL3_CC_WRITE)); 334 EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE));
267 335
268 memset(&(exp_key[0]),0,sizeof(exp_key)); 336 memset(&(exp_key[0]),0,sizeof(exp_key));
269 memset(&(exp_iv[0]),0,sizeof(exp_iv)); 337 memset(&(exp_iv[0]),0,sizeof(exp_iv));
338 EVP_MD_CTX_cleanup(&md);
270 return(1); 339 return(1);
271err: 340err:
272 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE); 341 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE);
@@ -280,6 +349,7 @@ int ssl3_setup_key_block(SSL *s)
280 const EVP_CIPHER *c; 349 const EVP_CIPHER *c;
281 const EVP_MD *hash; 350 const EVP_MD *hash;
282 int num; 351 int num;
352 int ret = 0;
283 SSL_COMP *comp; 353 SSL_COMP *comp;
284 354
285 if (s->s3->tmp.key_block_length != 0) 355 if (s->s3->tmp.key_block_length != 0)
@@ -306,9 +376,18 @@ int ssl3_setup_key_block(SSL *s)
306 s->s3->tmp.key_block_length=num; 376 s->s3->tmp.key_block_length=num;
307 s->s3->tmp.key_block=p; 377 s->s3->tmp.key_block=p;
308 378
309 ssl3_generate_key_block(s,p,num); 379 ret = ssl3_generate_key_block(s,p,num);
310 380
311 return(1); 381 /* enable vulnerability countermeasure for CBC ciphers with
382 * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */
383 s->s3->need_empty_fragments = 1;
384#ifndef OPENSSL_NO_RC4
385 if ((s->session->cipher != NULL) && ((s->session->cipher->algorithms & SSL_ENC_MASK) == SSL_RC4))
386 s->s3->need_empty_fragments = 0;
387#endif
388
389 return ret;
390
312err: 391err:
313 SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE); 392 SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);
314 return(0); 393 return(0);
@@ -381,8 +460,8 @@ int ssl3_enc(SSL *s, int send)
381 if (l == 0 || l%bs != 0) 460 if (l == 0 || l%bs != 0)
382 { 461 {
383 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 462 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
384 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR); 463 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
385 return(0); 464 return 0;
386 } 465 }
387 } 466 }
388 467
@@ -395,9 +474,11 @@ int ssl3_enc(SSL *s, int send)
395 * padding bytes (except that last) are arbitrary */ 474 * padding bytes (except that last) are arbitrary */
396 if (i > bs) 475 if (i > bs)
397 { 476 {
398 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 477 /* Incorrect padding. SSLerr() and ssl3_alert are done
399 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR); 478 * by caller: we don't want to reveal whether this is
400 return(0); 479 * a decryption error or a MAC verification failure
480 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
481 return -1;
401 } 482 }
402 rec->length-=i; 483 rec->length-=i;
403 } 484 }
@@ -407,8 +488,8 @@ int ssl3_enc(SSL *s, int send)
407 488
408void ssl3_init_finished_mac(SSL *s) 489void ssl3_init_finished_mac(SSL *s)
409 { 490 {
410 EVP_DigestInit(&(s->s3->finish_dgst1),s->ctx->md5); 491 EVP_DigestInit_ex(&(s->s3->finish_dgst1),s->ctx->md5, NULL);
411 EVP_DigestInit(&(s->s3->finish_dgst2),s->ctx->sha1); 492 EVP_DigestInit_ex(&(s->s3->finish_dgst2),s->ctx->sha1, NULL);
412 } 493 }
413 494
414void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) 495void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len)
@@ -442,7 +523,8 @@ static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
442 unsigned char md_buf[EVP_MAX_MD_SIZE]; 523 unsigned char md_buf[EVP_MAX_MD_SIZE];
443 EVP_MD_CTX ctx; 524 EVP_MD_CTX ctx;
444 525
445 EVP_MD_CTX_copy(&ctx,in_ctx); 526 EVP_MD_CTX_init(&ctx);
527 EVP_MD_CTX_copy_ex(&ctx,in_ctx);
446 528
447 n=EVP_MD_CTX_size(&ctx); 529 n=EVP_MD_CTX_size(&ctx);
448 npad=(48/n)*n; 530 npad=(48/n)*n;
@@ -452,16 +534,16 @@ static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
452 EVP_DigestUpdate(&ctx,s->session->master_key, 534 EVP_DigestUpdate(&ctx,s->session->master_key,
453 s->session->master_key_length); 535 s->session->master_key_length);
454 EVP_DigestUpdate(&ctx,ssl3_pad_1,npad); 536 EVP_DigestUpdate(&ctx,ssl3_pad_1,npad);
455 EVP_DigestFinal(&ctx,md_buf,&i); 537 EVP_DigestFinal_ex(&ctx,md_buf,&i);
456 538
457 EVP_DigestInit(&ctx,EVP_MD_CTX_md(&ctx)); 539 EVP_DigestInit_ex(&ctx,EVP_MD_CTX_md(&ctx), NULL);
458 EVP_DigestUpdate(&ctx,s->session->master_key, 540 EVP_DigestUpdate(&ctx,s->session->master_key,
459 s->session->master_key_length); 541 s->session->master_key_length);
460 EVP_DigestUpdate(&ctx,ssl3_pad_2,npad); 542 EVP_DigestUpdate(&ctx,ssl3_pad_2,npad);
461 EVP_DigestUpdate(&ctx,md_buf,i); 543 EVP_DigestUpdate(&ctx,md_buf,i);
462 EVP_DigestFinal(&ctx,p,&ret); 544 EVP_DigestFinal_ex(&ctx,p,&ret);
463 545
464 memset(&ctx,0,sizeof(EVP_MD_CTX)); 546 EVP_MD_CTX_cleanup(&ctx);
465 547
466 return((int)ret); 548 return((int)ret);
467 } 549 }
@@ -495,8 +577,9 @@ int ssl3_mac(SSL *ssl, unsigned char *md, int send)
495 npad=(48/md_size)*md_size; 577 npad=(48/md_size)*md_size;
496 578
497 /* Chop the digest off the end :-) */ 579 /* Chop the digest off the end :-) */
580 EVP_MD_CTX_init(&md_ctx);
498 581
499 EVP_DigestInit( &md_ctx,hash); 582 EVP_DigestInit_ex( &md_ctx,hash, NULL);
500 EVP_DigestUpdate(&md_ctx,mac_sec,md_size); 583 EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
501 EVP_DigestUpdate(&md_ctx,ssl3_pad_1,npad); 584 EVP_DigestUpdate(&md_ctx,ssl3_pad_1,npad);
502 EVP_DigestUpdate(&md_ctx,seq,8); 585 EVP_DigestUpdate(&md_ctx,seq,8);
@@ -506,13 +589,15 @@ int ssl3_mac(SSL *ssl, unsigned char *md, int send)
506 s2n(rec->length,p); 589 s2n(rec->length,p);
507 EVP_DigestUpdate(&md_ctx,md,2); 590 EVP_DigestUpdate(&md_ctx,md,2);
508 EVP_DigestUpdate(&md_ctx,rec->input,rec->length); 591 EVP_DigestUpdate(&md_ctx,rec->input,rec->length);
509 EVP_DigestFinal( &md_ctx,md,NULL); 592 EVP_DigestFinal_ex( &md_ctx,md,NULL);
510 593
511 EVP_DigestInit( &md_ctx,hash); 594 EVP_DigestInit_ex( &md_ctx,hash, NULL);
512 EVP_DigestUpdate(&md_ctx,mac_sec,md_size); 595 EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
513 EVP_DigestUpdate(&md_ctx,ssl3_pad_2,npad); 596 EVP_DigestUpdate(&md_ctx,ssl3_pad_2,npad);
514 EVP_DigestUpdate(&md_ctx,md,md_size); 597 EVP_DigestUpdate(&md_ctx,md,md_size);
515 EVP_DigestFinal( &md_ctx,md,&md_size); 598 EVP_DigestFinal_ex( &md_ctx,md,&md_size);
599
600 EVP_MD_CTX_cleanup(&md_ctx);
516 601
517 for (i=7; i>=0; i--) 602 for (i=7; i>=0; i--)
518 { 603 {
@@ -542,24 +627,26 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
542 int i,ret=0; 627 int i,ret=0;
543 unsigned int n; 628 unsigned int n;
544 629
630 EVP_MD_CTX_init(&ctx);
545 for (i=0; i<3; i++) 631 for (i=0; i<3; i++)
546 { 632 {
547 EVP_DigestInit(&ctx,s->ctx->sha1); 633 EVP_DigestInit_ex(&ctx,s->ctx->sha1, NULL);
548 EVP_DigestUpdate(&ctx,salt[i],strlen((const char *)salt[i])); 634 EVP_DigestUpdate(&ctx,salt[i],strlen((const char *)salt[i]));
549 EVP_DigestUpdate(&ctx,p,len); 635 EVP_DigestUpdate(&ctx,p,len);
550 EVP_DigestUpdate(&ctx,&(s->s3->client_random[0]), 636 EVP_DigestUpdate(&ctx,&(s->s3->client_random[0]),
551 SSL3_RANDOM_SIZE); 637 SSL3_RANDOM_SIZE);
552 EVP_DigestUpdate(&ctx,&(s->s3->server_random[0]), 638 EVP_DigestUpdate(&ctx,&(s->s3->server_random[0]),
553 SSL3_RANDOM_SIZE); 639 SSL3_RANDOM_SIZE);
554 EVP_DigestFinal(&ctx,buf,&n); 640 EVP_DigestFinal_ex(&ctx,buf,&n);
555 641
556 EVP_DigestInit(&ctx,s->ctx->md5); 642 EVP_DigestInit_ex(&ctx,s->ctx->md5, NULL);
557 EVP_DigestUpdate(&ctx,p,len); 643 EVP_DigestUpdate(&ctx,p,len);
558 EVP_DigestUpdate(&ctx,buf,n); 644 EVP_DigestUpdate(&ctx,buf,n);
559 EVP_DigestFinal(&ctx,out,&n); 645 EVP_DigestFinal_ex(&ctx,out,&n);
560 out+=n; 646 out+=n;
561 ret+=n; 647 ret+=n;
562 } 648 }
649 EVP_MD_CTX_cleanup(&ctx);
563 return(ret); 650 return(ret);
564 } 651 }
565 652
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index c32c06de32..686992406c 100644
--- a/src/lib/libssl/src/ssl/s3_lib.c
+++ b/src/lib/libssl/src/ssl/s3_lib.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-2002 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
@@ -110,10 +110,10 @@
110 */ 110 */
111 111
112#include <stdio.h> 112#include <stdio.h>
113#include <openssl/md5.h>
114#include <openssl/sha.h>
115#include <openssl/objects.h> 113#include <openssl/objects.h>
116#include "ssl_locl.h" 114#include "ssl_locl.h"
115#include "kssl_lcl.h"
116#include <openssl/md5.h>
117 117
118const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT; 118const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;
119 119
@@ -170,7 +170,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
170 SSL3_TXT_ADH_RC4_128_MD5, 170 SSL3_TXT_ADH_RC4_128_MD5,
171 SSL3_CK_ADH_RC4_128_MD5, 171 SSL3_CK_ADH_RC4_128_MD5,
172 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3, 172 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
173 SSL_NOT_EXP, 173 SSL_NOT_EXP|SSL_MEDIUM,
174 0, 174 0,
175 128, 175 128,
176 128, 176 128,
@@ -196,7 +196,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
196 SSL3_TXT_ADH_DES_64_CBC_SHA, 196 SSL3_TXT_ADH_DES_64_CBC_SHA,
197 SSL3_CK_ADH_DES_64_CBC_SHA, 197 SSL3_CK_ADH_DES_64_CBC_SHA,
198 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3, 198 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
199 SSL_NOT_EXP, 199 SSL_NOT_EXP|SSL_LOW,
200 0, 200 0,
201 56, 201 56,
202 56, 202 56,
@@ -209,7 +209,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
209 SSL3_TXT_ADH_DES_192_CBC_SHA, 209 SSL3_TXT_ADH_DES_192_CBC_SHA,
210 SSL3_CK_ADH_DES_192_CBC_SHA, 210 SSL3_CK_ADH_DES_192_CBC_SHA,
211 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3, 211 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
212 SSL_NOT_EXP, 212 SSL_NOT_EXP|SSL_HIGH,
213 0, 213 0,
214 168, 214 168,
215 168, 215 168,
@@ -518,7 +518,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
518 SSL3_TXT_FZA_DMS_RC4_SHA, 518 SSL3_TXT_FZA_DMS_RC4_SHA,
519 SSL3_CK_FZA_DMS_RC4_SHA, 519 SSL3_CK_FZA_DMS_RC4_SHA,
520 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3, 520 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
521 SSL_NOT_EXP, 521 SSL_NOT_EXP|SSL_MEDIUM,
522 0, 522 0,
523 128, 523 128,
524 128, 524 128,
@@ -526,6 +526,97 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
526 SSL_ALL_STRENGTHS, 526 SSL_ALL_STRENGTHS,
527 }, 527 },
528 528
529#ifndef OPENSSL_NO_KRB5
530/* The Kerberos ciphers
531** 20000107 VRS: And the first shall be last,
532** in hopes of avoiding the lynx ssl renegotiation problem.
533*/
534/* Cipher 21 VRS */
535 {
536 1,
537 SSL3_TXT_KRB5_DES_40_CBC_SHA,
538 SSL3_CK_KRB5_DES_40_CBC_SHA,
539 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
540 SSL_EXPORT|SSL_EXP40,
541 0,
542 40,
543 56,
544 SSL_ALL_CIPHERS,
545 SSL_ALL_STRENGTHS,
546 },
547
548/* Cipher 22 VRS */
549 {
550 1,
551 SSL3_TXT_KRB5_DES_40_CBC_MD5,
552 SSL3_CK_KRB5_DES_40_CBC_MD5,
553 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
554 SSL_EXPORT|SSL_EXP40,
555 0,
556 40,
557 56,
558 SSL_ALL_CIPHERS,
559 SSL_ALL_STRENGTHS,
560 },
561
562/* Cipher 23 VRS */
563 {
564 1,
565 SSL3_TXT_KRB5_DES_64_CBC_SHA,
566 SSL3_CK_KRB5_DES_64_CBC_SHA,
567 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
568 SSL_NOT_EXP|SSL_LOW,
569 0,
570 56,
571 56,
572 SSL_ALL_CIPHERS,
573 SSL_ALL_STRENGTHS,
574 },
575
576/* Cipher 24 VRS */
577 {
578 1,
579 SSL3_TXT_KRB5_DES_64_CBC_MD5,
580 SSL3_CK_KRB5_DES_64_CBC_MD5,
581 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
582 SSL_NOT_EXP|SSL_LOW,
583 0,
584 56,
585 56,
586 SSL_ALL_CIPHERS,
587 SSL_ALL_STRENGTHS,
588 },
589
590/* Cipher 25 VRS */
591 {
592 1,
593 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
594 SSL3_CK_KRB5_DES_192_CBC3_SHA,
595 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3,
596 SSL_NOT_EXP|SSL_HIGH,
597 0,
598 112,
599 168,
600 SSL_ALL_CIPHERS,
601 SSL_ALL_STRENGTHS,
602 },
603
604/* Cipher 26 VRS */
605 {
606 1,
607 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
608 SSL3_CK_KRB5_DES_192_CBC3_MD5,
609 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3,
610 SSL_NOT_EXP|SSL_HIGH,
611 0,
612 112,
613 168,
614 SSL_ALL_CIPHERS,
615 SSL_ALL_STRENGTHS,
616 },
617#endif /* OPENSSL_NO_KRB5 */
618
619
529#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 620#if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
530 /* New TLS Export CipherSuites */ 621 /* New TLS Export CipherSuites */
531 /* Cipher 60 */ 622 /* Cipher 60 */
@@ -612,7 +703,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
612 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA, 703 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
613 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA, 704 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
614 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, 705 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
615 SSL_NOT_EXP, 706 SSL_NOT_EXP|SSL_MEDIUM,
616 0, 707 0,
617 128, 708 128,
618 128, 709 128,
@@ -620,6 +711,165 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
620 SSL_ALL_STRENGTHS 711 SSL_ALL_STRENGTHS
621 }, 712 },
622#endif 713#endif
714 /* New AES ciphersuites */
715
716 /* Cipher 2F */
717 {
718 1,
719 TLS1_TXT_RSA_WITH_AES_128_SHA,
720 TLS1_CK_RSA_WITH_AES_128_SHA,
721 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
722 SSL_NOT_EXP|SSL_MEDIUM,
723 0,
724 128,
725 128,
726 SSL_ALL_CIPHERS,
727 SSL_ALL_STRENGTHS,
728 },
729 /* Cipher 30 */
730 {
731 0,
732 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
733 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
734 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
735 SSL_NOT_EXP|SSL_MEDIUM,
736 0,
737 128,
738 128,
739 SSL_ALL_CIPHERS,
740 SSL_ALL_STRENGTHS,
741 },
742 /* Cipher 31 */
743 {
744 0,
745 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
746 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
747 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
748 SSL_NOT_EXP|SSL_MEDIUM,
749 0,
750 128,
751 128,
752 SSL_ALL_CIPHERS,
753 SSL_ALL_STRENGTHS,
754 },
755 /* Cipher 32 */
756 {
757 1,
758 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
759 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
760 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
761 SSL_NOT_EXP|SSL_MEDIUM,
762 0,
763 128,
764 128,
765 SSL_ALL_CIPHERS,
766 SSL_ALL_STRENGTHS,
767 },
768 /* Cipher 33 */
769 {
770 1,
771 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
772 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
773 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
774 SSL_NOT_EXP|SSL_MEDIUM,
775 0,
776 128,
777 128,
778 SSL_ALL_CIPHERS,
779 SSL_ALL_STRENGTHS,
780 },
781 /* Cipher 34 */
782 {
783 1,
784 TLS1_TXT_ADH_WITH_AES_128_SHA,
785 TLS1_CK_ADH_WITH_AES_128_SHA,
786 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
787 SSL_NOT_EXP|SSL_MEDIUM,
788 0,
789 128,
790 128,
791 SSL_ALL_CIPHERS,
792 SSL_ALL_STRENGTHS,
793 },
794
795 /* Cipher 35 */
796 {
797 1,
798 TLS1_TXT_RSA_WITH_AES_256_SHA,
799 TLS1_CK_RSA_WITH_AES_256_SHA,
800 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
801 SSL_NOT_EXP|SSL_HIGH,
802 0,
803 256,
804 256,
805 SSL_ALL_CIPHERS,
806 SSL_ALL_STRENGTHS,
807 },
808 /* Cipher 36 */
809 {
810 0,
811 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
812 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
813 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
814 SSL_NOT_EXP|SSL_HIGH,
815 0,
816 256,
817 256,
818 SSL_ALL_CIPHERS,
819 SSL_ALL_STRENGTHS,
820 },
821 /* Cipher 37 */
822 {
823 0,
824 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
825 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
826 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
827 SSL_NOT_EXP|SSL_HIGH,
828 0,
829 256,
830 256,
831 SSL_ALL_CIPHERS,
832 SSL_ALL_STRENGTHS,
833 },
834 /* Cipher 38 */
835 {
836 1,
837 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
838 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
839 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
840 SSL_NOT_EXP|SSL_HIGH,
841 0,
842 256,
843 256,
844 SSL_ALL_CIPHERS,
845 SSL_ALL_STRENGTHS,
846 },
847 /* Cipher 39 */
848 {
849 1,
850 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
851 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
852 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
853 SSL_NOT_EXP|SSL_HIGH,
854 0,
855 256,
856 256,
857 SSL_ALL_CIPHERS,
858 SSL_ALL_STRENGTHS,
859 },
860 /* Cipher 3A */
861 {
862 1,
863 TLS1_TXT_ADH_WITH_AES_256_SHA,
864 TLS1_CK_ADH_WITH_AES_256_SHA,
865 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
866 SSL_NOT_EXP|SSL_HIGH,
867 0,
868 256,
869 256,
870 SSL_ALL_CIPHERS,
871 SSL_ALL_STRENGTHS,
872 },
623 873
624/* end of list */ 874/* end of list */
625 }; 875 };
@@ -693,6 +943,9 @@ SSL_CIPHER *ssl3_get_cipher(unsigned int u)
693 943
694int ssl3_pending(SSL *s) 944int ssl3_pending(SSL *s)
695 { 945 {
946 if (s->rstate == SSL_ST_READ_BODY)
947 return 0;
948
696 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0; 949 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
697 } 950 }
698 951
@@ -702,6 +955,8 @@ int ssl3_new(SSL *s)
702 955
703 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err; 956 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
704 memset(s3,0,sizeof *s3); 957 memset(s3,0,sizeof *s3);
958 EVP_MD_CTX_init(&s3->finish_dgst1);
959 EVP_MD_CTX_init(&s3->finish_dgst2);
705 960
706 s->s3=s3; 961 s->s3=s3;
707 962
@@ -723,12 +978,14 @@ void ssl3_free(SSL *s)
723 OPENSSL_free(s->s3->wbuf.buf); 978 OPENSSL_free(s->s3->wbuf.buf);
724 if (s->s3->rrec.comp != NULL) 979 if (s->s3->rrec.comp != NULL)
725 OPENSSL_free(s->s3->rrec.comp); 980 OPENSSL_free(s->s3->rrec.comp);
726#ifndef NO_DH 981#ifndef OPENSSL_NO_DH
727 if (s->s3->tmp.dh != NULL) 982 if (s->s3->tmp.dh != NULL)
728 DH_free(s->s3->tmp.dh); 983 DH_free(s->s3->tmp.dh);
729#endif 984#endif
730 if (s->s3->tmp.ca_names != NULL) 985 if (s->s3->tmp.ca_names != NULL)
731 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); 986 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
987 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
988 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
732 memset(s->s3,0,sizeof *s->s3); 989 memset(s->s3,0,sizeof *s->s3);
733 OPENSSL_free(s->s3); 990 OPENSSL_free(s->s3);
734 s->s3=NULL; 991 s->s3=NULL;
@@ -737,6 +994,7 @@ void ssl3_free(SSL *s)
737void ssl3_clear(SSL *s) 994void ssl3_clear(SSL *s)
738 { 995 {
739 unsigned char *rp,*wp; 996 unsigned char *rp,*wp;
997 size_t rlen, wlen;
740 998
741 ssl3_cleanup_key_block(s); 999 ssl3_cleanup_key_block(s);
742 if (s->s3->tmp.ca_names != NULL) 1000 if (s->s3->tmp.ca_names != NULL)
@@ -747,17 +1005,24 @@ void ssl3_clear(SSL *s)
747 OPENSSL_free(s->s3->rrec.comp); 1005 OPENSSL_free(s->s3->rrec.comp);
748 s->s3->rrec.comp=NULL; 1006 s->s3->rrec.comp=NULL;
749 } 1007 }
750#ifndef NO_DH 1008#ifndef OPENSSL_NO_DH
751 if (s->s3->tmp.dh != NULL) 1009 if (s->s3->tmp.dh != NULL)
752 DH_free(s->s3->tmp.dh); 1010 DH_free(s->s3->tmp.dh);
753#endif 1011#endif
754 1012
755 rp=s->s3->rbuf.buf; 1013 rp = s->s3->rbuf.buf;
756 wp=s->s3->wbuf.buf; 1014 wp = s->s3->wbuf.buf;
1015 rlen = s->s3->rbuf.len;
1016 wlen = s->s3->wbuf.len;
1017
1018 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
1019 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
757 1020
758 memset(s->s3,0,sizeof *s->s3); 1021 memset(s->s3,0,sizeof *s->s3);
759 if (rp != NULL) s->s3->rbuf.buf=rp; 1022 s->s3->rbuf.buf = rp;
760 if (wp != NULL) s->s3->wbuf.buf=wp; 1023 s->s3->wbuf.buf = wp;
1024 s->s3->rbuf.len = rlen;
1025 s->s3->wbuf.len = wlen;
761 1026
762 ssl_free_wbio_buffer(s); 1027 ssl_free_wbio_buffer(s);
763 1028
@@ -769,17 +1034,17 @@ void ssl3_clear(SSL *s)
769 s->version=SSL3_VERSION; 1034 s->version=SSL3_VERSION;
770 } 1035 }
771 1036
772long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg) 1037long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
773 { 1038 {
774 int ret=0; 1039 int ret=0;
775 1040
776#if !defined(NO_DSA) || !defined(NO_RSA) 1041#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
777 if ( 1042 if (
778#ifndef NO_RSA 1043#ifndef OPENSSL_NO_RSA
779 cmd == SSL_CTRL_SET_TMP_RSA || 1044 cmd == SSL_CTRL_SET_TMP_RSA ||
780 cmd == SSL_CTRL_SET_TMP_RSA_CB || 1045 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
781#endif 1046#endif
782#ifndef NO_DSA 1047#ifndef OPENSSL_NO_DSA
783 cmd == SSL_CTRL_SET_TMP_DH || 1048 cmd == SSL_CTRL_SET_TMP_DH ||
784 cmd == SSL_CTRL_SET_TMP_DH_CB || 1049 cmd == SSL_CTRL_SET_TMP_DH_CB ||
785#endif 1050#endif
@@ -813,7 +1078,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
813 case SSL_CTRL_GET_FLAGS: 1078 case SSL_CTRL_GET_FLAGS:
814 ret=(int)(s->s3->flags); 1079 ret=(int)(s->s3->flags);
815 break; 1080 break;
816#ifndef NO_RSA 1081#ifndef OPENSSL_NO_RSA
817 case SSL_CTRL_NEED_TMP_RSA: 1082 case SSL_CTRL_NEED_TMP_RSA:
818 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) && 1083 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
819 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || 1084 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
@@ -846,7 +1111,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
846 } 1111 }
847 break; 1112 break;
848#endif 1113#endif
849#ifndef NO_DH 1114#ifndef OPENSSL_NO_DH
850 case SSL_CTRL_SET_TMP_DH: 1115 case SSL_CTRL_SET_TMP_DH:
851 { 1116 {
852 DH *dh = (DH *)parg; 1117 DH *dh = (DH *)parg;
@@ -892,12 +1157,12 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
892 { 1157 {
893 int ret=0; 1158 int ret=0;
894 1159
895#if !defined(NO_DSA) || !defined(NO_RSA) 1160#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
896 if ( 1161 if (
897#ifndef NO_RSA 1162#ifndef OPENSSL_NO_RSA
898 cmd == SSL_CTRL_SET_TMP_RSA_CB || 1163 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
899#endif 1164#endif
900#ifndef NO_DSA 1165#ifndef OPENSSL_NO_DSA
901 cmd == SSL_CTRL_SET_TMP_DH_CB || 1166 cmd == SSL_CTRL_SET_TMP_DH_CB ||
902#endif 1167#endif
903 0) 1168 0)
@@ -912,14 +1177,14 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
912 1177
913 switch (cmd) 1178 switch (cmd)
914 { 1179 {
915#ifndef NO_RSA 1180#ifndef OPENSSL_NO_RSA
916 case SSL_CTRL_SET_TMP_RSA_CB: 1181 case SSL_CTRL_SET_TMP_RSA_CB:
917 { 1182 {
918 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; 1183 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
919 } 1184 }
920 break; 1185 break;
921#endif 1186#endif
922#ifndef NO_DH 1187#ifndef OPENSSL_NO_DH
923 case SSL_CTRL_SET_TMP_DH_CB: 1188 case SSL_CTRL_SET_TMP_DH_CB:
924 { 1189 {
925 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; 1190 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
@@ -932,7 +1197,7 @@ long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)())
932 return(ret); 1197 return(ret);
933 } 1198 }
934 1199
935long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg) 1200long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
936 { 1201 {
937 CERT *cert; 1202 CERT *cert;
938 1203
@@ -940,7 +1205,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
940 1205
941 switch (cmd) 1206 switch (cmd)
942 { 1207 {
943#ifndef NO_RSA 1208#ifndef OPENSSL_NO_RSA
944 case SSL_CTRL_NEED_TMP_RSA: 1209 case SSL_CTRL_NEED_TMP_RSA:
945 if ( (cert->rsa_tmp == NULL) && 1210 if ( (cert->rsa_tmp == NULL) &&
946 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || 1211 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
@@ -985,7 +1250,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
985 } 1250 }
986 break; 1251 break;
987#endif 1252#endif
988#ifndef NO_DH 1253#ifndef OPENSSL_NO_DH
989 case SSL_CTRL_SET_TMP_DH: 1254 case SSL_CTRL_SET_TMP_DH:
990 { 1255 {
991 DH *new=NULL,*dh; 1256 DH *new=NULL,*dh;
@@ -1042,14 +1307,14 @@ long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
1042 1307
1043 switch (cmd) 1308 switch (cmd)
1044 { 1309 {
1045#ifndef NO_RSA 1310#ifndef OPENSSL_NO_RSA
1046 case SSL_CTRL_SET_TMP_RSA_CB: 1311 case SSL_CTRL_SET_TMP_RSA_CB:
1047 { 1312 {
1048 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; 1313 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
1049 } 1314 }
1050 break; 1315 break;
1051#endif 1316#endif
1052#ifndef NO_DH 1317#ifndef OPENSSL_NO_DH
1053 case SSL_CTRL_SET_TMP_DH_CB: 1318 case SSL_CTRL_SET_TMP_DH_CB:
1054 { 1319 {
1055 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; 1320 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
@@ -1114,10 +1379,11 @@ int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
1114 return(2); 1379 return(2);
1115 } 1380 }
1116 1381
1117SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have, 1382SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
1118 STACK_OF(SSL_CIPHER) *pref) 1383 STACK_OF(SSL_CIPHER) *srvr)
1119 { 1384 {
1120 SSL_CIPHER *c,*ret=NULL; 1385 SSL_CIPHER *c,*ret=NULL;
1386 STACK_OF(SSL_CIPHER) *prio, *allow;
1121 int i,j,ok; 1387 int i,j,ok;
1122 CERT *cert; 1388 CERT *cert;
1123 unsigned long alg,mask,emask; 1389 unsigned long alg,mask,emask;
@@ -1125,26 +1391,62 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
1125 /* Let's see which ciphers we can support */ 1391 /* Let's see which ciphers we can support */
1126 cert=s->cert; 1392 cert=s->cert;
1127 1393
1128 sk_SSL_CIPHER_set_cmp_func(pref,ssl_cipher_ptr_id_cmp); 1394#if 0
1395 /* Do not set the compare functions, because this may lead to a
1396 * reordering by "id". We want to keep the original ordering.
1397 * We may pay a price in performance during sk_SSL_CIPHER_find(),
1398 * but would have to pay with the price of sk_SSL_CIPHER_dup().
1399 */
1400 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
1401 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
1402#endif
1129 1403
1130#ifdef CIPHER_DEBUG 1404#ifdef CIPHER_DEBUG
1131 printf("Have:\n"); 1405 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), srvr);
1132 for(i=0 ; i < sk_num(pref) ; ++i) 1406 for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
1133 { 1407 {
1134 c=(SSL_CIPHER *)sk_value(pref,i); 1408 c=sk_SSL_CIPHER_value(srvr,i);
1409 printf("%p:%s\n",c,c->name);
1410 }
1411 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), clnt);
1412 for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
1413 {
1414 c=sk_SSL_CIPHER_value(clnt,i);
1135 printf("%p:%s\n",c,c->name); 1415 printf("%p:%s\n",c,c->name);
1136 } 1416 }
1137#endif 1417#endif
1138 1418
1139 for (i=0; i<sk_SSL_CIPHER_num(have); i++) 1419 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
1420 {
1421 prio = srvr;
1422 allow = clnt;
1423 }
1424 else
1425 {
1426 prio = clnt;
1427 allow = srvr;
1428 }
1429
1430 for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
1140 { 1431 {
1141 c=sk_SSL_CIPHER_value(have,i); 1432 c=sk_SSL_CIPHER_value(prio,i);
1142 1433
1143 ssl_set_cert_masks(cert,c); 1434 ssl_set_cert_masks(cert,c);
1144 mask=cert->mask; 1435 mask=cert->mask;
1145 emask=cert->export_mask; 1436 emask=cert->export_mask;
1146 1437
1438#ifdef KSSL_DEBUG
1439 printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);
1440#endif /* KSSL_DEBUG */
1441
1147 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); 1442 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
1443#ifndef OPENSSL_NO_KRB5
1444 if (alg & SSL_KRB5)
1445 {
1446 if ( !kssl_keytab_is_available(s->kssl_ctx) )
1447 continue;
1448 }
1449#endif /* OPENSSL_NO_KRB5 */
1148 if (SSL_C_IS_EXPORT(c)) 1450 if (SSL_C_IS_EXPORT(c))
1149 { 1451 {
1150 ok=((alg & emask) == alg)?1:0; 1452 ok=((alg & emask) == alg)?1:0;
@@ -1164,10 +1466,10 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
1164 1466
1165 if (!ok) continue; 1467 if (!ok) continue;
1166 1468
1167 j=sk_SSL_CIPHER_find(pref,c); 1469 j=sk_SSL_CIPHER_find(allow,c);
1168 if (j >= 0) 1470 if (j >= 0)
1169 { 1471 {
1170 ret=sk_SSL_CIPHER_value(pref,j); 1472 ret=sk_SSL_CIPHER_value(allow,j);
1171 break; 1473 break;
1172 } 1474 }
1173 } 1475 }
@@ -1181,31 +1483,31 @@ int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
1181 1483
1182 alg=s->s3->tmp.new_cipher->algorithms; 1484 alg=s->s3->tmp.new_cipher->algorithms;
1183 1485
1184#ifndef NO_DH 1486#ifndef OPENSSL_NO_DH
1185 if (alg & (SSL_kDHr|SSL_kEDH)) 1487 if (alg & (SSL_kDHr|SSL_kEDH))
1186 { 1488 {
1187# ifndef NO_RSA 1489# ifndef OPENSSL_NO_RSA
1188 p[ret++]=SSL3_CT_RSA_FIXED_DH; 1490 p[ret++]=SSL3_CT_RSA_FIXED_DH;
1189# endif 1491# endif
1190# ifndef NO_DSA 1492# ifndef OPENSSL_NO_DSA
1191 p[ret++]=SSL3_CT_DSS_FIXED_DH; 1493 p[ret++]=SSL3_CT_DSS_FIXED_DH;
1192# endif 1494# endif
1193 } 1495 }
1194 if ((s->version == SSL3_VERSION) && 1496 if ((s->version == SSL3_VERSION) &&
1195 (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) 1497 (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
1196 { 1498 {
1197# ifndef NO_RSA 1499# ifndef OPENSSL_NO_RSA
1198 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH; 1500 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
1199# endif 1501# endif
1200# ifndef NO_DSA 1502# ifndef OPENSSL_NO_DSA
1201 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH; 1503 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
1202# endif 1504# endif
1203 } 1505 }
1204#endif /* !NO_DH */ 1506#endif /* !OPENSSL_NO_DH */
1205#ifndef NO_RSA 1507#ifndef OPENSSL_NO_RSA
1206 p[ret++]=SSL3_CT_RSA_SIGN; 1508 p[ret++]=SSL3_CT_RSA_SIGN;
1207#endif 1509#endif
1208#ifndef NO_DSA 1510#ifndef OPENSSL_NO_DSA
1209 p[ret++]=SSL3_CT_DSS_SIGN; 1511 p[ret++]=SSL3_CT_DSS_SIGN;
1210#endif 1512#endif
1211 return(ret); 1513 return(ret);
@@ -1312,13 +1614,12 @@ static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
1312 if (s->s3->renegotiate) ssl3_renegotiate_check(s); 1614 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
1313 s->s3->in_read_app_data=1; 1615 s->s3->in_read_app_data=1;
1314 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); 1616 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
1315 if ((ret == -1) && (s->s3->in_read_app_data == 0)) 1617 if ((ret == -1) && (s->s3->in_read_app_data == 2))
1316 { 1618 {
1317 /* ssl3_read_bytes decided to call s->handshake_func, which 1619 /* ssl3_read_bytes decided to call s->handshake_func, which
1318 * called ssl3_read_bytes to read handshake data. 1620 * called ssl3_read_bytes to read handshake data.
1319 * However, ssl3_read_bytes actually found application data 1621 * However, ssl3_read_bytes actually found application data
1320 * and thinks that application data makes sense here (signalled 1622 * and thinks that application data makes sense here; so disable
1321 * by resetting 'in_read_app_data', strangely); so disable
1322 * handshake processing and try to read application data again. */ 1623 * handshake processing and try to read application data again. */
1323 s->in_handshake++; 1624 s->in_handshake++;
1324 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); 1625 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
diff --git a/src/lib/libssl/src/ssl/s3_pkt.c b/src/lib/libssl/src/ssl/s3_pkt.c
index 9ab76604a6..43e8502b66 100644
--- a/src/lib/libssl/src/ssl/s3_pkt.c
+++ b/src/lib/libssl/src/ssl/s3_pkt.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-2002 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
@@ -117,7 +117,7 @@
117#include "ssl_locl.h" 117#include "ssl_locl.h"
118 118
119static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, 119static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
120 unsigned int len); 120 unsigned int len, int create_empty_fragment);
121static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, 121static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
122 unsigned int len); 122 unsigned int len);
123static int ssl3_get_record(SSL *s); 123static int ssl3_get_record(SSL *s);
@@ -162,15 +162,13 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
162 162
163 { 163 {
164 /* avoid buffer overflow */ 164 /* avoid buffer overflow */
165 int max_max = SSL3_RT_MAX_PACKET_SIZE - s->packet_length; 165 int max_max = s->s3->rbuf.len - s->packet_length;
166 if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER)
167 max_max += SSL3_RT_MAX_EXTRA;
168 if (max > max_max) 166 if (max > max_max)
169 max = max_max; 167 max = max_max;
170 } 168 }
171 if (n > max) /* does not happen */ 169 if (n > max) /* does not happen */
172 { 170 {
173 SSLerr(SSL_F_SSL3_READ_N,SSL_R_INTERNAL_ERROR); 171 SSLerr(SSL_F_SSL3_READ_N,ERR_R_INTERNAL_ERROR);
174 return -1; 172 return -1;
175 } 173 }
176 174
@@ -231,14 +229,15 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
231static int ssl3_get_record(SSL *s) 229static int ssl3_get_record(SSL *s)
232 { 230 {
233 int ssl_major,ssl_minor,al; 231 int ssl_major,ssl_minor,al;
234 int n,i,ret= -1; 232 int enc_err,n,i,ret= -1;
235 SSL3_RECORD *rr; 233 SSL3_RECORD *rr;
236 SSL_SESSION *sess; 234 SSL_SESSION *sess;
237 unsigned char *p; 235 unsigned char *p;
238 unsigned char md[EVP_MAX_MD_SIZE]; 236 unsigned char md[EVP_MAX_MD_SIZE];
239 short version; 237 short version;
240 unsigned int mac_size; 238 unsigned int mac_size;
241 int clear=0,extra; 239 int clear=0;
240 size_t extra;
242 241
243 rr= &(s->s3->rrec); 242 rr= &(s->s3->rrec);
244 sess=s->session; 243 sess=s->session;
@@ -247,14 +246,20 @@ static int ssl3_get_record(SSL *s)
247 extra=SSL3_RT_MAX_EXTRA; 246 extra=SSL3_RT_MAX_EXTRA;
248 else 247 else
249 extra=0; 248 extra=0;
249 if (extra != s->s3->rbuf.len - SSL3_RT_MAX_PACKET_SIZE)
250 {
251 /* actually likely an application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER
252 * set after ssl3_setup_buffers() was done */
253 SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR);
254 return -1;
255 }
250 256
251again: 257again:
252 /* check if we have the header */ 258 /* check if we have the header */
253 if ( (s->rstate != SSL_ST_READ_BODY) || 259 if ( (s->rstate != SSL_ST_READ_BODY) ||
254 (s->packet_length < SSL3_RT_HEADER_LENGTH)) 260 (s->packet_length < SSL3_RT_HEADER_LENGTH))
255 { 261 {
256 n=ssl3_read_n(s,SSL3_RT_HEADER_LENGTH, 262 n=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);
257 SSL3_RT_MAX_PACKET_SIZE,0);
258 if (n <= 0) return(n); /* error or non-blocking */ 263 if (n <= 0) return(n); /* error or non-blocking */
259 s->rstate=SSL_ST_READ_BODY; 264 s->rstate=SSL_ST_READ_BODY;
260 265
@@ -291,8 +296,7 @@ again:
291 goto err; 296 goto err;
292 } 297 }
293 298
294 if (rr->length > 299 if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
295 (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
296 { 300 {
297 al=SSL_AD_RECORD_OVERFLOW; 301 al=SSL_AD_RECORD_OVERFLOW;
298 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG); 302 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG);
@@ -304,7 +308,7 @@ again:
304 308
305 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ 309 /* s->rstate == SSL_ST_READ_BODY, get and decode the data */
306 310
307 if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH)) 311 if (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH)
308 { 312 {
309 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ 313 /* now s->packet_length == SSL3_RT_HEADER_LENGTH */
310 i=rr->length; 314 i=rr->length;
@@ -332,7 +336,7 @@ again:
332 * rr->length bytes of encrypted compressed stuff. */ 336 * rr->length bytes of encrypted compressed stuff. */
333 337
334 /* check is not needed I believe */ 338 /* check is not needed I believe */
335 if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) 339 if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra)
336 { 340 {
337 al=SSL_AD_RECORD_OVERFLOW; 341 al=SSL_AD_RECORD_OVERFLOW;
338 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG); 342 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
@@ -342,16 +346,23 @@ again:
342 /* decrypt in place in 'rr->input' */ 346 /* decrypt in place in 'rr->input' */
343 rr->data=rr->input; 347 rr->data=rr->input;
344 348
345 if (!s->method->ssl3_enc->enc(s,0)) 349 enc_err = s->method->ssl3_enc->enc(s,0);
350 if (enc_err <= 0)
346 { 351 {
347 al=SSL_AD_DECRYPT_ERROR; 352 if (enc_err == 0)
348 goto f_err; 353 /* SSLerr() and ssl3_send_alert() have been called */
354 goto err;
355
356 /* otherwise enc_err == -1 */
357 goto decryption_failed_or_bad_record_mac;
349 } 358 }
359
350#ifdef TLS_DEBUG 360#ifdef TLS_DEBUG
351printf("dec %d\n",rr->length); 361printf("dec %d\n",rr->length);
352{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); } 362{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); }
353printf("\n"); 363printf("\n");
354#endif 364#endif
365
355 /* r->length is now the compressed data plus mac */ 366 /* r->length is now the compressed data plus mac */
356 if ( (sess == NULL) || 367 if ( (sess == NULL) ||
357 (s->enc_read_ctx == NULL) || 368 (s->enc_read_ctx == NULL) ||
@@ -364,33 +375,37 @@ printf("\n");
364 375
365 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size) 376 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)
366 { 377 {
378#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */
367 al=SSL_AD_RECORD_OVERFLOW; 379 al=SSL_AD_RECORD_OVERFLOW;
368 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); 380 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
369 goto f_err; 381 goto f_err;
382#else
383 goto decryption_failed_or_bad_record_mac;
384#endif
370 } 385 }
371 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ 386 /* check the MAC for rr->input (it's in mac_size bytes at the tail) */
372 if (rr->length < mac_size) 387 if (rr->length < mac_size)
373 { 388 {
389#if 0 /* OK only for stream ciphers */
374 al=SSL_AD_DECODE_ERROR; 390 al=SSL_AD_DECODE_ERROR;
375 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); 391 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
376 goto f_err; 392 goto f_err;
393#else
394 goto decryption_failed_or_bad_record_mac;
395#endif
377 } 396 }
378 rr->length-=mac_size; 397 rr->length-=mac_size;
379 i=s->method->ssl3_enc->mac(s,md,0); 398 i=s->method->ssl3_enc->mac(s,md,0);
380 if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) 399 if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0)
381 { 400 {
382 al=SSL_AD_BAD_RECORD_MAC; 401 goto decryption_failed_or_bad_record_mac;
383 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_MAC_DECODE);
384 ret= -1;
385 goto f_err;
386 } 402 }
387 } 403 }
388 404
389 /* r->length is now just compressed */ 405 /* r->length is now just compressed */
390 if (s->expand != NULL) 406 if (s->expand != NULL)
391 { 407 {
392 if (rr->length > 408 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra)
393 (unsigned int)SSL3_RT_MAX_COMPRESSED_LENGTH+extra)
394 { 409 {
395 al=SSL_AD_RECORD_OVERFLOW; 410 al=SSL_AD_RECORD_OVERFLOW;
396 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG); 411 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);
@@ -404,7 +419,7 @@ printf("\n");
404 } 419 }
405 } 420 }
406 421
407 if (rr->length > (unsigned int)SSL3_RT_MAX_PLAIN_LENGTH+extra) 422 if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra)
408 { 423 {
409 al=SSL_AD_RECORD_OVERFLOW; 424 al=SSL_AD_RECORD_OVERFLOW;
410 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG); 425 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);
@@ -427,6 +442,15 @@ printf("\n");
427 if (rr->length == 0) goto again; 442 if (rr->length == 0) goto again;
428 443
429 return(1); 444 return(1);
445
446decryption_failed_or_bad_record_mac:
447 /* Separate 'decryption_failed' alert was introduced with TLS 1.0,
448 * SSL 3.0 only has 'bad_record_mac'. But unless a decryption
449 * failure is directly visible from the ciphertext anyway,
450 * we should not reveal which kind of error occured -- this
451 * might become visible to an attacker (e.g. via logfile) */
452 al=SSL_AD_BAD_RECORD_MAC;
453 SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC);
430f_err: 454f_err:
431 ssl3_send_alert(s,SSL3_AL_FATAL,al); 455 ssl3_send_alert(s,SSL3_AL_FATAL,al);
432err: 456err:
@@ -488,7 +512,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
488 if (i == 0) 512 if (i == 0)
489 { 513 {
490 SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); 514 SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
491 return(-1); 515 return -1;
492 } 516 }
493 } 517 }
494 518
@@ -500,18 +524,22 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
500 else 524 else
501 nw=n; 525 nw=n;
502 526
503 i=do_ssl3_write(s,type,&(buf[tot]),nw); 527 i=do_ssl3_write(s, type, &(buf[tot]), nw, 0);
504 if (i <= 0) 528 if (i <= 0)
505 { 529 {
506 s->s3->wnum=tot; 530 s->s3->wnum=tot;
507 return(i); 531 return i;
508 } 532 }
509 533
510 if ((i == (int)n) || 534 if ((i == (int)n) ||
511 (type == SSL3_RT_APPLICATION_DATA && 535 (type == SSL3_RT_APPLICATION_DATA &&
512 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) 536 (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)))
513 { 537 {
514 return(tot+i); 538 /* next chunk of data should get another prepended empty fragment
539 * in ciphersuites with known-IV weakness: */
540 s->s3->empty_fragment_done = 0;
541
542 return tot+i;
515 } 543 }
516 544
517 n-=i; 545 n-=i;
@@ -520,15 +548,16 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
520 } 548 }
521 549
522static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, 550static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
523 unsigned int len) 551 unsigned int len, int create_empty_fragment)
524 { 552 {
525 unsigned char *p,*plen; 553 unsigned char *p,*plen;
526 int i,mac_size,clear=0; 554 int i,mac_size,clear=0;
555 int prefix_len = 0;
527 SSL3_RECORD *wr; 556 SSL3_RECORD *wr;
528 SSL3_BUFFER *wb; 557 SSL3_BUFFER *wb;
529 SSL_SESSION *sess; 558 SSL_SESSION *sess;
530 559
531 /* first check is there is a SSL3_RECORD still being written 560 /* first check if there is a SSL3_BUFFER still being written
532 * out. This will happen with non blocking IO */ 561 * out. This will happen with non blocking IO */
533 if (s->s3->wbuf.left != 0) 562 if (s->s3->wbuf.left != 0)
534 return(ssl3_write_pending(s,type,buf,len)); 563 return(ssl3_write_pending(s,type,buf,len));
@@ -542,7 +571,8 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
542 /* if it went, fall through and send more stuff */ 571 /* if it went, fall through and send more stuff */
543 } 572 }
544 573
545 if (len == 0) return(len); 574 if (len == 0 && !create_empty_fragment)
575 return 0;
546 576
547 wr= &(s->s3->wrec); 577 wr= &(s->s3->wrec);
548 wb= &(s->s3->wbuf); 578 wb= &(s->s3->wbuf);
@@ -558,16 +588,44 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
558 else 588 else
559 mac_size=EVP_MD_size(s->write_hash); 589 mac_size=EVP_MD_size(s->write_hash);
560 590
561 p=wb->buf; 591 /* 'create_empty_fragment' is true only when this function calls itself */
592 if (!clear && !create_empty_fragment && !s->s3->empty_fragment_done)
593 {
594 /* countermeasure against known-IV weakness in CBC ciphersuites
595 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
596
597 if (s->s3->need_empty_fragments && type == SSL3_RT_APPLICATION_DATA)
598 {
599 /* recursive function call with 'create_empty_fragment' set;
600 * this prepares and buffers the data for an empty fragment
601 * (these 'prefix_len' bytes are sent out later
602 * together with the actual payload) */
603 prefix_len = do_ssl3_write(s, type, buf, 0, 1);
604 if (prefix_len <= 0)
605 goto err;
606
607 if (s->s3->wbuf.len < (size_t)prefix_len + SSL3_RT_MAX_PACKET_SIZE)
608 {
609 /* insufficient space */
610 SSLerr(SSL_F_DO_SSL3_WRITE, ERR_R_INTERNAL_ERROR);
611 goto err;
612 }
613 }
614
615 s->s3->empty_fragment_done = 1;
616 }
617
618 p = wb->buf + prefix_len;
562 619
563 /* write the header */ 620 /* write the header */
621
564 *(p++)=type&0xff; 622 *(p++)=type&0xff;
565 wr->type=type; 623 wr->type=type;
566 624
567 *(p++)=(s->version>>8); 625 *(p++)=(s->version>>8);
568 *(p++)=s->version&0xff; 626 *(p++)=s->version&0xff;
569 627
570 /* record where we are to write out packet length */ 628 /* field where we are to write out packet length */
571 plen=p; 629 plen=p;
572 p+=2; 630 p+=2;
573 631
@@ -618,19 +676,28 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
618 wr->type=type; /* not needed but helps for debugging */ 676 wr->type=type; /* not needed but helps for debugging */
619 wr->length+=SSL3_RT_HEADER_LENGTH; 677 wr->length+=SSL3_RT_HEADER_LENGTH;
620 678
621 /* Now lets setup wb */ 679 if (create_empty_fragment)
622 wb->left=wr->length; 680 {
623 wb->offset=0; 681 /* we are in a recursive call;
682 * just return the length, don't write out anything here
683 */
684 return wr->length;
685 }
686
687 /* now let's set up wb */
688 wb->left = prefix_len + wr->length;
689 wb->offset = 0;
624 690
691 /* memorize arguments so that ssl3_write_pending can detect bad write retries later */
625 s->s3->wpend_tot=len; 692 s->s3->wpend_tot=len;
626 s->s3->wpend_buf=buf; 693 s->s3->wpend_buf=buf;
627 s->s3->wpend_type=type; 694 s->s3->wpend_type=type;
628 s->s3->wpend_ret=len; 695 s->s3->wpend_ret=len;
629 696
630 /* we now just need to write the buffer */ 697 /* we now just need to write the buffer */
631 return(ssl3_write_pending(s,type,buf,len)); 698 return ssl3_write_pending(s,type,buf,len);
632err: 699err:
633 return(-1); 700 return -1;
634 } 701 }
635 702
636/* if s->s3->wbuf.left != 0, we need to call this */ 703/* if s->s3->wbuf.left != 0, we need to call this */
@@ -709,7 +776,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
709 int al,i,j,ret; 776 int al,i,j,ret;
710 unsigned int n; 777 unsigned int n;
711 SSL3_RECORD *rr; 778 SSL3_RECORD *rr;
712 void (*cb)()=NULL; 779 void (*cb)(const SSL *ssl,int type2,int val)=NULL;
713 780
714 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ 781 if (s->s3->rbuf.buf == NULL) /* Not initialized yet */
715 if (!ssl3_setup_buffers(s)) 782 if (!ssl3_setup_buffers(s))
@@ -718,7 +785,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
718 if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) || 785 if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) ||
719 (peek && (type != SSL3_RT_APPLICATION_DATA))) 786 (peek && (type != SSL3_RT_APPLICATION_DATA)))
720 { 787 {
721 SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR); 788 SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR);
722 return -1; 789 return -1;
723 } 790 }
724 791
@@ -890,6 +957,9 @@ start:
890 goto err; 957 goto err;
891 } 958 }
892 959
960 if (s->msg_callback)
961 s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg);
962
893 if (SSL_is_init_finished(s) && 963 if (SSL_is_init_finished(s) &&
894 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && 964 !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&
895 !s->s3->renegotiate) 965 !s->s3->renegotiate)
@@ -935,6 +1005,9 @@ start:
935 1005
936 s->s3->alert_fragment_len = 0; 1006 s->s3->alert_fragment_len = 0;
937 1007
1008 if (s->msg_callback)
1009 s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg);
1010
938 if (s->info_callback != NULL) 1011 if (s->info_callback != NULL)
939 cb=s->info_callback; 1012 cb=s->info_callback;
940 else if (s->ctx->info_callback != NULL) 1013 else if (s->ctx->info_callback != NULL)
@@ -998,6 +1071,10 @@ start:
998 } 1071 }
999 1072
1000 rr->length=0; 1073 rr->length=0;
1074
1075 if (s->msg_callback)
1076 s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg);
1077
1001 s->s3->change_cipher_spec=1; 1078 s->s3->change_cipher_spec=1;
1002 if (!do_change_cipher_spec(s)) 1079 if (!do_change_cipher_spec(s))
1003 goto err; 1080 goto err;
@@ -1052,10 +1129,11 @@ start:
1052 switch (rr->type) 1129 switch (rr->type)
1053 { 1130 {
1054 default: 1131 default:
1055#ifndef NO_TLS 1132#ifndef OPENSSL_NO_TLS
1056 /* TLS just ignores unknown message types */ 1133 /* TLS just ignores unknown message types */
1057 if (s->version == TLS1_VERSION) 1134 if (s->version == TLS1_VERSION)
1058 { 1135 {
1136 rr->length = 0;
1059 goto start; 1137 goto start;
1060 } 1138 }
1061#endif 1139#endif
@@ -1069,7 +1147,7 @@ start:
1069 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that 1147 * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that
1070 * should not happen when type != rr->type */ 1148 * should not happen when type != rr->type */
1071 al=SSL_AD_UNEXPECTED_MESSAGE; 1149 al=SSL_AD_UNEXPECTED_MESSAGE;
1072 SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_INTERNAL_ERROR); 1150 SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR);
1073 goto f_err; 1151 goto f_err;
1074 case SSL3_RT_APPLICATION_DATA: 1152 case SSL3_RT_APPLICATION_DATA:
1075 /* At this point, we were expecting handshake data, 1153 /* At this point, we were expecting handshake data,
@@ -1092,7 +1170,7 @@ start:
1092 ) 1170 )
1093 )) 1171 ))
1094 { 1172 {
1095 s->s3->in_read_app_data=0; 1173 s->s3->in_read_app_data=2;
1096 return(-1); 1174 return(-1);
1097 } 1175 }
1098 else 1176 else
@@ -1156,6 +1234,8 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1156 { 1234 {
1157 /* Map tls/ssl alert value to correct one */ 1235 /* Map tls/ssl alert value to correct one */
1158 desc=s->method->ssl3_enc->alert_value(desc); 1236 desc=s->method->ssl3_enc->alert_value(desc);
1237 if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)
1238 desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */
1159 if (desc < 0) return; 1239 if (desc < 0) return;
1160 /* If a fatal one, remove from cache */ 1240 /* If a fatal one, remove from cache */
1161 if ((level == 2) && (s->session != NULL)) 1241 if ((level == 2) && (s->session != NULL))
@@ -1164,7 +1244,7 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1164 s->s3->alert_dispatch=1; 1244 s->s3->alert_dispatch=1;
1165 s->s3->send_alert[0]=level; 1245 s->s3->send_alert[0]=level;
1166 s->s3->send_alert[1]=desc; 1246 s->s3->send_alert[1]=desc;
1167 if (s->s3->wbuf.left == 0) /* data still being written out */ 1247 if (s->s3->wbuf.left == 0) /* data still being written out? */
1168 ssl3_dispatch_alert(s); 1248 ssl3_dispatch_alert(s);
1169 /* else data is still being written out, we will get written 1249 /* else data is still being written out, we will get written
1170 * some time in the future */ 1250 * some time in the future */
@@ -1173,22 +1253,25 @@ void ssl3_send_alert(SSL *s, int level, int desc)
1173int ssl3_dispatch_alert(SSL *s) 1253int ssl3_dispatch_alert(SSL *s)
1174 { 1254 {
1175 int i,j; 1255 int i,j;
1176 void (*cb)()=NULL; 1256 void (*cb)(const SSL *ssl,int type,int val)=NULL;
1177 1257
1178 s->s3->alert_dispatch=0; 1258 s->s3->alert_dispatch=0;
1179 i=do_ssl3_write(s,SSL3_RT_ALERT,&s->s3->send_alert[0],2); 1259 i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], 2, 0);
1180 if (i <= 0) 1260 if (i <= 0)
1181 { 1261 {
1182 s->s3->alert_dispatch=1; 1262 s->s3->alert_dispatch=1;
1183 } 1263 }
1184 else 1264 else
1185 { 1265 {
1186 /* If it is important, send it now. If the message 1266 /* Alert sent to BIO. If it is important, flush it now.
1187 * does not get sent due to non-blocking IO, we will 1267 * If the message does not get sent due to non-blocking IO,
1188 * not worry too much. */ 1268 * we will not worry too much. */
1189 if (s->s3->send_alert[0] == SSL3_AL_FATAL) 1269 if (s->s3->send_alert[0] == SSL3_AL_FATAL)
1190 (void)BIO_flush(s->wbio); 1270 (void)BIO_flush(s->wbio);
1191 1271
1272 if (s->msg_callback)
1273 s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg);
1274
1192 if (s->info_callback != NULL) 1275 if (s->info_callback != NULL)
1193 cb=s->info_callback; 1276 cb=s->info_callback;
1194 else if (s->ctx->info_callback != NULL) 1277 else if (s->ctx->info_callback != NULL)
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c
index 258af84867..99b6a86983 100644
--- a/src/lib/libssl/src/ssl/s3_srvr.c
+++ b/src/lib/libssl/src/ssl/s3_srvr.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#define REUSE_CIPHER_BUG 112#define REUSE_CIPHER_BUG
60#define NETSCAPE_HANG_BUG 113#define NETSCAPE_HANG_BUG
@@ -64,11 +117,12 @@
64#include <openssl/buffer.h> 117#include <openssl/buffer.h>
65#include <openssl/rand.h> 118#include <openssl/rand.h>
66#include <openssl/objects.h> 119#include <openssl/objects.h>
67#include <openssl/md5.h>
68#include <openssl/sha.h>
69#include <openssl/evp.h> 120#include <openssl/evp.h>
70#include <openssl/x509.h> 121#include <openssl/x509.h>
122#include <openssl/krb5_asn.h>
71#include "ssl_locl.h" 123#include "ssl_locl.h"
124#include "kssl_lcl.h"
125#include <openssl/md5.h>
72 126
73static SSL_METHOD *ssl3_get_server_method(int ver); 127static SSL_METHOD *ssl3_get_server_method(int ver);
74static int ssl3_get_client_hello(SSL *s); 128static int ssl3_get_client_hello(SSL *s);
@@ -110,7 +164,7 @@ int ssl3_accept(SSL *s)
110 { 164 {
111 BUF_MEM *buf; 165 BUF_MEM *buf;
112 unsigned long l,Time=time(NULL); 166 unsigned long l,Time=time(NULL);
113 void (*cb)()=NULL; 167 void (*cb)(const SSL *ssl,int type,int val)=NULL;
114 long num1; 168 long num1;
115 int ret= -1; 169 int ret= -1;
116 int new_state,state,skip=0; 170 int new_state,state,skip=0;
@@ -125,8 +179,8 @@ int ssl3_accept(SSL *s)
125 cb=s->ctx->info_callback; 179 cb=s->ctx->info_callback;
126 180
127 /* init things to blank */ 181 /* init things to blank */
128 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
129 s->in_handshake++; 182 s->in_handshake++;
183 if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
130 184
131 if (s->cert == NULL) 185 if (s->cert == NULL)
132 { 186 {
@@ -154,7 +208,7 @@ int ssl3_accept(SSL *s)
154 208
155 if ((s->version>>8) != 3) 209 if ((s->version>>8) != 3)
156 { 210 {
157 SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_INTERNAL_ERROR); 211 SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
158 return -1; 212 return -1;
159 } 213 }
160 s->type=SSL_ST_ACCEPT; 214 s->type=SSL_ST_ACCEPT;
@@ -180,21 +234,23 @@ int ssl3_accept(SSL *s)
180 goto end; 234 goto end;
181 } 235 }
182 236
183 /* Ok, we now need to push on a buffering BIO so that
184 * the output is sent in a way that TCP likes :-)
185 */
186 if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }
187
188 s->init_num=0; 237 s->init_num=0;
189 238
190 if (s->state != SSL_ST_RENEGOTIATE) 239 if (s->state != SSL_ST_RENEGOTIATE)
191 { 240 {
241 /* Ok, we now need to push on a buffering BIO so that
242 * the output is sent in a way that TCP likes :-)
243 */
244 if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }
245
192 ssl3_init_finished_mac(s); 246 ssl3_init_finished_mac(s);
193 s->state=SSL3_ST_SR_CLNT_HELLO_A; 247 s->state=SSL3_ST_SR_CLNT_HELLO_A;
194 s->ctx->stats.sess_accept++; 248 s->ctx->stats.sess_accept++;
195 } 249 }
196 else 250 else
197 { 251 {
252 /* s->state == SSL_ST_RENEGOTIATE,
253 * we will just send a HelloRequest */
198 s->ctx->stats.sess_accept_renegotiate++; 254 s->ctx->stats.sess_accept_renegotiate++;
199 s->state=SSL3_ST_SW_HELLO_REQ_A; 255 s->state=SSL3_ST_SW_HELLO_REQ_A;
200 } 256 }
@@ -215,9 +271,7 @@ int ssl3_accept(SSL *s)
215 271
216 case SSL3_ST_SW_HELLO_REQ_C: 272 case SSL3_ST_SW_HELLO_REQ_C:
217 s->state=SSL_ST_OK; 273 s->state=SSL_ST_OK;
218 ret=1; 274 break;
219 goto end;
220 /* break; */
221 275
222 case SSL3_ST_SR_CLNT_HELLO_A: 276 case SSL3_ST_SR_CLNT_HELLO_A:
223 case SSL3_ST_SR_CLNT_HELLO_B: 277 case SSL3_ST_SR_CLNT_HELLO_B:
@@ -226,6 +280,7 @@ int ssl3_accept(SSL *s)
226 s->shutdown=0; 280 s->shutdown=0;
227 ret=ssl3_get_client_hello(s); 281 ret=ssl3_get_client_hello(s);
228 if (ret <= 0) goto end; 282 if (ret <= 0) goto end;
283 s->new_session = 2;
229 s->state=SSL3_ST_SW_SRVR_HELLO_A; 284 s->state=SSL3_ST_SW_SRVR_HELLO_A;
230 s->init_num=0; 285 s->init_num=0;
231 break; 286 break;
@@ -262,7 +317,15 @@ int ssl3_accept(SSL *s)
262 317
263 /* clear this, it may get reset by 318 /* clear this, it may get reset by
264 * send_server_key_exchange */ 319 * send_server_key_exchange */
265 if (s->options & SSL_OP_EPHEMERAL_RSA) 320 if ((s->options & SSL_OP_EPHEMERAL_RSA)
321#ifndef OPENSSL_NO_KRB5
322 && !(l & SSL_KRB5)
323#endif /* OPENSSL_NO_KRB5 */
324 )
325 /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key
326 * even when forbidden by protocol specs
327 * (handshake may fail as clients are not required to
328 * be able to handle this) */
266 s->s3->tmp.use_rsa_tmp=1; 329 s->s3->tmp.use_rsa_tmp=1;
267 else 330 else
268 s->s3->tmp.use_rsa_tmp=0; 331 s->s3->tmp.use_rsa_tmp=0;
@@ -304,7 +367,9 @@ int ssl3_accept(SSL *s)
304 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) && 367 ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) &&
305 /* ... except when the application insists on verification 368 /* ... except when the application insists on verification
306 * (against the specs, but s3_clnt.c accepts this for SSL 3) */ 369 * (against the specs, but s3_clnt.c accepts this for SSL 3) */
307 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT))) 370 !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
371 /* never request cert in Kerberos ciphersuites */
372 (s->s3->tmp.new_cipher->algorithms & SSL_aKRB5))
308 { 373 {
309 /* no cert request */ 374 /* no cert request */
310 skip=1; 375 skip=1;
@@ -456,18 +521,25 @@ int ssl3_accept(SSL *s)
456 /* remove buffering on output */ 521 /* remove buffering on output */
457 ssl_free_wbio_buffer(s); 522 ssl_free_wbio_buffer(s);
458 523
459 s->new_session=0;
460 s->init_num=0; 524 s->init_num=0;
461 525
462 ssl_update_cache(s,SSL_SESS_CACHE_SERVER); 526 if (s->new_session == 2) /* skipped if we just sent a HelloRequest */
463 527 {
464 s->ctx->stats.sess_accept_good++; 528 /* actually not necessarily a 'new' session unless
465 /* s->server=1; */ 529 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
466 s->handshake_func=ssl3_accept; 530
467 ret=1; 531 s->new_session=0;
468 532
469 if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); 533 ssl_update_cache(s,SSL_SESS_CACHE_SERVER);
470 534
535 s->ctx->stats.sess_accept_good++;
536 /* s->server=1; */
537 s->handshake_func=ssl3_accept;
538
539 if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);
540 }
541
542 ret = 1;
471 goto end; 543 goto end;
472 /* break; */ 544 /* break; */
473 545
@@ -500,9 +572,9 @@ int ssl3_accept(SSL *s)
500end: 572end:
501 /* BIO_flush(s->wbio); */ 573 /* BIO_flush(s->wbio); */
502 574
575 s->in_handshake--;
503 if (cb != NULL) 576 if (cb != NULL)
504 cb(s,SSL_CB_ACCEPT_EXIT,ret); 577 cb(s,SSL_CB_ACCEPT_EXIT,ret);
505 s->in_handshake--;
506 return(ret); 578 return(ret);
507 } 579 }
508 580
@@ -533,11 +605,13 @@ static int ssl3_check_client_hello(SSL *s)
533 int ok; 605 int ok;
534 long n; 606 long n;
535 607
608 /* this function is called when we really expect a Certificate message,
609 * so permit appropriate message length */
536 n=ssl3_get_message(s, 610 n=ssl3_get_message(s,
537 SSL3_ST_SR_CERT_A, 611 SSL3_ST_SR_CERT_A,
538 SSL3_ST_SR_CERT_B, 612 SSL3_ST_SR_CERT_B,
539 -1, 613 -1,
540 SSL3_RT_MAX_PLAIN_LENGTH, 614 s->max_cert_list,
541 &ok); 615 &ok);
542 if (!ok) return((int)n); 616 if (!ok) return((int)n);
543 s->s3->tmp.reuse_message = 1; 617 s->s3->tmp.reuse_message = 1;
@@ -547,7 +621,7 @@ static int ssl3_check_client_hello(SSL *s)
547 * which will now be aborted. (A full SSL_clear would be too much.) 621 * which will now be aborted. (A full SSL_clear would be too much.)
548 * I hope that tmp.dh is the only thing that may need to be cleared 622 * I hope that tmp.dh is the only thing that may need to be cleared
549 * when a handshake is not completed ... */ 623 * when a handshake is not completed ... */
550#ifndef NO_DH 624#ifndef OPENSSL_NO_DH
551 if (s->s3->tmp.dh != NULL) 625 if (s->s3->tmp.dh != NULL)
552 { 626 {
553 DH_free(s->s3->tmp.dh); 627 DH_free(s->s3->tmp.dh);
@@ -588,13 +662,25 @@ static int ssl3_get_client_hello(SSL *s)
588 &ok); 662 &ok);
589 663
590 if (!ok) return((int)n); 664 if (!ok) return((int)n);
591 d=p=(unsigned char *)s->init_buf->data; 665 d=p=(unsigned char *)s->init_msg;
592 666
593 /* use version from inside client hello, not from record header 667 /* use version from inside client hello, not from record header
594 * (may differ: see RFC 2246, Appendix E, second paragraph) */ 668 * (may differ: see RFC 2246, Appendix E, second paragraph) */
595 s->client_version=(((int)p[0])<<8)|(int)p[1]; 669 s->client_version=(((int)p[0])<<8)|(int)p[1];
596 p+=2; 670 p+=2;
597 671
672 if (s->client_version < s->version)
673 {
674 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
675 if ((s->client_version>>8) == SSL3_VERSION_MAJOR)
676 {
677 /* similar to ssl3_get_record, send alert using remote version number */
678 s->version = s->client_version;
679 }
680 al = SSL_AD_PROTOCOL_VERSION;
681 goto f_err;
682 }
683
598 /* load the client random */ 684 /* load the client random */
599 memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE); 685 memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE);
600 p+=SSL3_RANDOM_SIZE; 686 p+=SSL3_RANDOM_SIZE;
@@ -603,7 +689,15 @@ static int ssl3_get_client_hello(SSL *s)
603 j= *(p++); 689 j= *(p++);
604 690
605 s->hit=0; 691 s->hit=0;
606 if (j == 0) 692 /* Versions before 0.9.7 always allow session reuse during renegotiation
693 * (i.e. when s->new_session is true), option
694 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is new with 0.9.7.
695 * Maybe this optional behaviour should always have been the default,
696 * but we cannot safely change the default behaviour (or new applications
697 * might be written that become totally unsecure when compiled with
698 * an earlier library version)
699 */
700 if (j == 0 || (s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)))
607 { 701 {
608 if (!ssl_get_new_session(s,1)) 702 if (!ssl_get_new_session(s,1))
609 goto err; 703 goto err;
@@ -633,7 +727,7 @@ static int ssl3_get_client_hello(SSL *s)
633 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED); 727 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED);
634 goto f_err; 728 goto f_err;
635 } 729 }
636 if ((i+p) > (d+n)) 730 if ((p+i) >= (d+n))
637 { 731 {
638 /* not enough data */ 732 /* not enough data */
639 al=SSL_AD_DECODE_ERROR; 733 al=SSL_AD_DECODE_ERROR;
@@ -690,6 +784,13 @@ static int ssl3_get_client_hello(SSL *s)
690 784
691 /* compression */ 785 /* compression */
692 i= *(p++); 786 i= *(p++);
787 if ((p+i) > (d+n))
788 {
789 /* not enough data */
790 al=SSL_AD_DECODE_ERROR;
791 SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);
792 goto f_err;
793 }
693 q=p; 794 q=p;
694 for (j=0; j<i; j++) 795 for (j=0; j<i; j++)
695 { 796 {
@@ -737,7 +838,7 @@ static int ssl3_get_client_hello(SSL *s)
737 /* TLS does not mind if there is extra stuff */ 838 /* TLS does not mind if there is extra stuff */
738 if (s->version == SSL3_VERSION) 839 if (s->version == SSL3_VERSION)
739 { 840 {
740 if (p > (d+n)) 841 if (p < (d+n))
741 { 842 {
742 /* wrong number of bytes, 843 /* wrong number of bytes,
743 * there could be more to follow */ 844 * there could be more to follow */
@@ -747,7 +848,7 @@ static int ssl3_get_client_hello(SSL *s)
747 } 848 }
748 } 849 }
749 850
750 /* Given s->session->ciphers and ssl_get_ciphers_by_id(s), we must 851 /* Given s->session->ciphers and SSL_get_ciphers, we must
751 * pick a cipher */ 852 * pick a cipher */
752 853
753 if (!s->hit) 854 if (!s->hit)
@@ -764,7 +865,7 @@ static int ssl3_get_client_hello(SSL *s)
764 } 865 }
765 ciphers=NULL; 866 ciphers=NULL;
766 c=ssl3_choose_cipher(s,s->session->ciphers, 867 c=ssl3_choose_cipher(s,s->session->ciphers,
767 ssl_get_ciphers_by_id(s)); 868 SSL_get_ciphers(s));
768 869
769 if (c == NULL) 870 if (c == NULL)
770 { 871 {
@@ -919,14 +1020,14 @@ static int ssl3_send_server_done(SSL *s)
919 1020
920static int ssl3_send_server_key_exchange(SSL *s) 1021static int ssl3_send_server_key_exchange(SSL *s)
921 { 1022 {
922#ifndef NO_RSA 1023#ifndef OPENSSL_NO_RSA
923 unsigned char *q; 1024 unsigned char *q;
924 int j,num; 1025 int j,num;
925 RSA *rsa; 1026 RSA *rsa;
926 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; 1027 unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
927 unsigned int u; 1028 unsigned int u;
928#endif 1029#endif
929#ifndef NO_DH 1030#ifndef OPENSSL_NO_DH
930 DH *dh=NULL,*dhp; 1031 DH *dh=NULL,*dhp;
931#endif 1032#endif
932 EVP_PKEY *pkey; 1033 EVP_PKEY *pkey;
@@ -940,6 +1041,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
940 BUF_MEM *buf; 1041 BUF_MEM *buf;
941 EVP_MD_CTX md_ctx; 1042 EVP_MD_CTX md_ctx;
942 1043
1044 EVP_MD_CTX_init(&md_ctx);
943 if (s->state == SSL3_ST_SW_KEY_EXCH_A) 1045 if (s->state == SSL3_ST_SW_KEY_EXCH_A)
944 { 1046 {
945 type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK; 1047 type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK;
@@ -949,7 +1051,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
949 1051
950 r[0]=r[1]=r[2]=r[3]=NULL; 1052 r[0]=r[1]=r[2]=r[3]=NULL;
951 n=0; 1053 n=0;
952#ifndef NO_RSA 1054#ifndef OPENSSL_NO_RSA
953 if (type & SSL_kRSA) 1055 if (type & SSL_kRSA)
954 { 1056 {
955 rsa=cert->rsa_tmp; 1057 rsa=cert->rsa_tmp;
@@ -964,7 +1066,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
964 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY); 1066 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY);
965 goto f_err; 1067 goto f_err;
966 } 1068 }
967 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 1069 RSA_up_ref(rsa);
968 cert->rsa_tmp=rsa; 1070 cert->rsa_tmp=rsa;
969 } 1071 }
970 if (rsa == NULL) 1072 if (rsa == NULL)
@@ -979,7 +1081,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
979 } 1081 }
980 else 1082 else
981#endif 1083#endif
982#ifndef NO_DH 1084#ifndef OPENSSL_NO_DH
983 if (type & SSL_kEDH) 1085 if (type & SSL_kEDH)
984 { 1086 {
985 dhp=cert->dh_tmp; 1087 dhp=cert->dh_tmp;
@@ -997,7 +1099,7 @@ static int ssl3_send_server_key_exchange(SSL *s)
997 if (s->s3->tmp.dh != NULL) 1099 if (s->s3->tmp.dh != NULL)
998 { 1100 {
999 DH_free(dh); 1101 DH_free(dh);
1000 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_INTERNAL_ERROR); 1102 SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);
1001 goto err; 1103 goto err;
1002 } 1104 }
1003 1105
@@ -1083,19 +1185,19 @@ static int ssl3_send_server_key_exchange(SSL *s)
1083 { 1185 {
1084 /* n is the length of the params, they start at &(d[4]) 1186 /* n is the length of the params, they start at &(d[4])
1085 * and p points to the space at the end. */ 1187 * and p points to the space at the end. */
1086#ifndef NO_RSA 1188#ifndef OPENSSL_NO_RSA
1087 if (pkey->type == EVP_PKEY_RSA) 1189 if (pkey->type == EVP_PKEY_RSA)
1088 { 1190 {
1089 q=md_buf; 1191 q=md_buf;
1090 j=0; 1192 j=0;
1091 for (num=2; num > 0; num--) 1193 for (num=2; num > 0; num--)
1092 { 1194 {
1093 EVP_DigestInit(&md_ctx,(num == 2) 1195 EVP_DigestInit_ex(&md_ctx,(num == 2)
1094 ?s->ctx->md5:s->ctx->sha1); 1196 ?s->ctx->md5:s->ctx->sha1, NULL);
1095 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1197 EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1096 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1198 EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1097 EVP_DigestUpdate(&md_ctx,&(d[4]),n); 1199 EVP_DigestUpdate(&md_ctx,&(d[4]),n);
1098 EVP_DigestFinal(&md_ctx,q, 1200 EVP_DigestFinal_ex(&md_ctx,q,
1099 (unsigned int *)&i); 1201 (unsigned int *)&i);
1100 q+=i; 1202 q+=i;
1101 j+=i; 1203 j+=i;
@@ -1111,11 +1213,11 @@ static int ssl3_send_server_key_exchange(SSL *s)
1111 } 1213 }
1112 else 1214 else
1113#endif 1215#endif
1114#if !defined(NO_DSA) 1216#if !defined(OPENSSL_NO_DSA)
1115 if (pkey->type == EVP_PKEY_DSA) 1217 if (pkey->type == EVP_PKEY_DSA)
1116 { 1218 {
1117 /* lets do DSS */ 1219 /* lets do DSS */
1118 EVP_SignInit(&md_ctx,EVP_dss1()); 1220 EVP_SignInit_ex(&md_ctx,EVP_dss1(), NULL);
1119 EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); 1221 EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
1120 EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); 1222 EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
1121 EVP_SignUpdate(&md_ctx,&(d[4]),n); 1223 EVP_SignUpdate(&md_ctx,&(d[4]),n);
@@ -1148,10 +1250,12 @@ static int ssl3_send_server_key_exchange(SSL *s)
1148 } 1250 }
1149 1251
1150 s->state = SSL3_ST_SW_KEY_EXCH_B; 1252 s->state = SSL3_ST_SW_KEY_EXCH_B;
1253 EVP_MD_CTX_cleanup(&md_ctx);
1151 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); 1254 return(ssl3_do_write(s,SSL3_RT_HANDSHAKE));
1152f_err: 1255f_err:
1153 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1256 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1154err: 1257err:
1258 EVP_MD_CTX_cleanup(&md_ctx);
1155 return(-1); 1259 return(-1);
1156 } 1260 }
1157 1261
@@ -1249,28 +1353,31 @@ static int ssl3_get_client_key_exchange(SSL *s)
1249 long n; 1353 long n;
1250 unsigned long l; 1354 unsigned long l;
1251 unsigned char *p; 1355 unsigned char *p;
1252#ifndef NO_RSA 1356#ifndef OPENSSL_NO_RSA
1253 RSA *rsa=NULL; 1357 RSA *rsa=NULL;
1254 EVP_PKEY *pkey=NULL; 1358 EVP_PKEY *pkey=NULL;
1255#endif 1359#endif
1256#ifndef NO_DH 1360#ifndef OPENSSL_NO_DH
1257 BIGNUM *pub=NULL; 1361 BIGNUM *pub=NULL;
1258 DH *dh_srvr; 1362 DH *dh_srvr;
1259#endif 1363#endif
1364#ifndef OPENSSL_NO_KRB5
1365 KSSL_ERR kssl_err;
1366#endif /* OPENSSL_NO_KRB5 */
1260 1367
1261 n=ssl3_get_message(s, 1368 n=ssl3_get_message(s,
1262 SSL3_ST_SR_KEY_EXCH_A, 1369 SSL3_ST_SR_KEY_EXCH_A,
1263 SSL3_ST_SR_KEY_EXCH_B, 1370 SSL3_ST_SR_KEY_EXCH_B,
1264 SSL3_MT_CLIENT_KEY_EXCHANGE, 1371 SSL3_MT_CLIENT_KEY_EXCHANGE,
1265 400, /* ???? */ 1372 2048, /* ??? */
1266 &ok); 1373 &ok);
1267 1374
1268 if (!ok) return((int)n); 1375 if (!ok) return((int)n);
1269 p=(unsigned char *)s->init_buf->data; 1376 p=(unsigned char *)s->init_msg;
1270 1377
1271 l=s->s3->tmp.new_cipher->algorithms; 1378 l=s->s3->tmp.new_cipher->algorithms;
1272 1379
1273#ifndef NO_RSA 1380#ifndef OPENSSL_NO_RSA
1274 if (l & SSL_kRSA) 1381 if (l & SSL_kRSA)
1275 { 1382 {
1276 /* FIX THIS UP EAY EAY EAY EAY */ 1383 /* FIX THIS UP EAY EAY EAY EAY */
@@ -1377,7 +1484,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
1377 } 1484 }
1378 else 1485 else
1379#endif 1486#endif
1380#ifndef NO_DH 1487#ifndef OPENSSL_NO_DH
1381 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) 1488 if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd))
1382 { 1489 {
1383 n2s(p,i); 1490 n2s(p,i);
@@ -1440,16 +1547,165 @@ static int ssl3_get_client_key_exchange(SSL *s)
1440 } 1547 }
1441 else 1548 else
1442#endif 1549#endif
1550#ifndef OPENSSL_NO_KRB5
1551 if (l & SSL_kKRB5)
1552 {
1553 krb5_error_code krb5rc;
1554 krb5_data enc_ticket;
1555 krb5_data authenticator;
1556 krb5_data enc_pms;
1557 KSSL_CTX *kssl_ctx = s->kssl_ctx;
1558 EVP_CIPHER_CTX ciph_ctx;
1559 EVP_CIPHER *enc = NULL;
1560 unsigned char iv[EVP_MAX_IV_LENGTH];
1561 unsigned char pms[SSL_MAX_MASTER_KEY_LENGTH
1562 + EVP_MAX_IV_LENGTH + 1];
1563 int padl, outl = sizeof(pms);
1564 krb5_timestamp authtime = 0;
1565 krb5_ticket_times ttimes;
1566
1567 EVP_CIPHER_CTX_init(&ciph_ctx);
1568
1569 if (!kssl_ctx) kssl_ctx = kssl_ctx_new();
1570
1571 n2s(p,i);
1572 enc_ticket.length = i;
1573 enc_ticket.data = (char *)p;
1574 p+=enc_ticket.length;
1575
1576 n2s(p,i);
1577 authenticator.length = i;
1578 authenticator.data = (char *)p;
1579 p+=authenticator.length;
1580
1581 n2s(p,i);
1582 enc_pms.length = i;
1583 enc_pms.data = (char *)p;
1584 p+=enc_pms.length;
1585
1586 if (n != enc_ticket.length + authenticator.length +
1587 enc_pms.length + 6)
1588 {
1589 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1590 SSL_R_DATA_LENGTH_TOO_LONG);
1591 goto err;
1592 }
1593
1594 if ((krb5rc = kssl_sget_tkt(kssl_ctx, &enc_ticket, &ttimes,
1595 &kssl_err)) != 0)
1596 {
1597#ifdef KSSL_DEBUG
1598 printf("kssl_sget_tkt rtn %d [%d]\n",
1599 krb5rc, kssl_err.reason);
1600 if (kssl_err.text)
1601 printf("kssl_err text= %s\n", kssl_err.text);
1602#endif /* KSSL_DEBUG */
1603 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1604 kssl_err.reason);
1605 goto err;
1606 }
1607
1608 /* Note: no authenticator is not considered an error,
1609 ** but will return authtime == 0.
1610 */
1611 if ((krb5rc = kssl_check_authent(kssl_ctx, &authenticator,
1612 &authtime, &kssl_err)) != 0)
1613 {
1614#ifdef KSSL_DEBUG
1615 printf("kssl_check_authent rtn %d [%d]\n",
1616 krb5rc, kssl_err.reason);
1617 if (kssl_err.text)
1618 printf("kssl_err text= %s\n", kssl_err.text);
1619#endif /* KSSL_DEBUG */
1620 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
1621 kssl_err.reason);
1622 goto err;
1623 }
1624
1625 if ((krb5rc = kssl_validate_times(authtime, &ttimes)) != 0)
1626 {
1627 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, krb5rc);
1628 goto err;
1629 }
1630
1631#ifdef KSSL_DEBUG
1632 kssl_ctx_show(kssl_ctx);
1633#endif /* KSSL_DEBUG */
1634
1635 enc = kssl_map_enc(kssl_ctx->enctype);
1636 if (enc == NULL)
1637 goto err;
1638
1639 memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */
1640
1641 if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv))
1642 {
1643 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1644 SSL_R_DECRYPTION_FAILED);
1645 goto err;
1646 }
1647 if (!EVP_DecryptUpdate(&ciph_ctx, pms,&outl,
1648 (unsigned char *)enc_pms.data, enc_pms.length))
1649 {
1650 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1651 SSL_R_DECRYPTION_FAILED);
1652 goto err;
1653 }
1654 if (outl > SSL_MAX_MASTER_KEY_LENGTH)
1655 {
1656 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1657 SSL_R_DATA_LENGTH_TOO_LONG);
1658 goto err;
1659 }
1660 if (!EVP_DecryptFinal_ex(&ciph_ctx,&(pms[outl]),&padl))
1661 {
1662 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1663 SSL_R_DECRYPTION_FAILED);
1664 goto err;
1665 }
1666 outl += padl;
1667 if (outl > SSL_MAX_MASTER_KEY_LENGTH)
1668 {
1669 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1670 SSL_R_DATA_LENGTH_TOO_LONG);
1671 goto err;
1672 }
1673 EVP_CIPHER_CTX_cleanup(&ciph_ctx);
1674
1675 s->session->master_key_length=
1676 s->method->ssl3_enc->generate_master_secret(s,
1677 s->session->master_key, pms, outl);
1678
1679 if (kssl_ctx->client_princ)
1680 {
1681 int len = strlen(kssl_ctx->client_princ);
1682 if ( len < SSL_MAX_KRB5_PRINCIPAL_LENGTH )
1683 {
1684 s->session->krb5_client_princ_len = len;
1685 memcpy(s->session->krb5_client_princ,kssl_ctx->client_princ,len);
1686 }
1687 }
1688
1689
1690 /* Was doing kssl_ctx_free() here,
1691 ** but it caused problems for apache.
1692 ** kssl_ctx = kssl_ctx_free(kssl_ctx);
1693 ** if (s->kssl_ctx) s->kssl_ctx = NULL;
1694 */
1695 }
1696 else
1697#endif /* OPENSSL_NO_KRB5 */
1443 { 1698 {
1444 al=SSL_AD_HANDSHAKE_FAILURE; 1699 al=SSL_AD_HANDSHAKE_FAILURE;
1445 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_UNKNOWN_CIPHER_TYPE); 1700 SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
1701 SSL_R_UNKNOWN_CIPHER_TYPE);
1446 goto f_err; 1702 goto f_err;
1447 } 1703 }
1448 1704
1449 return(1); 1705 return(1);
1450f_err: 1706f_err:
1451 ssl3_send_alert(s,SSL3_AL_FATAL,al); 1707 ssl3_send_alert(s,SSL3_AL_FATAL,al);
1452#if !defined(NO_DH) || !defined(NO_RSA) 1708#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA)
1453err: 1709err:
1454#endif 1710#endif
1455 return(-1); 1711 return(-1);
@@ -1520,7 +1776,7 @@ static int ssl3_get_cert_verify(SSL *s)
1520 } 1776 }
1521 1777
1522 /* we now have a signature that we need to verify */ 1778 /* we now have a signature that we need to verify */
1523 p=(unsigned char *)s->init_buf->data; 1779 p=(unsigned char *)s->init_msg;
1524 n2s(p,i); 1780 n2s(p,i);
1525 n-=2; 1781 n-=2;
1526 if (i > n) 1782 if (i > n)
@@ -1538,7 +1794,7 @@ static int ssl3_get_cert_verify(SSL *s)
1538 goto f_err; 1794 goto f_err;
1539 } 1795 }
1540 1796
1541#ifndef NO_RSA 1797#ifndef OPENSSL_NO_RSA
1542 if (pkey->type == EVP_PKEY_RSA) 1798 if (pkey->type == EVP_PKEY_RSA)
1543 { 1799 {
1544 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, 1800 i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
@@ -1559,7 +1815,7 @@ static int ssl3_get_cert_verify(SSL *s)
1559 } 1815 }
1560 else 1816 else
1561#endif 1817#endif
1562#ifndef NO_DSA 1818#ifndef OPENSSL_NO_DSA
1563 if (pkey->type == EVP_PKEY_DSA) 1819 if (pkey->type == EVP_PKEY_DSA)
1564 { 1820 {
1565 j=DSA_verify(pkey->save_type, 1821 j=DSA_verify(pkey->save_type,
@@ -1576,7 +1832,7 @@ static int ssl3_get_cert_verify(SSL *s)
1576 else 1832 else
1577#endif 1833#endif
1578 { 1834 {
1579 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_INTERNAL_ERROR); 1835 SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,ERR_R_INTERNAL_ERROR);
1580 al=SSL_AD_UNSUPPORTED_CERTIFICATE; 1836 al=SSL_AD_UNSUPPORTED_CERTIFICATE;
1581 goto f_err; 1837 goto f_err;
1582 } 1838 }
@@ -1605,11 +1861,7 @@ static int ssl3_get_client_certificate(SSL *s)
1605 SSL3_ST_SR_CERT_A, 1861 SSL3_ST_SR_CERT_A,
1606 SSL3_ST_SR_CERT_B, 1862 SSL3_ST_SR_CERT_B,
1607 -1, 1863 -1,
1608#if defined(MSDOS) && !defined(WIN32) 1864 s->max_cert_list,
1609 1024*30, /* 30k max cert list :-) */
1610#else
1611 1024*100, /* 100k max cert list :-) */
1612#endif
1613 &ok); 1865 &ok);
1614 1866
1615 if (!ok) return((int)n); 1867 if (!ok) return((int)n);
@@ -1640,7 +1892,7 @@ static int ssl3_get_client_certificate(SSL *s)
1640 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE); 1892 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE);
1641 goto f_err; 1893 goto f_err;
1642 } 1894 }
1643 d=p=(unsigned char *)s->init_buf->data; 1895 d=p=(unsigned char *)s->init_msg;
1644 1896
1645 if ((sk=sk_X509_new_null()) == NULL) 1897 if ((sk=sk_X509_new_null()) == NULL)
1646 { 1898 {
@@ -1760,9 +2012,13 @@ int ssl3_send_server_certificate(SSL *s)
1760 if (s->state == SSL3_ST_SW_CERT_A) 2012 if (s->state == SSL3_ST_SW_CERT_A)
1761 { 2013 {
1762 x=ssl_get_server_send_cert(s); 2014 x=ssl_get_server_send_cert(s);
1763 if (x == NULL) 2015 if (x == NULL &&
2016 /* VRS: allow null cert if auth == KRB5 */
2017 (s->s3->tmp.new_cipher->algorithms
2018 & (SSL_MKEY_MASK|SSL_AUTH_MASK))
2019 != (SSL_aKRB5|SSL_kKRB5))
1764 { 2020 {
1765 SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,SSL_R_INTERNAL_ERROR); 2021 SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,ERR_R_INTERNAL_ERROR);
1766 return(0); 2022 return(0);
1767 } 2023 }
1768 2024
diff --git a/src/lib/libssl/src/ssl/ssl-lib.com b/src/lib/libssl/src/ssl/ssl-lib.com
index 0a8581898c..313ff2565e 100644
--- a/src/lib/libssl/src/ssl/ssl-lib.com
+++ b/src/lib/libssl/src/ssl/ssl-lib.com
@@ -192,7 +192,7 @@ $ LIB_SSL = "s2_meth,s2_srvr,s2_clnt,s2_lib,s2_enc,s2_pkt,"+ -
192 "ssl_lib,ssl_err2,ssl_cert,ssl_sess,"+ - 192 "ssl_lib,ssl_err2,ssl_cert,ssl_sess,"+ -
193 "ssl_ciph,ssl_stat,ssl_rsa,"+ - 193 "ssl_ciph,ssl_stat,ssl_rsa,"+ -
194 "ssl_asn1,ssl_txt,ssl_algs,"+ - 194 "ssl_asn1,ssl_txt,ssl_algs,"+ -
195 "bio_ssl,ssl_err" 195 "bio_ssl,ssl_err,kssl"
196$! 196$!
197$! Tell The User That We Are Compiling The Library. 197$! Tell The User That We Are Compiling The Library.
198$! 198$!
@@ -647,6 +647,7 @@ $ ENDIF
647$! 647$!
648$! Check To See If P2 Is Blank. 648$! Check To See If P2 Is Blank.
649$! 649$!
650$ p2 = "NORSAREF"
650$ IF (P2.EQS."NORSAREF") 651$ IF (P2.EQS."NORSAREF")
651$ THEN 652$ THEN
652$! 653$!
@@ -896,31 +897,7 @@ $ ENDIF
896$! 897$!
897$! Set Up Initial CC Definitions, Possibly With User Ones 898$! Set Up Initial CC Definitions, Possibly With User Ones
898$! 899$!
899$ CCDEFS = "VMS=1,TCPIP_TYPE_''P5'" 900$ CCDEFS = "TCPIP_TYPE_''P5'"
900$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
901$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
902$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
903$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
904$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
905$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
906$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
907$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
908$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
909$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
910$ IF F$TRNLNM("OPENSSL_NO_DES")
911$ THEN
912$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
913$ ELSE
914$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
915$ ENDIF
916$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
917$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
918$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
919$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
920$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
921$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
922$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
923$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
924$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 901$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
925$ CCEXTRAFLAGS = "" 902$ CCEXTRAFLAGS = ""
926$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 903$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -953,7 +930,7 @@ $ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
953 THEN CC = "CC/DECC" 930 THEN CC = "CC/DECC"
954$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 931$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
955 "/NOLIST/PREFIX=ALL" + - 932 "/NOLIST/PREFIX=ALL" + -
956 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[.SOURCE])" + CCEXTRAFLAGS 933 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[-])" + CCEXTRAFLAGS
957$! 934$!
958$! Define The Linker Options File Name. 935$! Define The Linker Options File Name.
959$! 936$!
@@ -986,7 +963,7 @@ $ EXIT
986$ ENDIF 963$ ENDIF
987$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 964$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
988$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 965$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
989 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[.SOURCE])" + CCEXTRAFLAGS 966 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[-])" + CCEXTRAFLAGS
990$ CCDEFS = CCDEFS + ",""VAXC""" 967$ CCDEFS = CCDEFS + ",""VAXC"""
991$! 968$!
992$! Define <sys> As SYS$COMMON:[SYSLIB] 969$! Define <sys> As SYS$COMMON:[SYSLIB]
@@ -1018,7 +995,7 @@ $! Use GNU C...
1018$! 995$!
1019$ IF F$TYPE(GCC) .EQS. "" THEN GCC := GCC 996$ IF F$TYPE(GCC) .EQS. "" THEN GCC := GCC
1020$ CC = GCC+"/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 997$ CC = GCC+"/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1021 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[.SOURCE])" + CCEXTRAFLAGS 998 "/INCLUDE=(SYS$DISK:[-.CRYPTO],SYS$DISK:[-])" + CCEXTRAFLAGS
1022$! 999$!
1023$! Define The Linker Options File Name. 1000$! Define The Linker Options File Name.
1024$! 1001$!
@@ -1197,6 +1174,7 @@ $!
1197$! Save directory information 1174$! Save directory information
1198$! 1175$!
1199$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;" 1176$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1177$ __HERE = F$EDIT(__HERE,"UPCASE")
1200$ __TOP = __HERE - "SSL]" 1178$ __TOP = __HERE - "SSL]"
1201$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]" 1179$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1202$! 1180$!
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h
index 9de9e611ab..833f761690 100644
--- a/src/lib/libssl/src/ssl/ssl.h
+++ b/src/lib/libssl/src/ssl/ssl.h
@@ -55,20 +55,130 @@
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 */
111/* ====================================================================
112 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
113 *
114 * Redistribution and use in source and binary forms, with or without
115 * modification, are permitted provided that the following conditions
116 * are met:
117 *
118 * 1. Redistributions of source code must retain the above copyright
119 * notice, this list of conditions and the following disclaimer.
120 *
121 * 2. Redistributions in binary form must reproduce the above copyright
122 * notice, this list of conditions and the following disclaimer in
123 * the documentation and/or other materials provided with the
124 * distribution.
125 *
126 * 3. All advertising materials mentioning features or use of this
127 * software must display the following acknowledgment:
128 * "This product includes software developed by the OpenSSL Project
129 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
130 *
131 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
132 * endorse or promote products derived from this software without
133 * prior written permission. For written permission, please contact
134 * openssl-core@openssl.org.
135 *
136 * 5. Products derived from this software may not be called "OpenSSL"
137 * nor may "OpenSSL" appear in their names without prior written
138 * permission of the OpenSSL Project.
139 *
140 * 6. Redistributions of any form whatsoever must retain the following
141 * acknowledgment:
142 * "This product includes software developed by the OpenSSL Project
143 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
144 *
145 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
146 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
147 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
148 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
149 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
150 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
151 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
152 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
153 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
154 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
155 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
156 * OF THE POSSIBILITY OF SUCH DAMAGE.
157 * ====================================================================
158 *
159 * This product includes cryptographic software written by Eric Young
160 * (eay@cryptsoft.com). This product includes software written by Tim
161 * Hudson (tjh@cryptsoft.com).
162 *
163 */
58 164
59#ifndef HEADER_SSL_H 165#ifndef HEADER_SSL_H
60#define HEADER_SSL_H 166#define HEADER_SSL_H
61 167
62#ifndef NO_COMP 168#include <openssl/e_os2.h>
169
170#ifndef OPENSSL_NO_COMP
63#include <openssl/comp.h> 171#include <openssl/comp.h>
64#endif 172#endif
65#ifndef NO_BIO 173#ifndef OPENSSL_NO_BIO
66#include <openssl/bio.h> 174#include <openssl/bio.h>
67#endif 175#endif
68#ifndef NO_X509 176#ifndef OPENSSL_NO_X509
69#include <openssl/x509.h> 177#include <openssl/x509.h>
70#endif 178#endif
179#include <openssl/kssl.h>
71#include <openssl/safestack.h> 180#include <openssl/safestack.h>
181#include <openssl/symhacks.h>
72 182
73#ifdef __cplusplus 183#ifdef __cplusplus
74extern "C" { 184extern "C" {
@@ -92,6 +202,16 @@ extern "C" {
92#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 202#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5
93#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA 203#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA
94 204
205/* VRS Additional Kerberos5 entries
206 */
207#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
208#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
209#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
210#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5
211#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
212#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
213#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256
214
95#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 215#define SSL_MAX_SSL_SESSION_ID_LENGTH 32
96#define SSL_MAX_SID_CTX_LENGTH 32 216#define SSL_MAX_SID_CTX_LENGTH 32
97 217
@@ -112,6 +232,10 @@ extern "C" {
112#define SSL_TXT_eNULL "eNULL" 232#define SSL_TXT_eNULL "eNULL"
113#define SSL_TXT_NULL "NULL" 233#define SSL_TXT_NULL "NULL"
114 234
235#define SSL_TXT_kKRB5 "kKRB5"
236#define SSL_TXT_aKRB5 "aKRB5"
237#define SSL_TXT_KRB5 "KRB5"
238
115#define SSL_TXT_kRSA "kRSA" 239#define SSL_TXT_kRSA "kRSA"
116#define SSL_TXT_kDHr "kDHr" 240#define SSL_TXT_kDHr "kDHr"
117#define SSL_TXT_kDHd "kDHd" 241#define SSL_TXT_kDHd "kDHd"
@@ -129,6 +253,7 @@ extern "C" {
129#define SSL_TXT_RC4 "RC4" 253#define SSL_TXT_RC4 "RC4"
130#define SSL_TXT_RC2 "RC2" 254#define SSL_TXT_RC2 "RC2"
131#define SSL_TXT_IDEA "IDEA" 255#define SSL_TXT_IDEA "IDEA"
256#define SSL_TXT_AES "AESdraft" /* AES ciphersuites are not yet official (thus excluded from 'ALL') */
132#define SSL_TXT_MD5 "MD5" 257#define SSL_TXT_MD5 "MD5"
133#define SSL_TXT_SHA1 "SHA1" 258#define SSL_TXT_SHA1 "SHA1"
134#define SSL_TXT_SHA "SHA" 259#define SSL_TXT_SHA "SHA"
@@ -141,9 +266,10 @@ extern "C" {
141#define SSL_TXT_TLSV1 "TLSv1" 266#define SSL_TXT_TLSV1 "TLSv1"
142#define SSL_TXT_ALL "ALL" 267#define SSL_TXT_ALL "ALL"
143 268
144/* 'DEFAULT' at the start of the cipher list insert the following string 269/* The following cipher list is used by default.
145 * in addition to this being the default cipher string */ 270 * It also is substituted when an application-defined cipher list string
146#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+SSLv2:@STRENGTH" 271 * starts with 'DEFAULT'. */
272#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */
147 273
148/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ 274/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
149#define SSL_SENT_SHUTDOWN 1 275#define SSL_SENT_SHUTDOWN 1
@@ -164,8 +290,8 @@ extern "C" {
164extern "C" { 290extern "C" {
165#endif 291#endif
166 292
167#if (defined(NO_RSA) || defined(NO_MD5)) && !defined(NO_SSL2) 293#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)
168#define NO_SSL2 294#define OPENSSL_NO_SSL2
169#endif 295#endif
170 296
171#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 297#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
@@ -211,8 +337,8 @@ typedef struct ssl_method_st
211 int (*ssl_shutdown)(SSL *s); 337 int (*ssl_shutdown)(SSL *s);
212 int (*ssl_renegotiate)(SSL *s); 338 int (*ssl_renegotiate)(SSL *s);
213 int (*ssl_renegotiate_check)(SSL *s); 339 int (*ssl_renegotiate_check)(SSL *s);
214 long (*ssl_ctrl)(SSL *s,int cmd,long larg,char *parg); 340 long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg);
215 long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,char *parg); 341 long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg);
216 SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); 342 SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
217 int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); 343 int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr);
218 int (*ssl_pending)(SSL *s); 344 int (*ssl_pending)(SSL *s);
@@ -233,6 +359,7 @@ typedef struct ssl_method_st
233 * Cipher OCTET_STRING, -- the 3 byte cipher ID 359 * Cipher OCTET_STRING, -- the 3 byte cipher ID
234 * Session_ID OCTET_STRING, -- the Session ID 360 * Session_ID OCTET_STRING, -- the Session ID
235 * Master_key OCTET_STRING, -- the master key 361 * Master_key OCTET_STRING, -- the master key
362 * KRB5_principal OCTET_STRING -- optional Kerberos principal
236 * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument 363 * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument
237 * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time 364 * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
238 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds 365 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
@@ -263,6 +390,11 @@ typedef struct ssl_session_st
263 unsigned int sid_ctx_length; 390 unsigned int sid_ctx_length;
264 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; 391 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
265 392
393#ifndef OPENSSL_NO_KRB5
394 unsigned int krb5_client_princ_len;
395 unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];
396#endif /* OPENSSL_NO_KRB5 */
397
266 int not_resumable; 398 int not_resumable;
267 399
268 /* The cert is the certificate used to establish this connection */ 400 /* The cert is the certificate used to establish this connection */
@@ -306,21 +438,29 @@ typedef struct ssl_session_st
306#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L 438#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L
307#define SSL_OP_TLS_D5_BUG 0x00000100L 439#define SSL_OP_TLS_D5_BUG 0x00000100L
308#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L 440#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L
309#define SSL_OP_TLS_ROLLBACK_BUG 0x00000400L
310 441
311/* If set, always create a new key when using tmp_dh parameters */ 442/* If set, always create a new key when using tmp_dh parameters */
312#define SSL_OP_SINGLE_DH_USE 0x00100000L 443#define SSL_OP_SINGLE_DH_USE 0x00100000L
313/* Set to also use the tmp_rsa key when doing RSA operations. */ 444/* Set to always use the tmp_rsa key when doing RSA operations,
445 * even when this violates protocol specs */
314#define SSL_OP_EPHEMERAL_RSA 0x00200000L 446#define SSL_OP_EPHEMERAL_RSA 0x00200000L
447/* Set on servers to choose the cipher according to the server's
448 * preferences */
449#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L
450/* If set, a server will allow a client to issue a SSLv3.0 version number
451 * as latest version supported in the premaster secret, even when TLSv1.0
452 * (version 3.1) was announced in the client hello. Normally this is
453 * forbidden to prevent version rollback attacks. */
454#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L
455/* As server, disallow session resumption on renegotiation */
456#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x01000000L
315 457
316/* The next flag deliberately changes the ciphertest, this is a check 458/* The next flag deliberately changes the ciphertest, this is a check
317 * for the PKCS#1 attack */ 459 * for the PKCS#1 attack */
318#define SSL_OP_PKCS1_CHECK_1 0x08000000L 460#define SSL_OP_PKCS1_CHECK_1 0x08000000L
319#define SSL_OP_PKCS1_CHECK_2 0x10000000L 461#define SSL_OP_PKCS1_CHECK_2 0x10000000L
320#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L 462#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L
321/* SSL_OP_NON_EXPORT_FIRST looks utterly broken .. */ 463#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L
322#define SSL_OP_NON_EXPORT_FIRST 0x40000000L
323#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L
324#define SSL_OP_ALL 0x000FFFFFL 464#define SSL_OP_ALL 0x000FFFFFL
325 465
326#define SSL_OP_NO_SSLv2 0x01000000L 466#define SSL_OP_NO_SSLv2 0x01000000L
@@ -343,30 +483,60 @@ typedef struct ssl_session_st
343 * they cannot be used to clear bits. */ 483 * they cannot be used to clear bits. */
344 484
345#define SSL_CTX_set_options(ctx,op) \ 485#define SSL_CTX_set_options(ctx,op) \
346 SSL_CTX_ctrl(ctx,SSL_CTRL_OPTIONS,op,NULL) 486 SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
347#define SSL_CTX_get_options(ctx) \ 487#define SSL_CTX_get_options(ctx) \
348 SSL_CTX_ctrl(ctx,SSL_CTRL_OPTIONS,0,NULL) 488 SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)
349#define SSL_set_options(ssl,op) \ 489#define SSL_set_options(ssl,op) \
350 SSL_ctrl(ssl,SSL_CTRL_OPTIONS,op,NULL) 490 SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)
351#define SSL_get_options(ssl) \ 491#define SSL_get_options(ssl) \
352 SSL_ctrl(ssl,SSL_CTRL_OPTIONS,0,NULL) 492 SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)
353 493
354#define SSL_CTX_set_mode(ctx,op) \ 494#define SSL_CTX_set_mode(ctx,op) \
355 SSL_CTX_ctrl(ctx,SSL_CTRL_MODE,op,NULL) 495 SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
356#define SSL_CTX_get_mode(ctx) \ 496#define SSL_CTX_get_mode(ctx) \
357 SSL_CTX_ctrl(ctx,SSL_CTRL_MODE,0,NULL) 497 SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
358#define SSL_set_mode(ssl,op) \ 498#define SSL_set_mode(ssl,op) \
359 SSL_ctrl(ssl,SSL_CTRL_MODE,op,NULL) 499 SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
360#define SSL_get_mode(ssl) \ 500#define SSL_get_mode(ssl) \
361 SSL_ctrl(ssl,SSL_CTRL_MODE,0,NULL) 501 SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
502
503
504void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
505void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
506#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
507#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
508
509
510
511#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)
512#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */
513#else
514#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */
515#endif
362 516
363#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) 517#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)
364 518
519/* This callback type is used inside SSL_CTX, SSL, and in the functions that set
520 * them. It is used to override the generation of SSL/TLS session IDs in a
521 * server. Return value should be zero on an error, non-zero to proceed. Also,
522 * callbacks should themselves check if the id they generate is unique otherwise
523 * the SSL handshake will fail with an error - callbacks can do this using the
524 * 'ssl' value they're passed by;
525 * SSL_has_matching_session_id(ssl, id, *id_len)
526 * The length value passed in is set at the maximum size the session ID can be.
527 * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback
528 * can alter this length to be less if desired, but under SSLv2 session IDs are
529 * supposed to be fixed at 16 bytes so the id will be padded after the callback
530 * returns in this case. It is also an error for the callback to set the size to
531 * zero. */
532typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
533 unsigned int *id_len);
534
365typedef struct ssl_comp_st 535typedef struct ssl_comp_st
366 { 536 {
367 int id; 537 int id;
368 char *name; 538 char *name;
369#ifndef NO_COMP 539#ifndef OPENSSL_NO_COMP
370 COMP_METHOD *method; 540 COMP_METHOD *method;
371#else 541#else
372 char *method; 542 char *method;
@@ -378,8 +548,6 @@ DECLARE_STACK_OF(SSL_COMP)
378struct ssl_ctx_st 548struct ssl_ctx_st
379 { 549 {
380 SSL_METHOD *method; 550 SSL_METHOD *method;
381 unsigned long options;
382 unsigned long mode;
383 551
384 STACK_OF(SSL_CIPHER) *cipher_list; 552 STACK_OF(SSL_CIPHER) *cipher_list;
385 /* same as above but sorted for lookup */ 553 /* same as above but sorted for lookup */
@@ -417,6 +585,7 @@ struct ssl_ctx_st
417 void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); 585 void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess);
418 SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, 586 SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
419 unsigned char *data,int len,int *copy); 587 unsigned char *data,int len,int *copy);
588
420 struct 589 struct
421 { 590 {
422 int sess_connect; /* SSL new conn - started */ 591 int sess_connect; /* SSL new conn - started */
@@ -439,37 +608,20 @@ struct ssl_ctx_st
439 608
440 int references; 609 int references;
441 610
442/**/ void (*info_callback)();
443
444 /* if defined, these override the X509_verify_cert() calls */ 611 /* if defined, these override the X509_verify_cert() calls */
445/**/ int (*app_verify_callback)(); 612 int (*app_verify_callback)(X509_STORE_CTX *, void *);
446/**/ char *app_verify_arg; /* never used; should be void * */ 613 void *app_verify_arg;
447 614 /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored
448 /* default values to use in SSL structures */ 615 * ('app_verify_callback' was called with just one argument) */
449/**/ struct cert_st /* CERT */ *cert;
450/**/ int read_ahead;
451/**/ int verify_mode;
452/**/ int verify_depth;
453/**/ unsigned int sid_ctx_length;
454/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
455/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx);
456
457 int purpose; /* Purpose setting */
458 int trust; /* Trust setting */
459 616
460 /* Default password callback. */ 617 /* Default password callback. */
461/**/ pem_password_cb *default_passwd_callback; 618 pem_password_cb *default_passwd_callback;
462 619
463 /* Default password callback user data. */ 620 /* Default password callback user data. */
464/**/ void *default_passwd_callback_userdata; 621 void *default_passwd_callback_userdata;
465 622
466 /* get client cert callback */ 623 /* get client cert callback */
467/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */); 624 int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
468
469 /* what we put in client cert requests */
470 STACK_OF(X509_NAME) *client_CA;
471
472/**/ int quiet_shutdown;
473 625
474 CRYPTO_EX_DATA ex_data; 626 CRYPTO_EX_DATA ex_data;
475 627
@@ -478,7 +630,43 @@ struct ssl_ctx_st
478 const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ 630 const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */
479 631
480 STACK_OF(X509) *extra_certs; 632 STACK_OF(X509) *extra_certs;
481 STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ 633 STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
634
635
636 /* Default values used when no per-SSL value is defined follow */
637
638 void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */
639
640 /* what we put in client cert requests */
641 STACK_OF(X509_NAME) *client_CA;
642
643
644 /* Default values to use in SSL structures follow (these are copied by SSL_new) */
645
646 unsigned long options;
647 unsigned long mode;
648 long max_cert_list;
649
650 struct cert_st /* CERT */ *cert;
651 int read_ahead;
652
653 /* callback that allows applications to peek at protocol messages */
654 void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
655 void *msg_callback_arg;
656
657 int verify_mode;
658 int verify_depth;
659 unsigned int sid_ctx_length;
660 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
661 int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */
662
663 /* Default generate session ID callback. */
664 GEN_SESSION_CB generate_session_id;
665
666 int purpose; /* Purpose setting */
667 int trust; /* Trust setting */
668
669 int quiet_shutdown;
482 }; 670 };
483 671
484#define SSL_SESS_CACHE_OFF 0x0000 672#define SSL_SESS_CACHE_OFF 0x0000
@@ -553,7 +741,7 @@ struct ssl_st
553 * same. This is so data can be read and written to different 741 * same. This is so data can be read and written to different
554 * handlers */ 742 * handlers */
555 743
556#ifndef NO_BIO 744#ifndef OPENSSL_NO_BIO
557 BIO *rbio; /* used by SSL_read */ 745 BIO *rbio; /* used by SSL_read */
558 BIO *wbio; /* used by SSL_write */ 746 BIO *wbio; /* used by SSL_write */
559 BIO *bbio; /* used during session-id reuse to concatenate 747 BIO *bbio; /* used during session-id reuse to concatenate
@@ -583,7 +771,12 @@ struct ssl_st
583 771
584 int server; /* are we the server side? - mostly used by SSL_clear*/ 772 int server; /* are we the server side? - mostly used by SSL_clear*/
585 773
586 int new_session;/* 1 if we are to use a new session */ 774 int new_session;/* 1 if we are to use a new session.
775 * 2 if we are a server and are inside a handshake
776 * (i.e. not just sending a HelloRequest)
777 * NB: For servers, the 'new' session may actually be a previously
778 * cached session or even the previous session unless
779 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
587 int quiet_shutdown;/* don't send shutdown packets */ 780 int quiet_shutdown;/* don't send shutdown packets */
588 int shutdown; /* we have shut things down, 0x01 sent, 0x02 781 int shutdown; /* we have shut things down, 0x01 sent, 0x02
589 * for received */ 782 * for received */
@@ -591,6 +784,7 @@ struct ssl_st
591 int rstate; /* where we are when reading */ 784 int rstate; /* where we are when reading */
592 785
593 BUF_MEM *init_buf; /* buffer used during init */ 786 BUF_MEM *init_buf; /* buffer used during init */
787 void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */
594 int init_num; /* amount read/written */ 788 int init_num; /* amount read/written */
595 int init_off; /* amount read/written */ 789 int init_off; /* amount read/written */
596 790
@@ -603,6 +797,11 @@ struct ssl_st
603 797
604 int read_ahead; /* Read as many input bytes as possible 798 int read_ahead; /* Read as many input bytes as possible
605 * (for non-blocking reads) */ 799 * (for non-blocking reads) */
800
801 /* callback that allows applications to peek at protocol messages */
802 void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
803 void *msg_callback_arg;
804
606 int hit; /* reusing a previous session */ 805 int hit; /* reusing a previous session */
607 806
608 int purpose; /* Purpose setting */ 807 int purpose; /* Purpose setting */
@@ -617,7 +816,7 @@ struct ssl_st
617 816
618 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ 817 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
619 const EVP_MD *read_hash; /* used for mac generation */ 818 const EVP_MD *read_hash; /* used for mac generation */
620#ifndef NO_COMP 819#ifndef OPENSSL_NO_COMP
621 COMP_CTX *expand; /* uncompress */ 820 COMP_CTX *expand; /* uncompress */
622#else 821#else
623 char *expand; 822 char *expand;
@@ -625,7 +824,7 @@ struct ssl_st
625 824
626 EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ 825 EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
627 const EVP_MD *write_hash; /* used for mac generation */ 826 const EVP_MD *write_hash; /* used for mac generation */
628#ifndef NO_COMP 827#ifndef OPENSSL_NO_COMP
629 COMP_CTX *compress; /* compression */ 828 COMP_CTX *compress; /* compression */
630#else 829#else
631 char *compress; 830 char *compress;
@@ -645,16 +844,24 @@ struct ssl_st
645 /* This can also be in the session once a session is established */ 844 /* This can also be in the session once a session is established */
646 SSL_SESSION *session; 845 SSL_SESSION *session;
647 846
847 /* Default generate session ID callback. */
848 GEN_SESSION_CB generate_session_id;
849
648 /* Used in SSL2 and SSL3 */ 850 /* Used in SSL2 and SSL3 */
649 int verify_mode; /* 0 don't care about verify failure. 851 int verify_mode; /* 0 don't care about verify failure.
650 * 1 fail if verify fails */ 852 * 1 fail if verify fails */
651 int verify_depth; 853 int verify_depth;
652 int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ 854 int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */
653 void (*info_callback)(); /* optional informational callback */ 855
856 void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */
654 857
655 int error; /* error bytes to be written */ 858 int error; /* error bytes to be written */
656 int error_code; /* actual code */ 859 int error_code; /* actual code */
657 860
861#ifndef OPENSSL_NO_KRB5
862 KSSL_CTX *kssl_ctx; /* Kerberos 5 context */
863#endif /* OPENSSL_NO_KRB5 */
864
658 SSL_CTX *ctx; 865 SSL_CTX *ctx;
659 /* set this flag to 1 and a sleep(1) is put into all SSL_read() 866 /* set this flag to 1 and a sleep(1) is put into all SSL_read()
660 * and SSL_write() calls, good for nbio debuging :-) */ 867 * and SSL_write() calls, good for nbio debuging :-) */
@@ -670,6 +877,7 @@ struct ssl_st
670 int references; 877 int references;
671 unsigned long options; /* protocol behaviour */ 878 unsigned long options; /* protocol behaviour */
672 unsigned long mode; /* API behaviour */ 879 unsigned long mode; /* API behaviour */
880 long max_cert_list;
673 int first_packet; 881 int first_packet;
674 int client_version; /* what was passed, used for 882 int client_version; /* what was passed, used for
675 * SSLv3/TLS rollback check */ 883 * SSLv3/TLS rollback check */
@@ -831,13 +1039,14 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
831#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ 1039#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */
832#define SSL_ERROR_ZERO_RETURN 6 1040#define SSL_ERROR_ZERO_RETURN 6
833#define SSL_ERROR_WANT_CONNECT 7 1041#define SSL_ERROR_WANT_CONNECT 7
1042#define SSL_ERROR_WANT_ACCEPT 8
834 1043
835#define SSL_CTRL_NEED_TMP_RSA 1 1044#define SSL_CTRL_NEED_TMP_RSA 1
836#define SSL_CTRL_SET_TMP_RSA 2 1045#define SSL_CTRL_SET_TMP_RSA 2
837#define SSL_CTRL_SET_TMP_DH 3 1046#define SSL_CTRL_SET_TMP_DH 3
838#define SSL_CTRL_SET_TMP_RSA_CB 4 1047#define SSL_CTRL_SET_TMP_RSA_CB 4
839#define SSL_CTRL_SET_TMP_DH_CB 5 1048#define SSL_CTRL_SET_TMP_DH_CB 5
840/* Add these ones */ 1049
841#define SSL_CTRL_GET_SESSION_REUSED 6 1050#define SSL_CTRL_GET_SESSION_REUSED 6
842#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7 1051#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7
843#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8 1052#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8
@@ -846,6 +1055,9 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
846#define SSL_CTRL_GET_FLAGS 11 1055#define SSL_CTRL_GET_FLAGS 11
847#define SSL_CTRL_EXTRA_CHAIN_CERT 12 1056#define SSL_CTRL_EXTRA_CHAIN_CERT 12
848 1057
1058#define SSL_CTRL_SET_MSG_CALLBACK 13
1059#define SSL_CTRL_SET_MSG_CALLBACK_ARG 14
1060
849/* Stats */ 1061/* Stats */
850#define SSL_CTRL_SESS_NUMBER 20 1062#define SSL_CTRL_SESS_NUMBER 20
851#define SSL_CTRL_SESS_CONNECT 21 1063#define SSL_CTRL_SESS_CONNECT 21
@@ -860,7 +1072,7 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
860#define SSL_CTRL_SESS_TIMEOUTS 30 1072#define SSL_CTRL_SESS_TIMEOUTS 30
861#define SSL_CTRL_SESS_CACHE_FULL 31 1073#define SSL_CTRL_SESS_CACHE_FULL 31
862#define SSL_CTRL_OPTIONS 32 1074#define SSL_CTRL_OPTIONS 32
863#define SSL_CTRL_MODE 33 1075#define SSL_CTRL_MODE 33
864 1076
865#define SSL_CTRL_GET_READ_AHEAD 40 1077#define SSL_CTRL_GET_READ_AHEAD 40
866#define SSL_CTRL_SET_READ_AHEAD 41 1078#define SSL_CTRL_SET_READ_AHEAD 41
@@ -869,6 +1081,9 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
869#define SSL_CTRL_SET_SESS_CACHE_MODE 44 1081#define SSL_CTRL_SET_SESS_CACHE_MODE 44
870#define SSL_CTRL_GET_SESS_CACHE_MODE 45 1082#define SSL_CTRL_GET_SESS_CACHE_MODE 45
871 1083
1084#define SSL_CTRL_GET_MAX_CERT_LIST 50
1085#define SSL_CTRL_SET_MAX_CERT_LIST 51
1086
872#define SSL_session_reused(ssl) \ 1087#define SSL_session_reused(ssl) \
873 SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) 1088 SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)
874#define SSL_num_renegotiations(ssl) \ 1089#define SSL_num_renegotiations(ssl) \
@@ -895,23 +1110,7 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
895#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ 1110#define SSL_CTX_add_extra_chain_cert(ctx,x509) \
896 SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) 1111 SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
897 1112
898/* VMS uses only 31 characters for symbols. */ 1113#ifndef OPENSSL_NO_BIO
899#ifdef VMS
900#undef SSL_CTX_set_cert_verify_callback
901#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
902#undef SSL_CTX_use_certificate_chain_file
903#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
904#undef SSL_CTX_set_default_verify_paths
905#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
906#undef SSL_get_ex_data_X509_STORE_CTX_idx
907#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_data_X509_STOR_CTX_i
908#undef SSL_add_file_cert_subjects_to_stack
909#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_sub_to_stack
910#undef SSL_add_dir_cert_subjects_to_stack
911#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_sub_to_stack
912#endif
913
914#ifndef NO_BIO
915BIO_METHOD *BIO_f_ssl(void); 1114BIO_METHOD *BIO_f_ssl(void);
916BIO *BIO_new_ssl(SSL_CTX *ctx,int client); 1115BIO *BIO_new_ssl(SSL_CTX *ctx,int client);
917BIO *BIO_new_ssl_connect(SSL_CTX *ctx); 1116BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
@@ -939,16 +1138,18 @@ char * SSL_CIPHER_get_version(SSL_CIPHER *c);
939const char * SSL_CIPHER_get_name(SSL_CIPHER *c); 1138const char * SSL_CIPHER_get_name(SSL_CIPHER *c);
940 1139
941int SSL_get_fd(SSL *s); 1140int SSL_get_fd(SSL *s);
1141int SSL_get_rfd(SSL *s);
1142int SSL_get_wfd(SSL *s);
942const char * SSL_get_cipher_list(SSL *s,int n); 1143const char * SSL_get_cipher_list(SSL *s,int n);
943char * SSL_get_shared_ciphers(SSL *s, char *buf, int len); 1144char * SSL_get_shared_ciphers(SSL *s, char *buf, int len);
944int SSL_get_read_ahead(SSL * s); 1145int SSL_get_read_ahead(SSL * s);
945int SSL_pending(SSL *s); 1146int SSL_pending(SSL *s);
946#ifndef NO_SOCK 1147#ifndef OPENSSL_NO_SOCK
947int SSL_set_fd(SSL *s, int fd); 1148int SSL_set_fd(SSL *s, int fd);
948int SSL_set_rfd(SSL *s, int fd); 1149int SSL_set_rfd(SSL *s, int fd);
949int SSL_set_wfd(SSL *s, int fd); 1150int SSL_set_wfd(SSL *s, int fd);
950#endif 1151#endif
951#ifndef NO_BIO 1152#ifndef OPENSSL_NO_BIO
952void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); 1153void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);
953BIO * SSL_get_rbio(SSL *s); 1154BIO * SSL_get_rbio(SSL *s);
954BIO * SSL_get_wbio(SSL *s); 1155BIO * SSL_get_wbio(SSL *s);
@@ -961,7 +1162,7 @@ int (*SSL_get_verify_callback(SSL *s))(int,X509_STORE_CTX *);
961void SSL_set_verify(SSL *s, int mode, 1162void SSL_set_verify(SSL *s, int mode,
962 int (*callback)(int ok,X509_STORE_CTX *ctx)); 1163 int (*callback)(int ok,X509_STORE_CTX *ctx));
963void SSL_set_verify_depth(SSL *s, int depth); 1164void SSL_set_verify_depth(SSL *s, int depth);
964#ifndef NO_RSA 1165#ifndef OPENSSL_NO_RSA
965int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); 1166int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
966#endif 1167#endif
967int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); 1168int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
@@ -970,7 +1171,7 @@ int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len);
970int SSL_use_certificate(SSL *ssl, X509 *x); 1171int SSL_use_certificate(SSL *ssl, X509 *x);
971int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len); 1172int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len);
972 1173
973#ifndef NO_STDIO 1174#ifndef OPENSSL_NO_STDIO
974int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); 1175int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
975int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); 1176int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
976int SSL_use_certificate_file(SSL *ssl, const char *file, int type); 1177int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
@@ -981,16 +1182,22 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM t
981STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); 1182STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
982int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1183int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
983 const char *file); 1184 const char *file);
1185#ifndef OPENSSL_SYS_WIN32
1186#ifndef OPENSSL_SYS_VMS
1187#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */
984int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1188int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
985 const char *dir); 1189 const char *dir);
986#endif 1190#endif
1191#endif
1192#endif
1193
1194#endif
987 1195
988void ERR_load_SSL_strings(void );
989void SSL_load_error_strings(void ); 1196void SSL_load_error_strings(void );
990char * SSL_state_string(SSL *s); 1197const char *SSL_state_string(const SSL *s);
991char * SSL_rstate_string(SSL *s); 1198const char *SSL_rstate_string(const SSL *s);
992char * SSL_state_string_long(SSL *s); 1199const char *SSL_state_string_long(const SSL *s);
993char * SSL_rstate_string_long(SSL *s); 1200const char *SSL_rstate_string_long(const SSL *s);
994long SSL_SESSION_get_time(SSL_SESSION *s); 1201long SSL_SESSION_get_time(SSL_SESSION *s);
995long SSL_SESSION_set_time(SSL_SESSION *s, long t); 1202long SSL_SESSION_set_time(SSL_SESSION *s, long t);
996long SSL_SESSION_get_timeout(SSL_SESSION *s); 1203long SSL_SESSION_get_timeout(SSL_SESSION *s);
@@ -1000,10 +1207,10 @@ void SSL_copy_session_id(SSL *to,SSL *from);
1000SSL_SESSION *SSL_SESSION_new(void); 1207SSL_SESSION *SSL_SESSION_new(void);
1001unsigned long SSL_SESSION_hash(SSL_SESSION *a); 1208unsigned long SSL_SESSION_hash(SSL_SESSION *a);
1002int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b); 1209int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b);
1003#ifndef NO_FP_API 1210#ifndef OPENSSL_NO_FP_API
1004int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses); 1211int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses);
1005#endif 1212#endif
1006#ifndef NO_BIO 1213#ifndef OPENSSL_NO_BIO
1007int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses); 1214int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses);
1008#endif 1215#endif
1009void SSL_SESSION_free(SSL_SESSION *ses); 1216void SSL_SESSION_free(SSL_SESSION *ses);
@@ -1011,6 +1218,10 @@ int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp);
1011int SSL_set_session(SSL *to, SSL_SESSION *session); 1218int SSL_set_session(SSL *to, SSL_SESSION *session);
1012int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); 1219int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);
1013int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); 1220int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c);
1221int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);
1222int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);
1223int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
1224 unsigned int id_len);
1014SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length); 1225SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length);
1015 1226
1016#ifdef HEADER_X509_H 1227#ifdef HEADER_X509_H
@@ -1019,18 +1230,14 @@ X509 * SSL_get_peer_certificate(SSL *s);
1019 1230
1020STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s); 1231STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s);
1021 1232
1022#ifdef VMS
1023#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
1024#endif
1025
1026int SSL_CTX_get_verify_mode(SSL_CTX *ctx); 1233int SSL_CTX_get_verify_mode(SSL_CTX *ctx);
1027int SSL_CTX_get_verify_depth(SSL_CTX *ctx); 1234int SSL_CTX_get_verify_depth(SSL_CTX *ctx);
1028int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *); 1235int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *);
1029void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, 1236void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,
1030 int (*callback)(int, X509_STORE_CTX *)); 1237 int (*callback)(int, X509_STORE_CTX *));
1031void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); 1238void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
1032void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(),char *arg); 1239void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg);
1033#ifndef NO_RSA 1240#ifndef OPENSSL_NO_RSA
1034int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); 1241int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
1035#endif 1242#endif
1036int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); 1243int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len);
@@ -1064,9 +1271,9 @@ int SSL_connect(SSL *ssl);
1064int SSL_read(SSL *ssl,void *buf,int num); 1271int SSL_read(SSL *ssl,void *buf,int num);
1065int SSL_peek(SSL *ssl,void *buf,int num); 1272int SSL_peek(SSL *ssl,void *buf,int num);
1066int SSL_write(SSL *ssl,const void *buf,int num); 1273int SSL_write(SSL *ssl,const void *buf,int num);
1067long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); 1274long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
1068long SSL_callback_ctrl(SSL *, int, void (*)()); 1275long SSL_callback_ctrl(SSL *, int, void (*)());
1069long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); 1276long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg);
1070long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)()); 1277long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)());
1071 1278
1072int SSL_get_error(SSL *s,int ret_code); 1279int SSL_get_error(SSL *s,int ret_code);
@@ -1095,14 +1302,15 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s);
1095 1302
1096int SSL_do_handshake(SSL *s); 1303int SSL_do_handshake(SSL *s);
1097int SSL_renegotiate(SSL *s); 1304int SSL_renegotiate(SSL *s);
1305int SSL_renegotiate_pending(SSL *s);
1098int SSL_shutdown(SSL *s); 1306int SSL_shutdown(SSL *s);
1099 1307
1100SSL_METHOD *SSL_get_ssl_method(SSL *s); 1308SSL_METHOD *SSL_get_ssl_method(SSL *s);
1101int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); 1309int SSL_set_ssl_method(SSL *s,SSL_METHOD *method);
1102char *SSL_alert_type_string_long(int value); 1310const char *SSL_alert_type_string_long(int value);
1103char *SSL_alert_type_string(int value); 1311const char *SSL_alert_type_string(int value);
1104char *SSL_alert_desc_string_long(int value); 1312const char *SSL_alert_desc_string_long(int value);
1105char *SSL_alert_desc_string(int value); 1313const char *SSL_alert_desc_string(int value);
1106 1314
1107void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list); 1315void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list);
1108void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list); 1316void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list);
@@ -1140,8 +1348,9 @@ int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1140SSL_SESSION *SSL_get_session(SSL *ssl); 1348SSL_SESSION *SSL_get_session(SSL *ssl);
1141SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ 1349SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
1142SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); 1350SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
1143void SSL_set_info_callback(SSL *ssl,void (*cb)()); 1351void SSL_set_info_callback(SSL *ssl,
1144void (*SSL_get_info_callback(SSL *ssl))(); 1352 void (*cb)(const SSL *ssl,int type,int val));
1353void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val);
1145int SSL_state(SSL *ssl); 1354int SSL_state(SSL *ssl);
1146 1355
1147void SSL_set_verify_result(SSL *ssl,long v); 1356void SSL_set_verify_result(SSL *ssl,long v);
@@ -1179,9 +1388,17 @@ int SSL_get_ex_data_X509_STORE_CTX_idx(void );
1179 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) 1388 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)
1180#define SSL_CTX_set_read_ahead(ctx,m) \ 1389#define SSL_CTX_set_read_ahead(ctx,m) \
1181 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) 1390 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)
1391#define SSL_CTX_get_max_cert_list(ctx) \
1392 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
1393#define SSL_CTX_set_max_cert_list(ctx,m) \
1394 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
1395#define SSL_get_max_cert_list(ssl) \
1396 SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
1397#define SSL_set_max_cert_list(ssl,m) \
1398 SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
1182 1399
1183 /* NB: the keylength is only applicable when is_export is true */ 1400 /* NB: the keylength is only applicable when is_export is true */
1184#ifndef NO_RSA 1401#ifndef OPENSSL_NO_RSA
1185void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, 1402void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
1186 RSA *(*cb)(SSL *ssl,int is_export, 1403 RSA *(*cb)(SSL *ssl,int is_export,
1187 int keylength)); 1404 int keylength));
@@ -1190,7 +1407,7 @@ void SSL_set_tmp_rsa_callback(SSL *ssl,
1190 RSA *(*cb)(SSL *ssl,int is_export, 1407 RSA *(*cb)(SSL *ssl,int is_export,
1191 int keylength)); 1408 int keylength));
1192#endif 1409#endif
1193#ifndef NO_DH 1410#ifndef OPENSSL_NO_DH
1194void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, 1411void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
1195 DH *(*dh)(SSL *ssl,int is_export, 1412 DH *(*dh)(SSL *ssl,int is_export,
1196 int keylength)); 1413 int keylength));
@@ -1199,7 +1416,7 @@ void SSL_set_tmp_dh_callback(SSL *ssl,
1199 int keylength)); 1416 int keylength));
1200#endif 1417#endif
1201 1418
1202#ifndef NO_COMP 1419#ifndef OPENSSL_NO_COMP
1203int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); 1420int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm);
1204#else 1421#else
1205int SSL_COMP_add_compression_method(int id,char *cm); 1422int SSL_COMP_add_compression_method(int id,char *cm);
@@ -1254,6 +1471,7 @@ void ERR_load_SSL_strings(void);
1254#define SSL_F_SSL3_CTRL 213 1471#define SSL_F_SSL3_CTRL 213
1255#define SSL_F_SSL3_CTX_CTRL 133 1472#define SSL_F_SSL3_CTX_CTRL 133
1256#define SSL_F_SSL3_ENC 134 1473#define SSL_F_SSL3_ENC 134
1474#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238
1257#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 1475#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135
1258#define SSL_F_SSL3_GET_CERT_VERIFY 136 1476#define SSL_F_SSL3_GET_CERT_VERIFY 136
1259#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 1477#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137
@@ -1403,6 +1621,7 @@ void ERR_load_SSL_strings(void);
1403#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 1621#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145
1404#define SSL_R_DATA_LENGTH_TOO_LONG 146 1622#define SSL_R_DATA_LENGTH_TOO_LONG 146
1405#define SSL_R_DECRYPTION_FAILED 147 1623#define SSL_R_DECRYPTION_FAILED 147
1624#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 1109
1406#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 1625#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148
1407#define SSL_R_DIGEST_CHECK_FAILED 149 1626#define SSL_R_DIGEST_CHECK_FAILED 149
1408#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 1627#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150
@@ -1413,15 +1632,27 @@ void ERR_load_SSL_strings(void);
1413#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 1632#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154
1414#define SSL_R_HTTPS_PROXY_REQUEST 155 1633#define SSL_R_HTTPS_PROXY_REQUEST 155
1415#define SSL_R_HTTP_REQUEST 156 1634#define SSL_R_HTTP_REQUEST 156
1416#define SSL_R_INTERNAL_ERROR 157 1635#define SSL_R_ILLEGAL_PADDING 1110
1417#define SSL_R_INVALID_CHALLENGE_LENGTH 158 1636#define SSL_R_INVALID_CHALLENGE_LENGTH 158
1418#define SSL_R_INVALID_COMMAND 280 1637#define SSL_R_INVALID_COMMAND 280
1419#define SSL_R_INVALID_PURPOSE 278 1638#define SSL_R_INVALID_PURPOSE 278
1420#define SSL_R_INVALID_TRUST 279 1639#define SSL_R_INVALID_TRUST 279
1640#define SSL_R_KRB5 1104
1641#define SSL_R_KRB5_C_CC_PRINC 1094
1642#define SSL_R_KRB5_C_GET_CRED 1095
1643#define SSL_R_KRB5_C_INIT 1096
1644#define SSL_R_KRB5_C_MK_REQ 1097
1645#define SSL_R_KRB5_S_BAD_TICKET 1098
1646#define SSL_R_KRB5_S_INIT 1099
1647#define SSL_R_KRB5_S_RD_REQ 1108
1648#define SSL_R_KRB5_S_TKT_EXPIRED 1105
1649#define SSL_R_KRB5_S_TKT_NYV 1106
1650#define SSL_R_KRB5_S_TKT_SKEW 1107
1421#define SSL_R_LENGTH_MISMATCH 159 1651#define SSL_R_LENGTH_MISMATCH 159
1422#define SSL_R_LENGTH_TOO_SHORT 160 1652#define SSL_R_LENGTH_TOO_SHORT 160
1423#define SSL_R_LIBRARY_BUG 274 1653#define SSL_R_LIBRARY_BUG 274
1424#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 1654#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161
1655#define SSL_R_MESSAGE_TOO_LONG 1111
1425#define SSL_R_MISSING_DH_DSA_CERT 162 1656#define SSL_R_MISSING_DH_DSA_CERT 162
1426#define SSL_R_MISSING_DH_KEY 163 1657#define SSL_R_MISSING_DH_KEY 163
1427#define SSL_R_MISSING_DH_RSA_CERT 164 1658#define SSL_R_MISSING_DH_RSA_CERT 164
@@ -1505,7 +1736,10 @@ void ERR_load_SSL_strings(void);
1505#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 1736#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228
1506#define SSL_R_SSL_HANDSHAKE_FAILURE 229 1737#define SSL_R_SSL_HANDSHAKE_FAILURE 229
1507#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 1738#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230
1739#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 1102
1740#define SSL_R_SSL_SESSION_ID_CONFLICT 1103
1508#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 1741#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273
1742#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 1101
1509#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 1743#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231
1510#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 1744#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
1511#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 1745#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
diff --git a/src/lib/libssl/src/ssl/ssl2.h b/src/lib/libssl/src/ssl/ssl2.h
index f8b56afb6b..99a52ea0dd 100644
--- a/src/lib/libssl/src/ssl/ssl2.h
+++ b/src/lib/libssl/src/ssl/ssl2.h
@@ -133,7 +133,7 @@ extern "C" {
133 133
134/* Upper/Lower Bounds */ 134/* Upper/Lower Bounds */
135#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 135#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256
136#ifdef MPE 136#ifdef OPENSSL_SYS_MPE
137#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u 137#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u
138#else 138#else
139#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ 139#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */
@@ -189,7 +189,6 @@ typedef struct ssl2_state_st
189 unsigned char *ract_data; 189 unsigned char *ract_data;
190 unsigned char *wact_data; 190 unsigned char *wact_data;
191 unsigned char *mac_data; 191 unsigned char *mac_data;
192 unsigned char *pad_data;
193 192
194 unsigned char *read_key; 193 unsigned char *read_key;
195 unsigned char *write_key; 194 unsigned char *write_key;
@@ -209,11 +208,11 @@ typedef struct ssl2_state_st
209 unsigned int conn_id_length; 208 unsigned int conn_id_length;
210 unsigned int cert_type; 209 unsigned int cert_type;
211 unsigned int cert_length; 210 unsigned int cert_length;
212 int csl; 211 unsigned int csl;
213 int clear; 212 unsigned int clear;
214 unsigned int enc; 213 unsigned int enc;
215 unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; 214 unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
216 int cipher_spec_length; 215 unsigned int cipher_spec_length;
217 unsigned int session_id_length; 216 unsigned int session_id_length;
218 unsigned int clen; 217 unsigned int clen;
219 unsigned int rlen; 218 unsigned int rlen;
diff --git a/src/lib/libssl/src/ssl/ssl3.h b/src/lib/libssl/src/ssl/ssl3.h
index 7ee1feaa67..8fd6951d77 100644
--- a/src/lib/libssl/src/ssl/ssl3.h
+++ b/src/lib/libssl/src/ssl/ssl3.h
@@ -55,11 +55,64 @@
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#ifndef HEADER_SSL3_H 112#ifndef HEADER_SSL3_H
60#define HEADER_SSL3_H 113#define HEADER_SSL3_H
61 114
62#ifndef NO_COMP 115#ifndef OPENSSL_NO_COMP
63#include <openssl/comp.h> 116#include <openssl/comp.h>
64#endif 117#endif
65#include <openssl/buffer.h> 118#include <openssl/buffer.h>
@@ -105,6 +158,22 @@ extern "C" {
105#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D 158#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D
106#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E 159#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E
107 160
161/* VRS Additional Kerberos5 entries
162 */
163#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021
164#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022
165#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023
166#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024
167#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025
168#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026
169
170#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA"
171#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5"
172#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA"
173#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5"
174#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA"
175#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5"
176
108#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" 177#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
109#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" 178#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
110#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" 179#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5"
@@ -149,7 +218,8 @@ extern "C" {
149#define SSL3_RT_HEADER_LENGTH 5 218#define SSL3_RT_HEADER_LENGTH 5
150 219
151/* Due to MS stuffing up, this can change.... */ 220/* Due to MS stuffing up, this can change.... */
152#if defined(WIN16) || (defined(MSDOS) && !defined(WIN32)) 221#if defined(OPENSSL_SYS_WIN16) || \
222 (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32))
153#define SSL3_RT_MAX_EXTRA (14000) 223#define SSL3_RT_MAX_EXTRA (14000)
154#else 224#else
155#define SSL3_RT_MAX_EXTRA (16384) 225#define SSL3_RT_MAX_EXTRA (16384)
@@ -201,10 +271,11 @@ typedef struct ssl3_record_st
201 271
202typedef struct ssl3_buffer_st 272typedef struct ssl3_buffer_st
203 { 273 {
204 unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes (more if 274 unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes,
205 * SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER is set) */ 275 * see ssl3_setup_buffers() */
206 int offset; /* where to 'copy from' */ 276 size_t len; /* buffer size */
207 int left; /* how many bytes left */ 277 int offset; /* where to 'copy from' */
278 int left; /* how many bytes left */
208 } SSL3_BUFFER; 279 } SSL3_BUFFER;
209 280
210#define SSL3_CT_RSA_SIGN 1 281#define SSL3_CT_RSA_SIGN 1
@@ -234,6 +305,10 @@ typedef struct ssl3_state_st
234 unsigned char server_random[SSL3_RANDOM_SIZE]; 305 unsigned char server_random[SSL3_RANDOM_SIZE];
235 unsigned char client_random[SSL3_RANDOM_SIZE]; 306 unsigned char client_random[SSL3_RANDOM_SIZE];
236 307
308 /* flags for countermeasure against known-IV weakness */
309 int need_empty_fragments;
310 int empty_fragment_done;
311
237 SSL3_BUFFER rbuf; /* read IO goes into here */ 312 SSL3_BUFFER rbuf; /* read IO goes into here */
238 SSL3_BUFFER wbuf; /* write IO goes into here */ 313 SSL3_BUFFER wbuf; /* write IO goes into here */
239 314
@@ -292,7 +367,7 @@ typedef struct ssl3_state_st
292 367
293 /* used to hold the new cipher we are going to use */ 368 /* used to hold the new cipher we are going to use */
294 SSL_CIPHER *new_cipher; 369 SSL_CIPHER *new_cipher;
295#ifndef NO_DH 370#ifndef OPENSSL_NO_DH
296 DH *dh; 371 DH *dh;
297#endif 372#endif
298 /* used when SSL_ST_FLUSH_DATA is entered */ 373 /* used when SSL_ST_FLUSH_DATA is entered */
@@ -313,7 +388,7 @@ typedef struct ssl3_state_st
313 388
314 const EVP_CIPHER *new_sym_enc; 389 const EVP_CIPHER *new_sym_enc;
315 const EVP_MD *new_hash; 390 const EVP_MD *new_hash;
316#ifndef NO_COMP 391#ifndef OPENSSL_NO_COMP
317 const SSL_COMP *new_compression; 392 const SSL_COMP *new_compression;
318#else 393#else
319 char *new_compression; 394 char *new_compression;
diff --git a/src/lib/libssl/src/ssl/ssl_algs.c b/src/lib/libssl/src/ssl/ssl_algs.c
index dde8918fe0..3d1299ee7b 100644
--- a/src/lib/libssl/src/ssl/ssl_algs.c
+++ b/src/lib/libssl/src/ssl/ssl_algs.c
@@ -63,40 +63,44 @@
63 63
64int SSL_library_init(void) 64int SSL_library_init(void)
65 { 65 {
66#ifndef NO_DES 66
67#ifndef OPENSSL_NO_DES
67 EVP_add_cipher(EVP_des_cbc()); 68 EVP_add_cipher(EVP_des_cbc());
68 EVP_add_cipher(EVP_des_ede3_cbc()); 69 EVP_add_cipher(EVP_des_ede3_cbc());
69#endif 70#endif
70#ifndef NO_IDEA 71#ifndef OPENSSL_NO_IDEA
71 EVP_add_cipher(EVP_idea_cbc()); 72 EVP_add_cipher(EVP_idea_cbc());
72#endif 73#endif
73#ifndef NO_RC4 74#ifndef OPENSSL_NO_RC4
74 EVP_add_cipher(EVP_rc4()); 75 EVP_add_cipher(EVP_rc4());
75#endif 76#endif
76#ifndef NO_RC2 77#ifndef OPENSSL_NO_RC2
77 EVP_add_cipher(EVP_rc2_cbc()); 78 EVP_add_cipher(EVP_rc2_cbc());
78#endif 79#endif
79 80#ifndef OPENSSL_NO_AES
80#ifndef NO_MD2 81 EVP_add_cipher(EVP_aes_128_cbc());
82 EVP_add_cipher(EVP_aes_192_cbc());
83 EVP_add_cipher(EVP_aes_256_cbc());
84#endif
85#ifndef OPENSSL_NO_MD2
81 EVP_add_digest(EVP_md2()); 86 EVP_add_digest(EVP_md2());
82#endif 87#endif
83#ifndef NO_MD5 88#ifndef OPENSSL_NO_MD5
84 EVP_add_digest(EVP_md5()); 89 EVP_add_digest(EVP_md5());
85 EVP_add_digest_alias(SN_md5,"ssl2-md5"); 90 EVP_add_digest_alias(SN_md5,"ssl2-md5");
86 EVP_add_digest_alias(SN_md5,"ssl3-md5"); 91 EVP_add_digest_alias(SN_md5,"ssl3-md5");
87#endif 92#endif
88#ifndef NO_SHA 93#ifndef OPENSSL_NO_SHA
89 EVP_add_digest(EVP_sha1()); /* RSA with sha1 */ 94 EVP_add_digest(EVP_sha1()); /* RSA with sha1 */
90 EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); 95 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
91 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); 96 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
92#endif 97#endif
93#if !defined(NO_SHA) && !defined(NO_DSA) 98#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)
94 EVP_add_digest(EVP_dss1()); /* DSA with sha1 */ 99 EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
95 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); 100 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
96 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); 101 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
97 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); 102 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
98#endif 103#endif
99
100 /* If you want support for phased out ciphers, add the following */ 104 /* If you want support for phased out ciphers, add the following */
101#if 0 105#if 0
102 EVP_add_digest(EVP_sha()); 106 EVP_add_digest(EVP_sha());
diff --git a/src/lib/libssl/src/ssl/ssl_asn1.c b/src/lib/libssl/src/ssl/ssl_asn1.c
index fa6456e4f5..c5eeeb6bc5 100644
--- a/src/lib/libssl/src/ssl/ssl_asn1.c
+++ b/src/lib/libssl/src/ssl/ssl_asn1.c
@@ -72,6 +72,9 @@ typedef struct ssl_session_asn1_st
72 ASN1_OCTET_STRING session_id; 72 ASN1_OCTET_STRING session_id;
73 ASN1_OCTET_STRING session_id_context; 73 ASN1_OCTET_STRING session_id_context;
74 ASN1_OCTET_STRING key_arg; 74 ASN1_OCTET_STRING key_arg;
75#ifndef OPENSSL_NO_KRB5
76 ASN1_OCTET_STRING krb5_princ;
77#endif /* OPENSSL_NO_KRB5 */
75 ASN1_INTEGER time; 78 ASN1_INTEGER time;
76 ASN1_INTEGER timeout; 79 ASN1_INTEGER timeout;
77 ASN1_INTEGER verify_result; 80 ASN1_INTEGER verify_result;
@@ -142,6 +145,15 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
142 a.key_arg.type=V_ASN1_OCTET_STRING; 145 a.key_arg.type=V_ASN1_OCTET_STRING;
143 a.key_arg.data=in->key_arg; 146 a.key_arg.data=in->key_arg;
144 147
148#ifndef OPENSSL_NO_KRB5
149 if (in->krb5_client_princ_len)
150 {
151 a.krb5_princ.length=in->krb5_client_princ_len;
152 a.krb5_princ.type=V_ASN1_OCTET_STRING;
153 a.krb5_princ.data=in->krb5_client_princ;
154 }
155#endif /* OPENSSL_NO_KRB5 */
156
145 if (in->time != 0L) 157 if (in->time != 0L)
146 { 158 {
147 a.time.length=LSIZE2; 159 a.time.length=LSIZE2;
@@ -166,11 +178,16 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
166 ASN1_INTEGER_set(&a.verify_result,in->verify_result); 178 ASN1_INTEGER_set(&a.verify_result,in->verify_result);
167 } 179 }
168 180
181
169 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); 182 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER);
170 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); 183 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER);
171 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); 184 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING);
172 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); 185 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING);
173 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); 186 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING);
187#ifndef OPENSSL_NO_KRB5
188 if (in->krb5_client_princ_len)
189 M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING);
190#endif /* OPENSSL_NO_KRB5 */
174 if (in->key_arg_length > 0) 191 if (in->key_arg_length > 0)
175 M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING); 192 M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING);
176 if (in->time != 0L) 193 if (in->time != 0L)
@@ -190,6 +207,10 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
190 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); 207 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING);
191 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); 208 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING);
192 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); 209 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING);
210#ifndef OPENSSL_NO_KRB5
211 if (in->krb5_client_princ_len)
212 M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING);
213#endif /* OPENSSL_NO_KRB5 */
193 if (in->key_arg_length > 0) 214 if (in->key_arg_length > 0)
194 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); 215 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0);
195 if (in->time != 0L) 216 if (in->time != 0L)
@@ -285,6 +306,25 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
285 memcpy(ret->master_key,os.data,ret->master_key_length); 306 memcpy(ret->master_key,os.data,ret->master_key_length);
286 307
287 os.length=0; 308 os.length=0;
309
310#ifndef OPENSSL_NO_KRB5
311 os.length=0;
312 M_ASN1_D2I_get_opt(osp,d2i_ASN1_OCTET_STRING,V_ASN1_OCTET_STRING);
313 if (os.data)
314 {
315 if (os.length > SSL_MAX_KRB5_PRINCIPAL_LENGTH)
316 ret->krb5_client_princ_len=0;
317 else
318 ret->krb5_client_princ_len=os.length;
319 memcpy(ret->krb5_client_princ,os.data,ret->krb5_client_princ_len);
320 OPENSSL_free(os.data);
321 os.data = NULL;
322 os.length = 0;
323 }
324 else
325 ret->krb5_client_princ_len=0;
326#endif /* OPENSSL_NO_KRB5 */
327
288 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); 328 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING);
289 if (os.length > SSL_MAX_KEY_ARG_LENGTH) 329 if (os.length > SSL_MAX_KEY_ARG_LENGTH)
290 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; 330 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH;
diff --git a/src/lib/libssl/src/ssl/ssl_cert.c b/src/lib/libssl/src/ssl/ssl_cert.c
index 27e7fcc60a..79e89fe14a 100644
--- a/src/lib/libssl/src/ssl/ssl_cert.c
+++ b/src/lib/libssl/src/ssl/ssl_cert.c
@@ -106,16 +106,19 @@
106 106
107#include <stdio.h> 107#include <stdio.h>
108 108
109#include "openssl/e_os.h" 109#include "e_os.h"
110
111#ifndef NO_SYS_TYPES_H 110#ifndef NO_SYS_TYPES_H
112# include <sys/types.h> 111# include <sys/types.h>
113#endif 112#endif
114 113
115#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X) 114#if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(NeXT) && !defined(MAC_OS_pre_X)
116#include <dirent.h> 115#include <dirent.h>
117#endif 116#endif
118 117
118#if defined(WIN32)
119#include <windows.h>
120#endif
121
119#ifdef NeXT 122#ifdef NeXT
120#include <sys/dir.h> 123#include <sys/dir.h>
121#define dirent direct 124#define dirent direct
@@ -129,14 +132,23 @@
129 132
130int SSL_get_ex_data_X509_STORE_CTX_idx(void) 133int SSL_get_ex_data_X509_STORE_CTX_idx(void)
131 { 134 {
132 static int ssl_x509_store_ctx_idx= -1; 135 static volatile int ssl_x509_store_ctx_idx= -1;
133 136
134 if (ssl_x509_store_ctx_idx < 0) 137 if (ssl_x509_store_ctx_idx < 0)
135 { 138 {
136 ssl_x509_store_ctx_idx=X509_STORE_CTX_get_ex_new_index( 139 /* any write lock will do; usually this branch
137 0,"SSL for verify callback",NULL,NULL,NULL); 140 * will only be taken once anyway */
141 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
142
143 if (ssl_x509_store_ctx_idx < 0)
144 {
145 ssl_x509_store_ctx_idx=X509_STORE_CTX_get_ex_new_index(
146 0,"SSL for verify callback",NULL,NULL,NULL);
147 }
148
149 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
138 } 150 }
139 return(ssl_x509_store_ctx_idx); 151 return ssl_x509_store_ctx_idx;
140 } 152 }
141 153
142CERT *ssl_cert_new(void) 154CERT *ssl_cert_new(void)
@@ -179,16 +191,16 @@ CERT *ssl_cert_dup(CERT *cert)
179 ret->mask = cert->mask; 191 ret->mask = cert->mask;
180 ret->export_mask = cert->export_mask; 192 ret->export_mask = cert->export_mask;
181 193
182#ifndef NO_RSA 194#ifndef OPENSSL_NO_RSA
183 if (cert->rsa_tmp != NULL) 195 if (cert->rsa_tmp != NULL)
184 { 196 {
197 RSA_up_ref(cert->rsa_tmp);
185 ret->rsa_tmp = cert->rsa_tmp; 198 ret->rsa_tmp = cert->rsa_tmp;
186 CRYPTO_add(&ret->rsa_tmp->references, 1, CRYPTO_LOCK_RSA);
187 } 199 }
188 ret->rsa_tmp_cb = cert->rsa_tmp_cb; 200 ret->rsa_tmp_cb = cert->rsa_tmp_cb;
189#endif 201#endif
190 202
191#ifndef NO_DH 203#ifndef OPENSSL_NO_DH
192 if (cert->dh_tmp != NULL) 204 if (cert->dh_tmp != NULL)
193 { 205 {
194 /* DH parameters don't have a reference count */ 206 /* DH parameters don't have a reference count */
@@ -271,14 +283,14 @@ CERT *ssl_cert_dup(CERT *cert)
271 283
272 return(ret); 284 return(ret);
273 285
274#ifndef NO_DH /* avoid 'unreferenced label' warning if NO_DH is defined */ 286#ifndef OPENSSL_NO_DH /* avoid 'unreferenced label' warning if OPENSSL_NO_DH is defined */
275err: 287err:
276#endif 288#endif
277#ifndef NO_RSA 289#ifndef OPENSSL_NO_RSA
278 if (ret->rsa_tmp != NULL) 290 if (ret->rsa_tmp != NULL)
279 RSA_free(ret->rsa_tmp); 291 RSA_free(ret->rsa_tmp);
280#endif 292#endif
281#ifndef NO_DH 293#ifndef OPENSSL_NO_DH
282 if (ret->dh_tmp != NULL) 294 if (ret->dh_tmp != NULL)
283 DH_free(ret->dh_tmp); 295 DH_free(ret->dh_tmp);
284#endif 296#endif
@@ -315,10 +327,10 @@ void ssl_cert_free(CERT *c)
315 } 327 }
316#endif 328#endif
317 329
318#ifndef NO_RSA 330#ifndef OPENSSL_NO_RSA
319 if (c->rsa_tmp) RSA_free(c->rsa_tmp); 331 if (c->rsa_tmp) RSA_free(c->rsa_tmp);
320#endif 332#endif
321#ifndef NO_DH 333#ifndef OPENSSL_NO_DH
322 if (c->dh_tmp) DH_free(c->dh_tmp); 334 if (c->dh_tmp) DH_free(c->dh_tmp);
323#endif 335#endif
324 336
@@ -419,11 +431,11 @@ void ssl_sess_cert_free(SESS_CERT *sc)
419#endif 431#endif
420 } 432 }
421 433
422#ifndef NO_RSA 434#ifndef OPENSSL_NO_RSA
423 if (sc->peer_rsa_tmp != NULL) 435 if (sc->peer_rsa_tmp != NULL)
424 RSA_free(sc->peer_rsa_tmp); 436 RSA_free(sc->peer_rsa_tmp);
425#endif 437#endif
426#ifndef NO_DH 438#ifndef OPENSSL_NO_DH
427 if (sc->peer_dh_tmp != NULL) 439 if (sc->peer_dh_tmp != NULL)
428 DH_free(sc->peer_dh_tmp); 440 DH_free(sc->peer_dh_tmp);
429#endif 441#endif
@@ -447,25 +459,38 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk)
447 return(0); 459 return(0);
448 460
449 x=sk_X509_value(sk,0); 461 x=sk_X509_value(sk,0);
450 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk); 462 if(!X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk))
463 {
464 SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,ERR_R_X509_LIB);
465 return(0);
466 }
451 if (SSL_get_verify_depth(s) >= 0) 467 if (SSL_get_verify_depth(s) >= 0)
452 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s)); 468 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s));
453 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s); 469 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s);
470
454 /* We need to set the verify purpose. The purpose can be determined by 471 /* We need to set the verify purpose. The purpose can be determined by
455 * the context: if its a server it will verify SSL client certificates 472 * the context: if its a server it will verify SSL client certificates
456 * or vice versa. 473 * or vice versa.
457 */ 474 */
458 475 if (s->server)
459 if(s->server) i = X509_PURPOSE_SSL_CLIENT; 476 i = X509_PURPOSE_SSL_CLIENT;
460 else i = X509_PURPOSE_SSL_SERVER; 477 else
478 i = X509_PURPOSE_SSL_SERVER;
461 479
462 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust); 480 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust);
463 481
482 if (s->verify_callback)
483 X509_STORE_CTX_set_verify_cb(&ctx, s->verify_callback);
484
464 if (s->ctx->app_verify_callback != NULL) 485 if (s->ctx->app_verify_callback != NULL)
486#if 1 /* new with OpenSSL 0.9.7 */
487 i=s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg);
488#else
465 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */ 489 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */
490#endif
466 else 491 else
467 { 492 {
468#ifndef NO_X509_VERIFY 493#ifndef OPENSSL_NO_X509_VERIFY
469 i=X509_verify_cert(&ctx); 494 i=X509_verify_cert(&ctx);
470#else 495#else
471 i=0; 496 i=0;
@@ -575,7 +600,7 @@ static int xname_cmp(const X509_NAME * const *a, const X509_NAME * const *b)
575 return(X509_NAME_cmp(*a,*b)); 600 return(X509_NAME_cmp(*a,*b));
576 } 601 }
577 602
578#ifndef NO_STDIO 603#ifndef OPENSSL_NO_STDIO
579/*! 604/*!
580 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed; 605 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
581 * it doesn't really have anything to do with clients (except that a common use 606 * it doesn't really have anything to do with clients (except that a common use
@@ -705,9 +730,9 @@ err:
705 * certs may have been added to \c stack. 730 * certs may have been added to \c stack.
706 */ 731 */
707 732
708#ifndef WIN32 733#ifndef OPENSSL_SYS_WIN32
709#ifndef VMS /* XXXX This may be fixed in the future */ 734#ifndef OPENSSL_SYS_VMS /* XXXX This may be fixed in the future */
710#ifndef MAC_OS_pre_X 735#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! */
711 736
712int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, 737int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
713 const char *dir) 738 const char *dir)
@@ -748,10 +773,61 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
748 ret = 1; 773 ret = 1;
749 774
750err: 775err:
776 if (d) closedir(d);
751 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); 777 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
752 return ret; 778 return ret;
753 } 779 }
754 780
755#endif 781#endif
756#endif 782#endif
783
784#else
785
786int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
787 const char *dir)
788 {
789 WIN32_FIND_DATA FindFileData;
790 HANDLE hFind;
791 int ret = 0;
792
793 CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
794
795 hFind = FindFirstFile(dir, &FindFileData);
796 /* Note that a side effect is that the CAs will be sorted by name */
797 if(hFind == INVALID_HANDLE_VALUE)
798 {
799 SYSerr(SYS_F_OPENDIR, get_last_sys_error());
800 ERR_add_error_data(3, "opendir('", dir, "')");
801 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);
802 goto err_noclose;
803 }
804
805 do
806 {
807 char buf[1024];
808 int r;
809
810 if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf)
811 {
812 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);
813 goto err;
814 }
815
816 r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,FindFileData.cFileName);
817 if (r <= 0 || r >= sizeof buf)
818 goto err;
819 if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
820 goto err;
821 }
822 while (FindNextFile(hFind, &FindFileData) != FALSE);
823 ret = 1;
824
825err:
826 FindClose(hFind);
827err_noclose:
828 if (d) closedir(d);
829 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
830 return ret;
831 }
832
757#endif 833#endif
diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c
index f63163f26c..cdd8dde128 100644
--- a/src/lib/libssl/src/ssl/ssl_ciph.c
+++ b/src/lib/libssl/src/ssl/ssl_ciph.c
@@ -68,7 +68,9 @@
68#define SSL_ENC_IDEA_IDX 4 68#define SSL_ENC_IDEA_IDX 4
69#define SSL_ENC_eFZA_IDX 5 69#define SSL_ENC_eFZA_IDX 5
70#define SSL_ENC_NULL_IDX 6 70#define SSL_ENC_NULL_IDX 6
71#define SSL_ENC_NUM_IDX 7 71#define SSL_ENC_AES128_IDX 7
72#define SSL_ENC_AES256_IDX 8
73#define SSL_ENC_NUM_IDX 9
72 74
73static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ 75static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={
74 NULL,NULL,NULL,NULL,NULL,NULL, 76 NULL,NULL,NULL,NULL,NULL,NULL,
@@ -98,8 +100,10 @@ typedef struct cipher_order_st
98 } CIPHER_ORDER; 100 } CIPHER_ORDER;
99 101
100static const SSL_CIPHER cipher_aliases[]={ 102static const SSL_CIPHER cipher_aliases[]={
101 /* Don't include eNULL unless specifically enabled */ 103 /* Don't include eNULL unless specifically enabled.
102 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */ 104 * Similarly, don't include AES in ALL because these ciphers are not yet official. */
105 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL & ~SSL_AES, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */
106 {0,SSL_TXT_kKRB5,0,SSL_kKRB5,0,0,0,0,SSL_MKEY_MASK,0}, /* VRS Kerberos5 */
103 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0}, 107 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0},
104 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0}, 108 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0},
105 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0}, 109 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0},
@@ -108,6 +112,7 @@ static const SSL_CIPHER cipher_aliases[]={
108 {0,SSL_TXT_DH, 0,SSL_DH, 0,0,0,0,SSL_MKEY_MASK,0}, 112 {0,SSL_TXT_DH, 0,SSL_DH, 0,0,0,0,SSL_MKEY_MASK,0},
109 {0,SSL_TXT_EDH, 0,SSL_EDH, 0,0,0,0,SSL_MKEY_MASK|SSL_AUTH_MASK,0}, 113 {0,SSL_TXT_EDH, 0,SSL_EDH, 0,0,0,0,SSL_MKEY_MASK|SSL_AUTH_MASK,0},
110 114
115 {0,SSL_TXT_aKRB5,0,SSL_aKRB5,0,0,0,0,SSL_AUTH_MASK,0}, /* VRS Kerberos5 */
111 {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,0,0,0,SSL_AUTH_MASK,0}, 116 {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,0,0,0,SSL_AUTH_MASK,0},
112 {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,0,0,0,SSL_AUTH_MASK,0}, 117 {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,0,0,0,SSL_AUTH_MASK,0},
113 {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,0,0,0,SSL_AUTH_MASK,0}, 118 {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,0,0,0,SSL_AUTH_MASK,0},
@@ -122,12 +127,14 @@ static const SSL_CIPHER cipher_aliases[]={
122 {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,0,0,0,SSL_ENC_MASK,0}, 127 {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,0,0,0,SSL_ENC_MASK,0},
123 {0,SSL_TXT_eNULL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0}, 128 {0,SSL_TXT_eNULL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0},
124 {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,0,0,0,SSL_ENC_MASK,0}, 129 {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,0,0,0,SSL_ENC_MASK,0},
130 {0,SSL_TXT_AES, 0,SSL_AES, 0,0,0,0,SSL_ENC_MASK,0},
125 131
126 {0,SSL_TXT_MD5, 0,SSL_MD5, 0,0,0,0,SSL_MAC_MASK,0}, 132 {0,SSL_TXT_MD5, 0,SSL_MD5, 0,0,0,0,SSL_MAC_MASK,0},
127 {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,0,0,0,SSL_MAC_MASK,0}, 133 {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,0,0,0,SSL_MAC_MASK,0},
128 {0,SSL_TXT_SHA, 0,SSL_SHA, 0,0,0,0,SSL_MAC_MASK,0}, 134 {0,SSL_TXT_SHA, 0,SSL_SHA, 0,0,0,0,SSL_MAC_MASK,0},
129 135
130 {0,SSL_TXT_NULL,0,SSL_NULL, 0,0,0,0,SSL_ENC_MASK,0}, 136 {0,SSL_TXT_NULL,0,SSL_NULL, 0,0,0,0,SSL_ENC_MASK,0},
137 {0,SSL_TXT_KRB5,0,SSL_KRB5, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
131 {0,SSL_TXT_RSA, 0,SSL_RSA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, 138 {0,SSL_TXT_RSA, 0,SSL_RSA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
132 {0,SSL_TXT_ADH, 0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, 139 {0,SSL_TXT_ADH, 0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
133 {0,SSL_TXT_FZA, 0,SSL_FZA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK,0}, 140 {0,SSL_TXT_FZA, 0,SSL_FZA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK,0},
@@ -160,6 +167,10 @@ static void load_ciphers(void)
160 EVP_get_cipherbyname(SN_rc2_cbc); 167 EVP_get_cipherbyname(SN_rc2_cbc);
161 ssl_cipher_methods[SSL_ENC_IDEA_IDX]= 168 ssl_cipher_methods[SSL_ENC_IDEA_IDX]=
162 EVP_get_cipherbyname(SN_idea_cbc); 169 EVP_get_cipherbyname(SN_idea_cbc);
170 ssl_cipher_methods[SSL_ENC_AES128_IDX]=
171 EVP_get_cipherbyname(SN_aes_128_cbc);
172 ssl_cipher_methods[SSL_ENC_AES256_IDX]=
173 EVP_get_cipherbyname(SN_aes_256_cbc);
163 174
164 ssl_digest_methods[SSL_MD_MD5_IDX]= 175 ssl_digest_methods[SSL_MD_MD5_IDX]=
165 EVP_get_digestbyname(SN_md5); 176 EVP_get_digestbyname(SN_md5);
@@ -220,6 +231,14 @@ int ssl_cipher_get_evp(SSL_SESSION *s, const EVP_CIPHER **enc,
220 case SSL_eNULL: 231 case SSL_eNULL:
221 i=SSL_ENC_NULL_IDX; 232 i=SSL_ENC_NULL_IDX;
222 break; 233 break;
234 case SSL_AES:
235 switch(c->alg_bits)
236 {
237 case 128: i=SSL_ENC_AES128_IDX; break;
238 case 256: i=SSL_ENC_AES256_IDX; break;
239 default: i=-1; break;
240 }
241 break;
223 default: 242 default:
224 i= -1; 243 i= -1;
225 break; 244 break;
@@ -282,15 +301,18 @@ static unsigned long ssl_cipher_get_disabled(void)
282 unsigned long mask; 301 unsigned long mask;
283 302
284 mask = SSL_kFZA; 303 mask = SSL_kFZA;
285#ifdef NO_RSA 304#ifdef OPENSSL_NO_RSA
286 mask |= SSL_aRSA|SSL_kRSA; 305 mask |= SSL_aRSA|SSL_kRSA;
287#endif 306#endif
288#ifdef NO_DSA 307#ifdef OPENSSL_NO_DSA
289 mask |= SSL_aDSS; 308 mask |= SSL_aDSS;
290#endif 309#endif
291#ifdef NO_DH 310#ifdef OPENSSL_NO_DH
292 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; 311 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH;
293#endif 312#endif
313#ifdef OPENSSL_NO_KRB5
314 mask |= SSL_kKRB5|SSL_aKRB5;
315#endif
294 316
295#ifdef SSL_FORBID_ENULL 317#ifdef SSL_FORBID_ENULL
296 mask |= SSL_eNULL; 318 mask |= SSL_eNULL;
@@ -302,6 +324,7 @@ static unsigned long ssl_cipher_get_disabled(void)
302 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0; 324 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0;
303 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0; 325 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0;
304 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0; 326 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0;
327 mask |= (ssl_cipher_methods[SSL_ENC_AES128_IDX] == NULL) ? SSL_AES:0;
305 328
306 mask |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 :0; 329 mask |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 :0;
307 mask |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1:0; 330 mask |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1:0;
@@ -336,6 +359,9 @@ static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method,
336 list[list_num].prev = NULL; 359 list[list_num].prev = NULL;
337 list[list_num].active = 0; 360 list[list_num].active = 0;
338 list_num++; 361 list_num++;
362#ifdef KSSL_DEBUG
363 printf("\t%d: %s %lx %lx\n",i,c->name,c->id,c->algorithms);
364#endif /* KSSL_DEBUG */
339 /* 365 /*
340 if (!sk_push(ca_list,(char *)c)) goto err; 366 if (!sk_push(ca_list,(char *)c)) goto err;
341 */ 367 */
@@ -738,6 +764,9 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
738 * it is used for allocation. 764 * it is used for allocation.
739 */ 765 */
740 num_of_ciphers = ssl_method->num_ciphers(); 766 num_of_ciphers = ssl_method->num_ciphers();
767#ifdef KSSL_DEBUG
768 printf("ssl_create_cipher_list() for %d ciphers\n", num_of_ciphers);
769#endif /* KSSL_DEBUG */
741 list = (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers); 770 list = (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
742 if (list == NULL) 771 if (list == NULL)
743 { 772 {
@@ -872,8 +901,12 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
872 char *ver,*exp; 901 char *ver,*exp;
873 char *kx,*au,*enc,*mac; 902 char *kx,*au,*enc,*mac;
874 unsigned long alg,alg2,alg_s; 903 unsigned long alg,alg2,alg_s;
904#ifdef KSSL_DEBUG
905 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s AL=%lx\n";
906#else
875 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; 907 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n";
876 908#endif /* KSSL_DEBUG */
909
877 alg=cipher->algorithms; 910 alg=cipher->algorithms;
878 alg_s=cipher->algo_strength; 911 alg_s=cipher->algo_strength;
879 alg2=cipher->algorithm2; 912 alg2=cipher->algorithm2;
@@ -901,6 +934,10 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
901 case SSL_kDHd: 934 case SSL_kDHd:
902 kx="DH/DSS"; 935 kx="DH/DSS";
903 break; 936 break;
937 case SSL_kKRB5: /* VRS */
938 case SSL_KRB5: /* VRS */
939 kx="KRB5";
940 break;
904 case SSL_kFZA: 941 case SSL_kFZA:
905 kx="Fortezza"; 942 kx="Fortezza";
906 break; 943 break;
@@ -922,6 +959,10 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
922 case SSL_aDH: 959 case SSL_aDH:
923 au="DH"; 960 au="DH";
924 break; 961 break;
962 case SSL_aKRB5: /* VRS */
963 case SSL_KRB5: /* VRS */
964 au="KRB5";
965 break;
925 case SSL_aFZA: 966 case SSL_aFZA:
926 case SSL_aNULL: 967 case SSL_aNULL:
927 au="None"; 968 au="None";
@@ -955,6 +996,15 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
955 case SSL_eNULL: 996 case SSL_eNULL:
956 enc="None"; 997 enc="None";
957 break; 998 break;
999 case SSL_AES:
1000 switch(cipher->strength_bits)
1001 {
1002 case 128: enc="AESdraft(128)"; break;
1003 case 192: enc="AESdraft(192)"; break;
1004 case 256: enc="AESdraft(256)"; break;
1005 default: enc="AESdraft(?""?""?)"; break;
1006 }
1007 break;
958 default: 1008 default:
959 enc="unknown"; 1009 enc="unknown";
960 break; 1010 break;
@@ -982,7 +1032,11 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
982 else if (len < 128) 1032 else if (len < 128)
983 return("Buffer too small"); 1033 return("Buffer too small");
984 1034
1035#ifdef KSSL_DEBUG
1036 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp,alg);
1037#else
985 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp); 1038 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp);
1039#endif /* KSSL_DEBUG */
986 return(buf); 1040 return(buf);
987 } 1041 }
988 1042
@@ -1053,6 +1107,10 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
1053 SSL_COMP *comp; 1107 SSL_COMP *comp;
1054 STACK_OF(SSL_COMP) *sk; 1108 STACK_OF(SSL_COMP) *sk;
1055 1109
1110 if (cm == NULL || cm->type == NID_undef)
1111 return 1;
1112
1113 MemCheck_off();
1056 comp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP)); 1114 comp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
1057 comp->id=id; 1115 comp->id=id;
1058 comp->method=cm; 1116 comp->method=cm;
@@ -1062,10 +1120,13 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
1062 sk=ssl_comp_methods; 1120 sk=ssl_comp_methods;
1063 if ((sk == NULL) || !sk_SSL_COMP_push(sk,comp)) 1121 if ((sk == NULL) || !sk_SSL_COMP_push(sk,comp))
1064 { 1122 {
1123 MemCheck_on();
1065 SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE); 1124 SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE);
1066 return(0); 1125 return(0);
1067 } 1126 }
1068 else 1127 else
1128 {
1129 MemCheck_on();
1069 return(1); 1130 return(1);
1131 }
1070 } 1132 }
1071
diff --git a/src/lib/libssl/src/ssl/ssl_err.c b/src/lib/libssl/src/ssl/ssl_err.c
index 1ae3333407..c32c4ef6e9 100644
--- a/src/lib/libssl/src/ssl/ssl_err.c
+++ b/src/lib/libssl/src/ssl/ssl_err.c
@@ -63,7 +63,7 @@
63#include <openssl/ssl.h> 63#include <openssl/ssl.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA SSL_str_functs[]= 67static ERR_STRING_DATA SSL_str_functs[]=
68 { 68 {
69{ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"}, 69{ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"},
@@ -106,6 +106,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
106{ERR_PACK(0,SSL_F_SSL3_CTRL,0), "SSL3_CTRL"}, 106{ERR_PACK(0,SSL_F_SSL3_CTRL,0), "SSL3_CTRL"},
107{ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"}, 107{ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"},
108{ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"}, 108{ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"},
109{ERR_PACK(0,SSL_F_SSL3_GENERATE_KEY_BLOCK,0), "SSL3_GENERATE_KEY_BLOCK"},
109{ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"}, 110{ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"},
110{ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"}, 111{ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"},
111{ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"}, 112{ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"},
@@ -258,6 +259,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
258{SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"}, 259{SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"},
259{SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"}, 260{SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"},
260{SSL_R_DECRYPTION_FAILED ,"decryption failed"}, 261{SSL_R_DECRYPTION_FAILED ,"decryption failed"},
262{SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC,"decryption failed or bad record mac"},
261{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, 263{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"},
262{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, 264{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"},
263{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, 265{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"},
@@ -268,15 +270,27 @@ static ERR_STRING_DATA SSL_str_reasons[]=
268{SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"}, 270{SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"},
269{SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"}, 271{SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"},
270{SSL_R_HTTP_REQUEST ,"http request"}, 272{SSL_R_HTTP_REQUEST ,"http request"},
271{SSL_R_INTERNAL_ERROR ,"internal error"}, 273{SSL_R_ILLEGAL_PADDING ,"illegal padding"},
272{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, 274{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"},
273{SSL_R_INVALID_COMMAND ,"invalid command"}, 275{SSL_R_INVALID_COMMAND ,"invalid command"},
274{SSL_R_INVALID_PURPOSE ,"invalid purpose"}, 276{SSL_R_INVALID_PURPOSE ,"invalid purpose"},
275{SSL_R_INVALID_TRUST ,"invalid trust"}, 277{SSL_R_INVALID_TRUST ,"invalid trust"},
278{SSL_R_KRB5 ,"krb5"},
279{SSL_R_KRB5_C_CC_PRINC ,"krb5 client cc principal (no tkt?)"},
280{SSL_R_KRB5_C_GET_CRED ,"krb5 client get cred"},
281{SSL_R_KRB5_C_INIT ,"krb5 client init"},
282{SSL_R_KRB5_C_MK_REQ ,"krb5 client mk_req (expired tkt?)"},
283{SSL_R_KRB5_S_BAD_TICKET ,"krb5 server bad ticket"},
284{SSL_R_KRB5_S_INIT ,"krb5 server init"},
285{SSL_R_KRB5_S_RD_REQ ,"krb5 server rd_req (keytab perms?)"},
286{SSL_R_KRB5_S_TKT_EXPIRED ,"krb5 server tkt expired"},
287{SSL_R_KRB5_S_TKT_NYV ,"krb5 server tkt not yet valid"},
288{SSL_R_KRB5_S_TKT_SKEW ,"krb5 server tkt skew"},
276{SSL_R_LENGTH_MISMATCH ,"length mismatch"}, 289{SSL_R_LENGTH_MISMATCH ,"length mismatch"},
277{SSL_R_LENGTH_TOO_SHORT ,"length too short"}, 290{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
278{SSL_R_LIBRARY_BUG ,"library bug"}, 291{SSL_R_LIBRARY_BUG ,"library bug"},
279{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, 292{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"},
293{SSL_R_MESSAGE_TOO_LONG ,"message too long"},
280{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, 294{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"},
281{SSL_R_MISSING_DH_KEY ,"missing dh key"}, 295{SSL_R_MISSING_DH_KEY ,"missing dh key"},
282{SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"}, 296{SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"},
@@ -360,7 +374,10 @@ static ERR_STRING_DATA SSL_str_reasons[]=
360{SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"}, 374{SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"},
361{SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"}, 375{SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"},
362{SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"}, 376{SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"},
377{SSL_R_SSL_SESSION_ID_CALLBACK_FAILED ,"ssl session id callback failed"},
378{SSL_R_SSL_SESSION_ID_CONFLICT ,"ssl session id conflict"},
363{SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG ,"ssl session id context too long"}, 379{SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG ,"ssl session id context too long"},
380{SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH ,"ssl session id has bad length"},
364{SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"}, 381{SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"},
365{SSL_R_TLSV1_ALERT_ACCESS_DENIED ,"tlsv1 alert access denied"}, 382{SSL_R_TLSV1_ALERT_ACCESS_DENIED ,"tlsv1 alert access denied"},
366{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"}, 383{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"},
@@ -426,7 +443,7 @@ void ERR_load_SSL_strings(void)
426 if (init) 443 if (init)
427 { 444 {
428 init=0; 445 init=0;
429#ifndef NO_ERR 446#ifndef OPENSSL_NO_ERR
430 ERR_load_strings(ERR_LIB_SSL,SSL_str_functs); 447 ERR_load_strings(ERR_LIB_SSL,SSL_str_functs);
431 ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons); 448 ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons);
432#endif 449#endif
diff --git a/src/lib/libssl/src/ssl/ssl_err2.c b/src/lib/libssl/src/ssl/ssl_err2.c
index cc089a612b..ea95a5f983 100644
--- a/src/lib/libssl/src/ssl/ssl_err2.c
+++ b/src/lib/libssl/src/ssl/ssl_err2.c
@@ -62,7 +62,7 @@
62 62
63void SSL_load_error_strings(void) 63void SSL_load_error_strings(void)
64 { 64 {
65#ifndef NO_ERR 65#ifndef OPENSSL_NO_ERR
66 ERR_load_crypto_strings(); 66 ERR_load_crypto_strings();
67 ERR_load_SSL_strings(); 67 ERR_load_SSL_strings();
68#endif 68#endif
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c
index 1fe85b6cb7..df307a80c5 100644
--- a/src/lib/libssl/src/ssl/ssl_lib.c
+++ b/src/lib/libssl/src/ssl/ssl_lib.c
@@ -57,22 +57,73 @@
57 * copied and put under another distribution licence 57 * copied and put under another distribution licence
58 * [including the GNU Public Licence.] 58 * [including the GNU Public Licence.]
59 */ 59 */
60/* ====================================================================
61 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 *
67 * 1. Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 *
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in
72 * the documentation and/or other materials provided with the
73 * distribution.
74 *
75 * 3. All advertising materials mentioning features or use of this
76 * software must display the following acknowledgment:
77 * "This product includes software developed by the OpenSSL Project
78 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
79 *
80 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
81 * endorse or promote products derived from this software without
82 * prior written permission. For written permission, please contact
83 * openssl-core@openssl.org.
84 *
85 * 5. Products derived from this software may not be called "OpenSSL"
86 * nor may "OpenSSL" appear in their names without prior written
87 * permission of the OpenSSL Project.
88 *
89 * 6. Redistributions of any form whatsoever must retain the following
90 * acknowledgment:
91 * "This product includes software developed by the OpenSSL Project
92 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
93 *
94 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
95 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
97 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
98 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
99 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
100 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
101 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
102 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
103 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
104 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
105 * OF THE POSSIBILITY OF SUCH DAMAGE.
106 * ====================================================================
107 *
108 * This product includes cryptographic software written by Eric Young
109 * (eay@cryptsoft.com). This product includes software written by Tim
110 * Hudson (tjh@cryptsoft.com).
111 *
112 */
60 113
61 114
62#include <assert.h> 115#ifdef REF_CHECK
116# include <assert.h>
117#endif
63#include <stdio.h> 118#include <stdio.h>
64#include <openssl/objects.h> 119#include <openssl/objects.h>
65#include <openssl/lhash.h> 120#include <openssl/lhash.h>
66#include <openssl/x509v3.h> 121#include <openssl/x509v3.h>
67#include "ssl_locl.h" 122#include "ssl_locl.h"
123#include "kssl_lcl.h"
68 124
69const char *SSL_version_str=OPENSSL_VERSION_TEXT; 125const char *SSL_version_str=OPENSSL_VERSION_TEXT;
70 126
71static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_meth=NULL;
72static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_ctx_meth=NULL;
73static int ssl_meth_num=0;
74static int ssl_ctx_meth_num=0;
75
76OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={ 127OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
77 /* evil casts, but these functions are only called if there's a library bug */ 128 /* evil casts, but these functions are only called if there's a library bug */
78 (int (*)(SSL *,int))ssl_undefined_function, 129 (int (*)(SSL *,int))ssl_undefined_function,
@@ -85,7 +136,6 @@ OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
85 136
86int SSL_clear(SSL *s) 137int SSL_clear(SSL *s)
87 { 138 {
88 int state;
89 139
90 if (s->method == NULL) 140 if (s->method == NULL)
91 { 141 {
@@ -93,6 +143,12 @@ int SSL_clear(SSL *s)
93 return(0); 143 return(0);
94 } 144 }
95 145
146 if (ssl_clear_bad_session(s))
147 {
148 SSL_SESSION_free(s->session);
149 s->session=NULL;
150 }
151
96 s->error=0; 152 s->error=0;
97 s->hit=0; 153 s->hit=0;
98 s->shutdown=0; 154 s->shutdown=0;
@@ -105,12 +161,11 @@ int SSL_clear(SSL *s)
105#else 161#else
106 if (s->new_session) 162 if (s->new_session)
107 { 163 {
108 SSLerr(SSL_F_SSL_CLEAR,SSL_R_INTERNAL_ERROR); 164 SSLerr(SSL_F_SSL_CLEAR,ERR_R_INTERNAL_ERROR);
109 return 0; 165 return 0;
110 } 166 }
111#endif 167#endif
112 168
113 state=s->state; /* Keep to check if we throw away the session-id */
114 s->type=0; 169 s->type=0;
115 170
116 s->state=SSL_ST_BEFORE|((s->server)?SSL_ST_ACCEPT:SSL_ST_CONNECT); 171 s->state=SSL_ST_BEFORE|((s->server)?SSL_ST_ACCEPT:SSL_ST_CONNECT);
@@ -131,18 +186,12 @@ int SSL_clear(SSL *s)
131 186
132 ssl_clear_cipher_ctx(s); 187 ssl_clear_cipher_ctx(s);
133 188
134 if (ssl_clear_bad_session(s))
135 {
136 SSL_SESSION_free(s->session);
137 s->session=NULL;
138 }
139
140 s->first_packet=0; 189 s->first_packet=0;
141 190
142#if 1 191#if 1
143 /* Check to see if we were changed into a different method, if 192 /* Check to see if we were changed into a different method, if
144 * so, revert back if we are not doing session-id reuse. */ 193 * so, revert back if we are not doing session-id reuse. */
145 if ((s->session == NULL) && (s->method != s->ctx->method)) 194 if (!s->in_handshake && (s->session == NULL) && (s->method != s->ctx->method))
146 { 195 {
147 s->method->ssl_free(s); 196 s->method->ssl_free(s);
148 s->method=s->ctx->method; 197 s->method=s->ctx->method;
@@ -191,6 +240,14 @@ SSL *SSL_new(SSL_CTX *ctx)
191 if (s == NULL) goto err; 240 if (s == NULL) goto err;
192 memset(s,0,sizeof(SSL)); 241 memset(s,0,sizeof(SSL));
193 242
243#ifndef OPENSSL_NO_KRB5
244 s->kssl_ctx = kssl_ctx_new();
245#endif /* OPENSSL_NO_KRB5 */
246
247 s->options=ctx->options;
248 s->mode=ctx->mode;
249 s->max_cert_list=ctx->max_cert_list;
250
194 if (ctx->cert != NULL) 251 if (ctx->cert != NULL)
195 { 252 {
196 /* Earlier library versions used to copy the pointer to 253 /* Earlier library versions used to copy the pointer to
@@ -209,13 +266,20 @@ SSL *SSL_new(SSL_CTX *ctx)
209 } 266 }
210 else 267 else
211 s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */ 268 s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */
212 s->sid_ctx_length=ctx->sid_ctx_length; 269
213 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); 270 s->read_ahead=ctx->read_ahead;
271 s->msg_callback=ctx->msg_callback;
272 s->msg_callback_arg=ctx->msg_callback_arg;
214 s->verify_mode=ctx->verify_mode; 273 s->verify_mode=ctx->verify_mode;
215 s->verify_depth=ctx->verify_depth; 274 s->verify_depth=ctx->verify_depth;
275 s->sid_ctx_length=ctx->sid_ctx_length;
276 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx));
216 s->verify_callback=ctx->default_verify_callback; 277 s->verify_callback=ctx->default_verify_callback;
278 s->generate_session_id=ctx->generate_session_id;
217 s->purpose = ctx->purpose; 279 s->purpose = ctx->purpose;
218 s->trust = ctx->trust; 280 s->trust = ctx->trust;
281 s->quiet_shutdown=ctx->quiet_shutdown;
282
219 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); 283 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
220 s->ctx=ctx; 284 s->ctx=ctx;
221 285
@@ -226,15 +290,12 @@ SSL *SSL_new(SSL_CTX *ctx)
226 if (!s->method->ssl_new(s)) 290 if (!s->method->ssl_new(s))
227 goto err; 291 goto err;
228 292
229 s->quiet_shutdown=ctx->quiet_shutdown;
230 s->references=1; 293 s->references=1;
231 s->server=(ctx->method->ssl_accept == ssl_undefined_function)?0:1; 294 s->server=(ctx->method->ssl_accept == ssl_undefined_function)?0:1;
232 s->options=ctx->options; 295
233 s->mode=ctx->mode;
234 s->read_ahead=ctx->read_ahead; /* used to happen in SSL_clear */
235 SSL_clear(s); 296 SSL_clear(s);
236 297
237 CRYPTO_new_ex_data(ssl_meth,s,&s->ex_data); 298 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
238 299
239 return(s); 300 return(s);
240err: 301err:
@@ -278,45 +339,71 @@ int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
278 return 1; 339 return 1;
279 } 340 }
280 341
281int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) 342int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb)
282{ 343 {
283 if(X509_PURPOSE_get_by_id(purpose) == -1) { 344 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
284 SSLerr(SSL_F_SSL_CTX_SET_PURPOSE, SSL_R_INVALID_PURPOSE); 345 ctx->generate_session_id = cb;
285 return 0; 346 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
347 return 1;
286 } 348 }
287 s->purpose = purpose; 349
350int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB cb)
351 {
352 CRYPTO_w_lock(CRYPTO_LOCK_SSL);
353 ssl->generate_session_id = cb;
354 CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
288 return 1; 355 return 1;
289} 356 }
357
358int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
359 unsigned int id_len)
360 {
361 /* A quick examination of SSL_SESSION_hash and SSL_SESSION_cmp shows how
362 * we can "construct" a session to give us the desired check - ie. to
363 * find if there's a session in the hash table that would conflict with
364 * any new session built out of this id/id_len and the ssl_version in
365 * use by this SSL. */
366 SSL_SESSION r, *p;
367 r.ssl_version = ssl->version;
368 r.session_id_length = id_len;
369 memcpy(r.session_id, id, id_len);
370 /* NB: SSLv2 always uses a fixed 16-byte session ID, so even if a
371 * callback is calling us to check the uniqueness of a shorter ID, it
372 * must be compared as a padded-out ID because that is what it will be
373 * converted to when the callback has finished choosing it. */
374 if((r.ssl_version == SSL2_VERSION) &&
375 (id_len < SSL2_SSL_SESSION_ID_LENGTH))
376 {
377 memset(r.session_id + id_len, 0,
378 SSL2_SSL_SESSION_ID_LENGTH - id_len);
379 r.session_id_length = SSL2_SSL_SESSION_ID_LENGTH;
380 }
381
382 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
383 p = (SSL_SESSION *)lh_retrieve(ssl->ctx->sessions, &r);
384 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
385 return (p != NULL);
386 }
387
388int SSL_CTX_set_purpose(SSL_CTX *s, int purpose)
389 {
390 return X509_PURPOSE_set(&s->purpose, purpose);
391 }
290 392
291int SSL_set_purpose(SSL *s, int purpose) 393int SSL_set_purpose(SSL *s, int purpose)
292{ 394 {
293 if(X509_PURPOSE_get_by_id(purpose) == -1) { 395 return X509_PURPOSE_set(&s->purpose, purpose);
294 SSLerr(SSL_F_SSL_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
295 return 0;
296 } 396 }
297 s->purpose = purpose; 397
298 return 1;
299}
300
301int SSL_CTX_set_trust(SSL_CTX *s, int trust) 398int SSL_CTX_set_trust(SSL_CTX *s, int trust)
302{ 399 {
303 if(X509_TRUST_get_by_id(trust) == -1) { 400 return X509_TRUST_set(&s->trust, trust);
304 SSLerr(SSL_F_SSL_CTX_SET_TRUST, SSL_R_INVALID_TRUST);
305 return 0;
306 } 401 }
307 s->trust = trust;
308 return 1;
309}
310 402
311int SSL_set_trust(SSL *s, int trust) 403int SSL_set_trust(SSL *s, int trust)
312{ 404 {
313 if(X509_TRUST_get_by_id(trust) == -1) { 405 return X509_TRUST_set(&s->trust, trust);
314 SSLerr(SSL_F_SSL_SET_TRUST, SSL_R_INVALID_TRUST);
315 return 0;
316 } 406 }
317 s->trust = trust;
318 return 1;
319}
320 407
321void SSL_free(SSL *s) 408void SSL_free(SSL *s)
322 { 409 {
@@ -338,7 +425,7 @@ void SSL_free(SSL *s)
338 } 425 }
339#endif 426#endif
340 427
341 CRYPTO_free_ex_data(ssl_meth,(char *)s,&s->ex_data); 428 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
342 429
343 if (s->bbio != NULL) 430 if (s->bbio != NULL)
344 { 431 {
@@ -411,6 +498,11 @@ BIO *SSL_get_wbio(SSL *s)
411 498
412int SSL_get_fd(SSL *s) 499int SSL_get_fd(SSL *s)
413 { 500 {
501 return(SSL_get_rfd(s));
502 }
503
504int SSL_get_rfd(SSL *s)
505 {
414 int ret= -1; 506 int ret= -1;
415 BIO *b,*r; 507 BIO *b,*r;
416 508
@@ -421,7 +513,19 @@ int SSL_get_fd(SSL *s)
421 return(ret); 513 return(ret);
422 } 514 }
423 515
424#ifndef NO_SOCK 516int SSL_get_wfd(SSL *s)
517 {
518 int ret= -1;
519 BIO *b,*r;
520
521 b=SSL_get_wbio(s);
522 r=BIO_find_type(b,BIO_TYPE_DESCRIPTOR);
523 if (r != NULL)
524 BIO_get_fd(r,&ret);
525 return(ret);
526 }
527
528#ifndef OPENSSL_NO_SOCK
425int SSL_set_fd(SSL *s,int fd) 529int SSL_set_fd(SSL *s,int fd)
426 { 530 {
427 int ret=0; 531 int ret=0;
@@ -576,6 +680,13 @@ int SSL_get_read_ahead(SSL *s)
576 680
577int SSL_pending(SSL *s) 681int SSL_pending(SSL *s)
578 { 682 {
683 /* SSL_pending cannot work properly if read-ahead is enabled
684 * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)),
685 * and it is impossible to fix since SSL_pending cannot report
686 * errors that may be observed while scanning the new data.
687 * (Note that SSL_pending() is often used as a boolean value,
688 * so we'd better not return -1.)
689 */
579 return(s->method->ssl_pending(s)); 690 return(s->method->ssl_pending(s));
580 } 691 }
581 692
@@ -778,11 +889,21 @@ int SSL_shutdown(SSL *s)
778 889
779int SSL_renegotiate(SSL *s) 890int SSL_renegotiate(SSL *s)
780 { 891 {
781 s->new_session=1; 892 if (s->new_session == 0)
893 {
894 s->new_session=1;
895 }
782 return(s->method->ssl_renegotiate(s)); 896 return(s->method->ssl_renegotiate(s));
783 } 897 }
784 898
785long SSL_ctrl(SSL *s,int cmd,long larg,char *parg) 899int SSL_renegotiate_pending(SSL *s)
900 {
901 /* becomes true when negotiation is requested;
902 * false again once a handshake has finished */
903 return (s->new_session != 0);
904 }
905
906long SSL_ctrl(SSL *s,int cmd,long larg,void *parg)
786 { 907 {
787 long l; 908 long l;
788 909
@@ -794,10 +915,21 @@ long SSL_ctrl(SSL *s,int cmd,long larg,char *parg)
794 l=s->read_ahead; 915 l=s->read_ahead;
795 s->read_ahead=larg; 916 s->read_ahead=larg;
796 return(l); 917 return(l);
918
919 case SSL_CTRL_SET_MSG_CALLBACK_ARG:
920 s->msg_callback_arg = parg;
921 return 1;
922
797 case SSL_CTRL_OPTIONS: 923 case SSL_CTRL_OPTIONS:
798 return(s->options|=larg); 924 return(s->options|=larg);
799 case SSL_CTRL_MODE: 925 case SSL_CTRL_MODE:
800 return(s->mode|=larg); 926 return(s->mode|=larg);
927 case SSL_CTRL_GET_MAX_CERT_LIST:
928 return(s->max_cert_list);
929 case SSL_CTRL_SET_MAX_CERT_LIST:
930 l=s->max_cert_list;
931 s->max_cert_list=larg;
932 return(l);
801 default: 933 default:
802 return(s->method->ssl_ctrl(s,cmd,larg,parg)); 934 return(s->method->ssl_ctrl(s,cmd,larg,parg));
803 } 935 }
@@ -807,6 +939,10 @@ long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)())
807 { 939 {
808 switch(cmd) 940 switch(cmd)
809 { 941 {
942 case SSL_CTRL_SET_MSG_CALLBACK:
943 s->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp);
944 return 1;
945
810 default: 946 default:
811 return(s->method->ssl_callback_ctrl(s,cmd,fp)); 947 return(s->method->ssl_callback_ctrl(s,cmd,fp));
812 } 948 }
@@ -817,7 +953,7 @@ struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx)
817 return ctx->sessions; 953 return ctx->sessions;
818 } 954 }
819 955
820long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) 956long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,void *parg)
821 { 957 {
822 long l; 958 long l;
823 959
@@ -829,6 +965,17 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
829 l=ctx->read_ahead; 965 l=ctx->read_ahead;
830 ctx->read_ahead=larg; 966 ctx->read_ahead=larg;
831 return(l); 967 return(l);
968
969 case SSL_CTRL_SET_MSG_CALLBACK_ARG:
970 ctx->msg_callback_arg = parg;
971 return 1;
972
973 case SSL_CTRL_GET_MAX_CERT_LIST:
974 return(ctx->max_cert_list);
975 case SSL_CTRL_SET_MAX_CERT_LIST:
976 l=ctx->max_cert_list;
977 ctx->max_cert_list=larg;
978 return(l);
832 979
833 case SSL_CTRL_SET_SESS_CACHE_SIZE: 980 case SSL_CTRL_SET_SESS_CACHE_SIZE:
834 l=ctx->session_cache_size; 981 l=ctx->session_cache_size;
@@ -880,6 +1027,10 @@ long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
880 { 1027 {
881 switch(cmd) 1028 switch(cmd)
882 { 1029 {
1030 case SSL_CTRL_SET_MSG_CALLBACK:
1031 ctx->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp);
1032 return 1;
1033
883 default: 1034 default:
884 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp)); 1035 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp));
885 } 1036 }
@@ -1018,6 +1169,9 @@ int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p)
1018 int i,j=0; 1169 int i,j=0;
1019 SSL_CIPHER *c; 1170 SSL_CIPHER *c;
1020 unsigned char *q; 1171 unsigned char *q;
1172#ifndef OPENSSL_NO_KRB5
1173 int nokrb5 = !kssl_tgt_is_available(s->kssl_ctx);
1174#endif /* OPENSSL_NO_KRB5 */
1021 1175
1022 if (sk == NULL) return(0); 1176 if (sk == NULL) return(0);
1023 q=p; 1177 q=p;
@@ -1025,6 +1179,10 @@ int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p)
1025 for (i=0; i<sk_SSL_CIPHER_num(sk); i++) 1179 for (i=0; i<sk_SSL_CIPHER_num(sk); i++)
1026 { 1180 {
1027 c=sk_SSL_CIPHER_value(sk,i); 1181 c=sk_SSL_CIPHER_value(sk,i);
1182#ifndef OPENSSL_NO_KRB5
1183 if ((c->algorithms & SSL_KRB5) && nokrb5)
1184 continue;
1185#endif /* OPENSSL_NO_KRB5 */
1028 j=ssl_put_cipher_by_char(s,c,p); 1186 j=ssl_put_cipher_by_char(s,c,p);
1029 p+=j; 1187 p+=j;
1030 } 1188 }
@@ -1087,6 +1245,11 @@ unsigned long SSL_SESSION_hash(SSL_SESSION *a)
1087 return(l); 1245 return(l);
1088 } 1246 }
1089 1247
1248/* NB: If this function (or indeed the hash function which uses a sort of
1249 * coarser function than this one) is changed, ensure
1250 * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being
1251 * able to construct an SSL_SESSION that will collide with any existing session
1252 * with a matching session ID. */
1090int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b) 1253int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
1091 { 1254 {
1092 if (a->ssl_version != b->ssl_version) 1255 if (a->ssl_version != b->ssl_version)
@@ -1096,6 +1259,13 @@ int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
1096 return(memcmp(a->session_id,b->session_id,a->session_id_length)); 1259 return(memcmp(a->session_id,b->session_id,a->session_id_length));
1097 } 1260 }
1098 1261
1262/* These wrapper functions should remain rather than redeclaring
1263 * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each
1264 * variable. The reason is that the functions aren't static, they're exposed via
1265 * ssl.h. */
1266static IMPLEMENT_LHASH_HASH_FN(SSL_SESSION_hash, SSL_SESSION *)
1267static IMPLEMENT_LHASH_COMP_FN(SSL_SESSION_cmp, SSL_SESSION *)
1268
1099SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) 1269SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1100 { 1270 {
1101 SSL_CTX *ret=NULL; 1271 SSL_CTX *ret=NULL;
@@ -1128,9 +1298,10 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1128 /* We take the system default */ 1298 /* We take the system default */
1129 ret->session_timeout=meth->get_timeout(); 1299 ret->session_timeout=meth->get_timeout();
1130 1300
1131 ret->new_session_cb=NULL; 1301 ret->new_session_cb=0;
1132 ret->remove_session_cb=NULL; 1302 ret->remove_session_cb=0;
1133 ret->get_session_cb=NULL; 1303 ret->get_session_cb=0;
1304 ret->generate_session_id=0;
1134 1305
1135 memset((char *)&ret->stats,0,sizeof(ret->stats)); 1306 memset((char *)&ret->stats,0,sizeof(ret->stats));
1136 1307
@@ -1145,21 +1316,26 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1145 1316
1146 ret->info_callback=NULL; 1317 ret->info_callback=NULL;
1147 1318
1148 ret->app_verify_callback=NULL; 1319 ret->app_verify_callback=0;
1149 ret->app_verify_arg=NULL; 1320 ret->app_verify_arg=NULL;
1150 1321
1322 ret->max_cert_list=SSL_MAX_CERT_LIST_DEFAULT;
1151 ret->read_ahead=0; 1323 ret->read_ahead=0;
1324 ret->msg_callback=0;
1325 ret->msg_callback_arg=NULL;
1152 ret->verify_mode=SSL_VERIFY_NONE; 1326 ret->verify_mode=SSL_VERIFY_NONE;
1153 ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ 1327 ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */
1328 ret->sid_ctx_length=0;
1154 ret->default_verify_callback=NULL; 1329 ret->default_verify_callback=NULL;
1155 if ((ret->cert=ssl_cert_new()) == NULL) 1330 if ((ret->cert=ssl_cert_new()) == NULL)
1156 goto err; 1331 goto err;
1157 1332
1158 ret->default_passwd_callback=NULL; 1333 ret->default_passwd_callback=0;
1159 ret->default_passwd_callback_userdata=NULL; 1334 ret->default_passwd_callback_userdata=NULL;
1160 ret->client_cert_cb=NULL; 1335 ret->client_cert_cb=0;
1161 1336
1162 ret->sessions=lh_new(SSL_SESSION_hash,SSL_SESSION_cmp); 1337 ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash),
1338 LHASH_COMP_FN(SSL_SESSION_cmp));
1163 if (ret->sessions == NULL) goto err; 1339 if (ret->sessions == NULL) goto err;
1164 ret->cert_store=X509_STORE_new(); 1340 ret->cert_store=X509_STORE_new();
1165 if (ret->cert_store == NULL) goto err; 1341 if (ret->cert_store == NULL) goto err;
@@ -1193,7 +1369,7 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1193 if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL) 1369 if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL)
1194 goto err; 1370 goto err;
1195 1371
1196 CRYPTO_new_ex_data(ssl_ctx_meth,(char *)ret,&ret->ex_data); 1372 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data);
1197 1373
1198 ret->extra_certs=NULL; 1374 ret->extra_certs=NULL;
1199 ret->comp_methods=SSL_COMP_get_compression_methods(); 1375 ret->comp_methods=SSL_COMP_get_compression_methods();
@@ -1206,8 +1382,10 @@ err2:
1206 return(NULL); 1382 return(NULL);
1207 } 1383 }
1208 1384
1385#if 0
1209static void SSL_COMP_free(SSL_COMP *comp) 1386static void SSL_COMP_free(SSL_COMP *comp)
1210 { OPENSSL_free(comp); } 1387 { OPENSSL_free(comp); }
1388#endif
1211 1389
1212void SSL_CTX_free(SSL_CTX *a) 1390void SSL_CTX_free(SSL_CTX *a)
1213 { 1391 {
@@ -1227,7 +1405,7 @@ void SSL_CTX_free(SSL_CTX *a)
1227 abort(); /* ok */ 1405 abort(); /* ok */
1228 } 1406 }
1229#endif 1407#endif
1230 CRYPTO_free_ex_data(ssl_ctx_meth,(char *)a,&a->ex_data); 1408 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);
1231 1409
1232 if (a->sessions != NULL) 1410 if (a->sessions != NULL)
1233 { 1411 {
@@ -1246,8 +1424,12 @@ void SSL_CTX_free(SSL_CTX *a)
1246 sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free); 1424 sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free);
1247 if (a->extra_certs != NULL) 1425 if (a->extra_certs != NULL)
1248 sk_X509_pop_free(a->extra_certs,X509_free); 1426 sk_X509_pop_free(a->extra_certs,X509_free);
1427#if 0 /* This should never be done, since it removes a global database */
1249 if (a->comp_methods != NULL) 1428 if (a->comp_methods != NULL)
1250 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free); 1429 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);
1430#else
1431 a->comp_methods = NULL;
1432#endif
1251 OPENSSL_free(a); 1433 OPENSSL_free(a);
1252 } 1434 }
1253 1435
@@ -1261,23 +1443,16 @@ void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx,void *u)
1261 ctx->default_passwd_callback_userdata=u; 1443 ctx->default_passwd_callback_userdata=u;
1262 } 1444 }
1263 1445
1264void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,int (*cb)(),char *arg) 1446void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg)
1265 { 1447 {
1266 /* now
1267 * int (*cb)(X509_STORE_CTX *),
1268 * but should be
1269 * int (*cb)(X509_STORE_CTX *, void *arg)
1270 */
1271 ctx->app_verify_callback=cb; 1448 ctx->app_verify_callback=cb;
1272 ctx->app_verify_arg=arg; /* never used */ 1449 ctx->app_verify_arg=arg;
1273 } 1450 }
1274 1451
1275void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *)) 1452void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *))
1276 { 1453 {
1277 ctx->verify_mode=mode; 1454 ctx->verify_mode=mode;
1278 ctx->default_verify_callback=cb; 1455 ctx->default_verify_callback=cb;
1279 /* This needs cleaning up EAY EAY EAY */
1280 X509_STORE_set_verify_cb_func(ctx->cert_store,cb);
1281 } 1456 }
1282 1457
1283void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) 1458void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth)
@@ -1297,14 +1472,14 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1297 1472
1298 kl=SSL_C_EXPORT_PKEYLENGTH(cipher); 1473 kl=SSL_C_EXPORT_PKEYLENGTH(cipher);
1299 1474
1300#ifndef NO_RSA 1475#ifndef OPENSSL_NO_RSA
1301 rsa_tmp=(c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL); 1476 rsa_tmp=(c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL);
1302 rsa_tmp_export=(c->rsa_tmp_cb != NULL || 1477 rsa_tmp_export=(c->rsa_tmp_cb != NULL ||
1303 (rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl)); 1478 (rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl));
1304#else 1479#else
1305 rsa_tmp=rsa_tmp_export=0; 1480 rsa_tmp=rsa_tmp_export=0;
1306#endif 1481#endif
1307#ifndef NO_DH 1482#ifndef OPENSSL_NO_DH
1308 dh_tmp=(c->dh_tmp != NULL || c->dh_tmp_cb != NULL); 1483 dh_tmp=(c->dh_tmp != NULL || c->dh_tmp_cb != NULL);
1309 dh_tmp_export=(c->dh_tmp_cb != NULL || 1484 dh_tmp_export=(c->dh_tmp_cb != NULL ||
1310 (dh_tmp && DH_size(c->dh_tmp)*8 <= kl)); 1485 (dh_tmp && DH_size(c->dh_tmp)*8 <= kl));
@@ -1378,6 +1553,11 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1378 mask|=SSL_aNULL; 1553 mask|=SSL_aNULL;
1379 emask|=SSL_aNULL; 1554 emask|=SSL_aNULL;
1380 1555
1556#ifndef OPENSSL_NO_KRB5
1557 mask|=SSL_kKRB5|SSL_aKRB5;
1558 emask|=SSL_kKRB5|SSL_aKRB5;
1559#endif
1560
1381 c->mask=mask; 1561 c->mask=mask;
1382 c->export_mask=emask; 1562 c->export_mask=emask;
1383 c->valid=1; 1563 c->valid=1;
@@ -1410,9 +1590,14 @@ X509 *ssl_get_server_send_cert(SSL *s)
1410 else 1590 else
1411 i=SSL_PKEY_RSA_ENC; 1591 i=SSL_PKEY_RSA_ENC;
1412 } 1592 }
1593 else if (kalg & SSL_aKRB5)
1594 {
1595 /* VRS something else here? */
1596 return(NULL);
1597 }
1413 else /* if (kalg & SSL_aNULL) */ 1598 else /* if (kalg & SSL_aNULL) */
1414 { 1599 {
1415 SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,SSL_R_INTERNAL_ERROR); 1600 SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,ERR_R_INTERNAL_ERROR);
1416 return(NULL); 1601 return(NULL);
1417 } 1602 }
1418 if (c->pkeys[i].x509 == NULL) return(NULL); 1603 if (c->pkeys[i].x509 == NULL) return(NULL);
@@ -1441,7 +1626,7 @@ EVP_PKEY *ssl_get_sign_pkey(SSL *s,SSL_CIPHER *cipher)
1441 } 1626 }
1442 else /* if (alg & SSL_aNULL) */ 1627 else /* if (alg & SSL_aNULL) */
1443 { 1628 {
1444 SSLerr(SSL_F_SSL_GET_SIGN_PKEY,SSL_R_INTERNAL_ERROR); 1629 SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR);
1445 return(NULL); 1630 return(NULL);
1446 } 1631 }
1447 } 1632 }
@@ -1454,9 +1639,10 @@ void ssl_update_cache(SSL *s,int mode)
1454 * and it would be rather hard to do anyway :-) */ 1639 * and it would be rather hard to do anyway :-) */
1455 if (s->session->session_id_length == 0) return; 1640 if (s->session->session_id_length == 0) return;
1456 1641
1457 if ((s->ctx->session_cache_mode & mode) 1642 i=s->ctx->session_cache_mode;
1458 && (!s->hit) 1643 if ((i & mode) && (!s->hit)
1459 && SSL_CTX_add_session(s->ctx,s->session) 1644 && ((i & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)
1645 || SSL_CTX_add_session(s->ctx,s->session))
1460 && (s->ctx->new_session_cb != NULL)) 1646 && (s->ctx->new_session_cb != NULL))
1461 { 1647 {
1462 CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION); 1648 CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION);
@@ -1465,7 +1651,6 @@ void ssl_update_cache(SSL *s,int mode)
1465 } 1651 }
1466 1652
1467 /* auto flush every 255 connections */ 1653 /* auto flush every 255 connections */
1468 i=s->ctx->session_cache_mode;
1469 if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) && 1654 if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) &&
1470 ((i & mode) == mode)) 1655 ((i & mode) == mode))
1471 { 1656 {
@@ -1549,6 +1734,8 @@ int SSL_get_error(SSL *s,int i)
1549 reason=BIO_get_retry_reason(bio); 1734 reason=BIO_get_retry_reason(bio);
1550 if (reason == BIO_RR_CONNECT) 1735 if (reason == BIO_RR_CONNECT)
1551 return(SSL_ERROR_WANT_CONNECT); 1736 return(SSL_ERROR_WANT_CONNECT);
1737 else if (reason == BIO_RR_ACCEPT)
1738 return(SSL_ERROR_WANT_ACCEPT);
1552 else 1739 else
1553 return(SSL_ERROR_SYSCALL); /* unknown */ 1740 return(SSL_ERROR_SYSCALL); /* unknown */
1554 } 1741 }
@@ -1567,6 +1754,8 @@ int SSL_get_error(SSL *s,int i)
1567 reason=BIO_get_retry_reason(bio); 1754 reason=BIO_get_retry_reason(bio);
1568 if (reason == BIO_RR_CONNECT) 1755 if (reason == BIO_RR_CONNECT)
1569 return(SSL_ERROR_WANT_CONNECT); 1756 return(SSL_ERROR_WANT_CONNECT);
1757 else if (reason == BIO_RR_ACCEPT)
1758 return(SSL_ERROR_WANT_ACCEPT);
1570 else 1759 else
1571 return(SSL_ERROR_SYSCALL); 1760 return(SSL_ERROR_SYSCALL);
1572 } 1761 }
@@ -1667,7 +1856,11 @@ SSL *SSL_dup(SSL *s)
1667 1856
1668 if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL) 1857 if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL)
1669 return(NULL); 1858 return(NULL);
1670 1859
1860 ret->version = s->version;
1861 ret->type = s->type;
1862 ret->method = s->method;
1863
1671 if (s->session != NULL) 1864 if (s->session != NULL)
1672 { 1865 {
1673 /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ 1866 /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */
@@ -1698,18 +1891,23 @@ SSL *SSL_dup(SSL *s)
1698 s->sid_ctx, s->sid_ctx_length); 1891 s->sid_ctx, s->sid_ctx_length);
1699 } 1892 }
1700 1893
1894 ret->options=s->options;
1895 ret->mode=s->mode;
1896 SSL_set_max_cert_list(ret,SSL_get_max_cert_list(s));
1701 SSL_set_read_ahead(ret,SSL_get_read_ahead(s)); 1897 SSL_set_read_ahead(ret,SSL_get_read_ahead(s));
1898 ret->msg_callback = s->msg_callback;
1899 ret->msg_callback_arg = s->msg_callback_arg;
1702 SSL_set_verify(ret,SSL_get_verify_mode(s), 1900 SSL_set_verify(ret,SSL_get_verify_mode(s),
1703 SSL_get_verify_callback(s)); 1901 SSL_get_verify_callback(s));
1704 SSL_set_verify_depth(ret,SSL_get_verify_depth(s)); 1902 SSL_set_verify_depth(ret,SSL_get_verify_depth(s));
1903 ret->generate_session_id = s->generate_session_id;
1705 1904
1706 SSL_set_info_callback(ret,SSL_get_info_callback(s)); 1905 SSL_set_info_callback(ret,SSL_get_info_callback(s));
1707 1906
1708 ret->debug=s->debug; 1907 ret->debug=s->debug;
1709 ret->options=s->options;
1710 1908
1711 /* copy app data, a little dangerous perhaps */ 1909 /* copy app data, a little dangerous perhaps */
1712 if (!CRYPTO_dup_ex_data(ssl_meth,&ret->ex_data,&s->ex_data)) 1910 if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, &ret->ex_data, &s->ex_data))
1713 goto err; 1911 goto err;
1714 1912
1715 /* setup rbio, and wbio */ 1913 /* setup rbio, and wbio */
@@ -1728,6 +1926,19 @@ SSL *SSL_dup(SSL *s)
1728 else 1926 else
1729 ret->wbio=ret->rbio; 1927 ret->wbio=ret->rbio;
1730 } 1928 }
1929 ret->rwstate = s->rwstate;
1930 ret->in_handshake = s->in_handshake;
1931 ret->handshake_func = s->handshake_func;
1932 ret->server = s->server;
1933 ret->new_session = s->new_session;
1934 ret->quiet_shutdown = s->quiet_shutdown;
1935 ret->shutdown=s->shutdown;
1936 ret->state=s->state; /* SSL_dup does not really work at any state, though */
1937 ret->rstate=s->rstate;
1938 ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */
1939 ret->hit=s->hit;
1940 ret->purpose=s->purpose;
1941 ret->trust=s->trust;
1731 1942
1732 /* dup the cipher_list and cipher_list_by_id stacks */ 1943 /* dup the cipher_list and cipher_list_by_id stacks */
1733 if (s->cipher_list != NULL) 1944 if (s->cipher_list != NULL)
@@ -1756,11 +1967,6 @@ SSL *SSL_dup(SSL *s)
1756 } 1967 }
1757 } 1968 }
1758 1969
1759 ret->shutdown=s->shutdown;
1760 ret->state=s->state;
1761 ret->handshake_func=s->handshake_func;
1762 ret->server=s->server;
1763
1764 if (0) 1970 if (0)
1765 { 1971 {
1766err: 1972err:
@@ -1913,7 +2119,7 @@ SSL_CTX *SSL_get_SSL_CTX(SSL *ssl)
1913 return(ssl->ctx); 2119 return(ssl->ctx);
1914 } 2120 }
1915 2121
1916#ifndef NO_STDIO 2122#ifndef OPENSSL_NO_STDIO
1917int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) 2123int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
1918 { 2124 {
1919 return(X509_STORE_set_default_paths(ctx->cert_store)); 2125 return(X509_STORE_set_default_paths(ctx->cert_store));
@@ -1926,14 +2132,15 @@ int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1926 } 2132 }
1927#endif 2133#endif
1928 2134
1929void SSL_set_info_callback(SSL *ssl,void (*cb)()) 2135void SSL_set_info_callback(SSL *ssl,
2136 void (*cb)(const SSL *ssl,int type,int val))
1930 { 2137 {
1931 ssl->info_callback=cb; 2138 ssl->info_callback=cb;
1932 } 2139 }
1933 2140
1934void (*SSL_get_info_callback(SSL *ssl))(void) 2141void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val)
1935 { 2142 {
1936 return((void (*)())ssl->info_callback); 2143 return ssl->info_callback;
1937 } 2144 }
1938 2145
1939int SSL_state(SSL *ssl) 2146int SSL_state(SSL *ssl)
@@ -1954,9 +2161,8 @@ long SSL_get_verify_result(SSL *ssl)
1954int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, 2161int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1955 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) 2162 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1956 { 2163 {
1957 ssl_meth_num++; 2164 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, argl, argp,
1958 return(CRYPTO_get_ex_new_index(ssl_meth_num-1, 2165 new_func, dup_func, free_func);
1959 &ssl_meth,argl,argp,new_func,dup_func,free_func));
1960 } 2166 }
1961 2167
1962int SSL_set_ex_data(SSL *s,int idx,void *arg) 2168int SSL_set_ex_data(SSL *s,int idx,void *arg)
@@ -1972,9 +2178,8 @@ void *SSL_get_ex_data(SSL *s,int idx)
1972int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, 2178int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1973 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) 2179 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1974 { 2180 {
1975 ssl_ctx_meth_num++; 2181 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, argl, argp,
1976 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1, 2182 new_func, dup_func, free_func);
1977 &ssl_ctx_meth,argl,argp,new_func,dup_func,free_func));
1978 } 2183 }
1979 2184
1980int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg) 2185int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg)
@@ -2015,7 +2220,7 @@ int SSL_want(SSL *s)
2015 * \param cb the callback 2220 * \param cb the callback
2016 */ 2221 */
2017 2222
2018#ifndef NO_RSA 2223#ifndef OPENSSL_NO_RSA
2019void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, 2224void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl,
2020 int is_export, 2225 int is_export,
2021 int keylength)) 2226 int keylength))
@@ -2052,21 +2257,33 @@ RSA *cb(SSL *ssl,int is_export,int keylength)
2052 * \param dh the callback 2257 * \param dh the callback
2053 */ 2258 */
2054 2259
2055#ifndef NO_DH 2260#ifndef OPENSSL_NO_DH
2056void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, 2261void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export,
2057 int keylength)) 2262 int keylength))
2058 { 2263 {
2059 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); 2264 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2060 } 2265 }
2061 2266
2062void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, 2267void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export,
2063 int keylength)) 2268 int keylength))
2064 { 2269 {
2065 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); 2270 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2066 } 2271 }
2067#endif 2272#endif
2068 2273
2069#if defined(_WINDLL) && defined(WIN16) 2274
2275void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))
2276 {
2277 SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb);
2278 }
2279void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))
2280 {
2281 SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb);
2282 }
2283
2284
2285
2286#if defined(_WINDLL) && defined(OPENSSL_SYS_WIN16)
2070#include "../crypto/bio/bss_file.c" 2287#include "../crypto/bio/bss_file.c"
2071#endif 2288#endif
2072 2289
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h
index 516d3cc5ae..5208c4c42a 100644
--- a/src/lib/libssl/src/ssl/ssl_locl.h
+++ b/src/lib/libssl/src/ssl/ssl_locl.h
@@ -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
@@ -116,7 +116,7 @@
116#include <string.h> 116#include <string.h>
117#include <errno.h> 117#include <errno.h>
118 118
119#include "openssl/e_os.h" 119#include <e_os.h>
120 120
121#include <openssl/buffer.h> 121#include <openssl/buffer.h>
122#include <openssl/comp.h> 122#include <openssl/comp.h>
@@ -127,6 +127,12 @@
127#include <openssl/x509.h> 127#include <openssl/x509.h>
128#include <openssl/err.h> 128#include <openssl/err.h>
129#include <openssl/ssl.h> 129#include <openssl/ssl.h>
130#include <openssl/symhacks.h>
131
132#ifdef OPENSSL_BUILD_SHLIBSSL
133# undef OPENSSL_EXTERN
134# define OPENSSL_EXTERN OPENSSL_EXPORT
135#endif
130 136
131#define PKCS1_CHECK 137#define PKCS1_CHECK
132 138
@@ -221,48 +227,52 @@
221 * that the different entities within are mutually exclusive: 227 * that the different entities within are mutually exclusive:
222 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. 228 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
223 */ 229 */
224#define SSL_MKEY_MASK 0x0000001FL 230#define SSL_MKEY_MASK 0x0000003FL
225#define SSL_kRSA 0x00000001L /* RSA key exchange */ 231#define SSL_kRSA 0x00000001L /* RSA key exchange */
226#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ 232#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */
227#define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */ 233#define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */
228#define SSL_kFZA 0x00000008L 234#define SSL_kFZA 0x00000008L
229#define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */ 235#define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */
236#define SSL_kKRB5 0x00000020L /* Kerberos5 key exchange */
230#define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL)) 237#define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL))
231 238
232#define SSL_AUTH_MASK 0x000003e0L 239#define SSL_AUTH_MASK 0x00000FC0L
233#define SSL_aRSA 0x00000020L /* Authenticate with RSA */ 240#define SSL_aRSA 0x00000040L /* Authenticate with RSA */
234#define SSL_aDSS 0x00000040L /* Authenticate with DSS */ 241#define SSL_aDSS 0x00000080L /* Authenticate with DSS */
235#define SSL_DSS SSL_aDSS 242#define SSL_DSS SSL_aDSS
236#define SSL_aFZA 0x00000080L 243#define SSL_aFZA 0x00000100L
237#define SSL_aNULL 0x00000100L /* no Authenticate, ADH */ 244#define SSL_aNULL 0x00000200L /* no Authenticate, ADH */
238#define SSL_aDH 0x00000200L /* no Authenticate, ADH */ 245#define SSL_aDH 0x00000400L /* no Authenticate, ADH */
246#define SSL_aKRB5 0x00000800L /* Authenticate with KRB5 */
239 247
240#define SSL_NULL (SSL_eNULL) 248#define SSL_NULL (SSL_eNULL)
241#define SSL_ADH (SSL_kEDH|SSL_aNULL) 249#define SSL_ADH (SSL_kEDH|SSL_aNULL)
242#define SSL_RSA (SSL_kRSA|SSL_aRSA) 250#define SSL_RSA (SSL_kRSA|SSL_aRSA)
243#define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH) 251#define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH)
244#define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA) 252#define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA)
245 253#define SSL_KRB5 (SSL_kKRB5|SSL_aKRB5)
246#define SSL_ENC_MASK 0x0001Fc00L 254
247#define SSL_DES 0x00000400L 255#define SSL_ENC_MASK 0x0087F000L
248#define SSL_3DES 0x00000800L 256#define SSL_DES 0x00001000L
249#define SSL_RC4 0x00001000L 257#define SSL_3DES 0x00002000L
250#define SSL_RC2 0x00002000L 258#define SSL_RC4 0x00004000L
251#define SSL_IDEA 0x00004000L 259#define SSL_RC2 0x00008000L
252#define SSL_eFZA 0x00008000L 260#define SSL_IDEA 0x00010000L
253#define SSL_eNULL 0x00010000L 261#define SSL_eFZA 0x00020000L
254 262#define SSL_eNULL 0x00040000L
255#define SSL_MAC_MASK 0x00060000L 263#define SSL_AES 0x00800000L
256#define SSL_MD5 0x00020000L 264
257#define SSL_SHA1 0x00040000L 265#define SSL_MAC_MASK 0x00180000L
266#define SSL_MD5 0x00080000L
267#define SSL_SHA1 0x00100000L
258#define SSL_SHA (SSL_SHA1) 268#define SSL_SHA (SSL_SHA1)
259 269
260#define SSL_SSL_MASK 0x00180000L 270#define SSL_SSL_MASK 0x00600000L
261#define SSL_SSLV2 0x00080000L 271#define SSL_SSLV2 0x00200000L
262#define SSL_SSLV3 0x00100000L 272#define SSL_SSLV3 0x00400000L
263#define SSL_TLSV1 SSL_SSLV3 /* for now */ 273#define SSL_TLSV1 SSL_SSLV3 /* for now */
264 274
265/* we have used 001fffff - 11 bits left to go */ 275/* we have used 007fffff - 9 bits left to go */
266 276
267/* 277/*
268 * Export and cipher strength information. For each cipher we have to decide 278 * Export and cipher strength information. For each cipher we have to decide
@@ -367,11 +377,11 @@ typedef struct cert_st
367 int valid; 377 int valid;
368 unsigned long mask; 378 unsigned long mask;
369 unsigned long export_mask; 379 unsigned long export_mask;
370#ifndef NO_RSA 380#ifndef OPENSSL_NO_RSA
371 RSA *rsa_tmp; 381 RSA *rsa_tmp;
372 RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize); 382 RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize);
373#endif 383#endif
374#ifndef NO_DH 384#ifndef OPENSSL_NO_DH
375 DH *dh_tmp; 385 DH *dh_tmp;
376 DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize); 386 DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize);
377#endif 387#endif
@@ -394,10 +404,10 @@ typedef struct sess_cert_st
394 /* Obviously we don't have the private keys of these, 404 /* Obviously we don't have the private keys of these,
395 * so maybe we shouldn't even use the CERT_PKEY type here. */ 405 * so maybe we shouldn't even use the CERT_PKEY type here. */
396 406
397#ifndef NO_RSA 407#ifndef OPENSSL_NO_RSA
398 RSA *peer_rsa_tmp; /* not used for SSL 2 */ 408 RSA *peer_rsa_tmp; /* not used for SSL 2 */
399#endif 409#endif
400#ifndef NO_DH 410#ifndef OPENSSL_NO_DH
401 DH *peer_dh_tmp; /* not used for SSL 2 */ 411 DH *peer_dh_tmp; /* not used for SSL 2 */
402#endif 412#endif
403 413
@@ -454,9 +464,9 @@ OPENSSL_EXTERN SSL3_ENC_METHOD ssl3_undef_enc_method;
454OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[]; 464OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[];
455OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[]; 465OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[];
456 466
457#ifdef VMS 467#ifdef OPENSSL_SYS_VMS
458#undef SSL_COMP_get_compression_methods 468#undef SSL_COMP_get_compression_methods
459#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods 469#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
460#endif 470#endif
461 471
462 472
@@ -520,8 +530,8 @@ int ssl2_peek(SSL *s, void *buf, int len);
520int ssl2_write(SSL *s, const void *buf, int len); 530int ssl2_write(SSL *s, const void *buf, int len);
521int ssl2_shutdown(SSL *s); 531int ssl2_shutdown(SSL *s);
522void ssl2_clear(SSL *s); 532void ssl2_clear(SSL *s);
523long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg); 533long ssl2_ctrl(SSL *s,int cmd, long larg, void *parg);
524long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 534long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
525long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)()); 535long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)());
526long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); 536long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
527int ssl2_pending(SSL *s); 537int ssl2_pending(SSL *s);
@@ -556,8 +566,8 @@ void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
556int ssl3_enc(SSL *s, int send_data); 566int ssl3_enc(SSL *s, int send_data);
557int ssl3_mac(SSL *ssl, unsigned char *md, int send_data); 567int ssl3_mac(SSL *ssl, unsigned char *md, int send_data);
558unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); 568unsigned long ssl3_output_cert_chain(SSL *s, X509 *x);
559SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *have, 569SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *clnt,
560 STACK_OF(SSL_CIPHER) *pref); 570 STACK_OF(SSL_CIPHER) *srvr);
561int ssl3_setup_buffers(SSL *s); 571int ssl3_setup_buffers(SSL *s);
562int ssl3_new(SSL *s); 572int ssl3_new(SSL *s);
563void ssl3_free(SSL *s); 573void ssl3_free(SSL *s);
@@ -568,8 +578,8 @@ int ssl3_peek(SSL *s, void *buf, int len);
568int ssl3_write(SSL *s, const void *buf, int len); 578int ssl3_write(SSL *s, const void *buf, int len);
569int ssl3_shutdown(SSL *s); 579int ssl3_shutdown(SSL *s);
570void ssl3_clear(SSL *s); 580void ssl3_clear(SSL *s);
571long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg); 581long ssl3_ctrl(SSL *s,int cmd, long larg, void *parg);
572long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 582long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
573long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)()); 583long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)());
574long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); 584long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
575int ssl3_pending(SSL *s); 585int ssl3_pending(SSL *s);
@@ -582,7 +592,7 @@ int ssl23_write_bytes(SSL *s);
582int tls1_new(SSL *s); 592int tls1_new(SSL *s);
583void tls1_free(SSL *s); 593void tls1_free(SSL *s);
584void tls1_clear(SSL *s); 594void tls1_clear(SSL *s);
585long tls1_ctrl(SSL *s,int cmd, long larg, char *parg); 595long tls1_ctrl(SSL *s,int cmd, long larg, void *parg);
586long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)()); 596long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)());
587SSL_METHOD *tlsv1_base_method(void ); 597SSL_METHOD *tlsv1_base_method(void );
588 598
diff --git a/src/lib/libssl/src/ssl/ssl_rsa.c b/src/lib/libssl/src/ssl/ssl_rsa.c
index 6ec7a5cdb1..1cf8e20934 100644
--- a/src/lib/libssl/src/ssl/ssl_rsa.c
+++ b/src/lib/libssl/src/ssl/ssl_rsa.c
@@ -81,7 +81,7 @@ int SSL_use_certificate(SSL *ssl, X509 *x)
81 return(ssl_set_cert(ssl->cert,x)); 81 return(ssl_set_cert(ssl->cert,x));
82 } 82 }
83 83
84#ifndef NO_STDIO 84#ifndef OPENSSL_NO_STDIO
85int SSL_use_certificate_file(SSL *ssl, const char *file, int type) 85int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
86 { 86 {
87 int j; 87 int j;
@@ -148,7 +148,7 @@ int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len)
148 return(ret); 148 return(ret);
149 } 149 }
150 150
151#ifndef NO_RSA 151#ifndef OPENSSL_NO_RSA
152int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) 152int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
153 { 153 {
154 EVP_PKEY *pkey; 154 EVP_PKEY *pkey;
@@ -170,7 +170,7 @@ int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
170 return(0); 170 return(0);
171 } 171 }
172 172
173 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 173 RSA_up_ref(rsa);
174 EVP_PKEY_assign_RSA(pkey,rsa); 174 EVP_PKEY_assign_RSA(pkey,rsa);
175 175
176 ret=ssl_set_pkey(ssl->cert,pkey); 176 ret=ssl_set_pkey(ssl->cert,pkey);
@@ -198,7 +198,7 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
198 EVP_PKEY_free(pktmp); 198 EVP_PKEY_free(pktmp);
199 ERR_clear_error(); 199 ERR_clear_error();
200 200
201#ifndef NO_RSA 201#ifndef OPENSSL_NO_RSA
202 /* Don't check the public/private key, this is mostly 202 /* Don't check the public/private key, this is mostly
203 * for smart cards. */ 203 * for smart cards. */
204 if ((pkey->type == EVP_PKEY_RSA) && 204 if ((pkey->type == EVP_PKEY_RSA) &&
@@ -251,8 +251,8 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
251 return(1); 251 return(1);
252 } 252 }
253 253
254#ifndef NO_RSA 254#ifndef OPENSSL_NO_RSA
255#ifndef NO_STDIO 255#ifndef OPENSSL_NO_STDIO
256int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) 256int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
257 { 257 {
258 int j,ret=0; 258 int j,ret=0;
@@ -303,7 +303,7 @@ end:
303int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len) 303int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len)
304 { 304 {
305 int ret; 305 int ret;
306 unsigned char *p; 306 const unsigned char *p;
307 RSA *rsa; 307 RSA *rsa;
308 308
309 p=d; 309 p=d;
@@ -317,7 +317,7 @@ int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len)
317 RSA_free(rsa); 317 RSA_free(rsa);
318 return(ret); 318 return(ret);
319 } 319 }
320#endif /* !NO_RSA */ 320#endif /* !OPENSSL_NO_RSA */
321 321
322int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) 322int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
323 { 323 {
@@ -337,7 +337,7 @@ int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
337 return(ret); 337 return(ret);
338 } 338 }
339 339
340#ifndef NO_STDIO 340#ifndef OPENSSL_NO_STDIO
341int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) 341int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type)
342 { 342 {
343 int j,ret=0; 343 int j,ret=0;
@@ -438,7 +438,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
438 EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey); 438 EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey);
439 ERR_clear_error(); 439 ERR_clear_error();
440 440
441#ifndef NO_RSA 441#ifndef OPENSSL_NO_RSA
442 /* Don't check the public/private key, this is mostly 442 /* Don't check the public/private key, this is mostly
443 * for smart cards. */ 443 * for smart cards. */
444 if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) && 444 if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) &&
@@ -471,7 +471,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
471 } 471 }
472 else 472 else
473 ok=1; 473 ok=1;
474 } /* NO_RSA */ 474 } /* OPENSSL_NO_RSA */
475 } 475 }
476 else 476 else
477 ok=1; 477 ok=1;
@@ -493,7 +493,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
493 return(1); 493 return(1);
494 } 494 }
495 495
496#ifndef NO_STDIO 496#ifndef OPENSSL_NO_STDIO
497int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) 497int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
498 { 498 {
499 int j; 499 int j;
@@ -560,7 +560,7 @@ int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d)
560 return(ret); 560 return(ret);
561 } 561 }
562 562
563#ifndef NO_RSA 563#ifndef OPENSSL_NO_RSA
564int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) 564int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
565 { 565 {
566 int ret; 566 int ret;
@@ -582,7 +582,7 @@ int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
582 return(0); 582 return(0);
583 } 583 }
584 584
585 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 585 RSA_up_ref(rsa);
586 EVP_PKEY_assign_RSA(pkey,rsa); 586 EVP_PKEY_assign_RSA(pkey,rsa);
587 587
588 ret=ssl_set_pkey(ctx->cert, pkey); 588 ret=ssl_set_pkey(ctx->cert, pkey);
@@ -590,7 +590,7 @@ int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
590 return(ret); 590 return(ret);
591 } 591 }
592 592
593#ifndef NO_STDIO 593#ifndef OPENSSL_NO_STDIO
594int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) 594int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type)
595 { 595 {
596 int j,ret=0; 596 int j,ret=0;
@@ -641,7 +641,7 @@ end:
641int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len) 641int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len)
642 { 642 {
643 int ret; 643 int ret;
644 unsigned char *p; 644 const unsigned char *p;
645 RSA *rsa; 645 RSA *rsa;
646 646
647 p=d; 647 p=d;
@@ -655,7 +655,7 @@ int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len)
655 RSA_free(rsa); 655 RSA_free(rsa);
656 return(ret); 656 return(ret);
657 } 657 }
658#endif /* !NO_RSA */ 658#endif /* !OPENSSL_NO_RSA */
659 659
660int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) 660int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
661 { 661 {
@@ -672,7 +672,7 @@ int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
672 return(ssl_set_pkey(ctx->cert,pkey)); 672 return(ssl_set_pkey(ctx->cert,pkey));
673 } 673 }
674 674
675#ifndef NO_STDIO 675#ifndef OPENSSL_NO_STDIO
676int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) 676int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type)
677 { 677 {
678 int j,ret=0; 678 int j,ret=0;
@@ -735,7 +735,7 @@ int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, unsigned char *d,
735 } 735 }
736 736
737 737
738#ifndef NO_STDIO 738#ifndef OPENSSL_NO_STDIO
739/* Read a file that contains our certificate in "PEM" format, 739/* Read a file that contains our certificate in "PEM" format,
740 * possibly followed by a sequence of CA certificates that should be 740 * possibly followed by a sequence of CA certificates that should be
741 * sent to the peer in the Certificate message. 741 * sent to the peer in the Certificate message.
@@ -800,9 +800,9 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
800 * by SSL_CTX_use_certificate). */ 800 * by SSL_CTX_use_certificate). */
801 } 801 }
802 /* When the while loop ends, it's usually just EOF. */ 802 /* When the while loop ends, it's usually just EOF. */
803 err = ERR_peek_error(); 803 err = ERR_peek_last_error();
804 if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE) 804 if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE)
805 (void) ERR_get_error(); 805 (void)ERR_get_error();
806 else 806 else
807 ret = 0; /* some real error */ 807 ret = 0; /* some real error */
808 } 808 }
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index 7064262def..6424f775e2 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -64,8 +64,6 @@
64static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); 64static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s);
65static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s); 65static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s);
66static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck); 66static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck);
67static int ssl_session_num=0;
68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_session_meth=NULL;
69 67
70SSL_SESSION *SSL_get_session(SSL *ssl) 68SSL_SESSION *SSL_get_session(SSL *ssl)
71/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */ 69/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */
@@ -91,10 +89,8 @@ SSL_SESSION *SSL_get1_session(SSL *ssl)
91int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 89int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
92 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 90 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
93 { 91 {
94 ssl_session_num++; 92 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, argl, argp,
95 return(CRYPTO_get_ex_new_index(ssl_session_num-1, 93 new_func, dup_func, free_func);
96 &ssl_session_meth,
97 argl,argp,new_func,dup_func,free_func));
98 } 94 }
99 95
100int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg) 96int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg)
@@ -126,15 +122,49 @@ SSL_SESSION *SSL_SESSION_new(void)
126 ss->prev=NULL; 122 ss->prev=NULL;
127 ss->next=NULL; 123 ss->next=NULL;
128 ss->compress_meth=0; 124 ss->compress_meth=0;
129 CRYPTO_new_ex_data(ssl_session_meth,ss,&ss->ex_data); 125 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
130 return(ss); 126 return(ss);
131 } 127 }
132 128
129/* Even with SSLv2, we have 16 bytes (128 bits) of session ID space. SSLv3/TLSv1
130 * has 32 bytes (256 bits). As such, filling the ID with random gunk repeatedly
131 * until we have no conflict is going to complete in one iteration pretty much
132 * "most" of the time (btw: understatement). So, if it takes us 10 iterations
133 * and we still can't avoid a conflict - well that's a reasonable point to call
134 * it quits. Either the RAND code is broken or someone is trying to open roughly
135 * very close to 2^128 (or 2^256) SSL sessions to our server. How you might
136 * store that many sessions is perhaps a more interesting question ... */
137
138#define MAX_SESS_ID_ATTEMPTS 10
139static int def_generate_session_id(const SSL *ssl, unsigned char *id,
140 unsigned int *id_len)
141{
142 unsigned int retry = 0;
143 do
144 RAND_pseudo_bytes(id, *id_len);
145 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
146 (++retry < MAX_SESS_ID_ATTEMPTS));
147 if(retry < MAX_SESS_ID_ATTEMPTS)
148 return 1;
149 /* else - woops a session_id match */
150 /* XXX We should also check the external cache --
151 * but the probability of a collision is negligible, and
152 * we could not prevent the concurrent creation of sessions
153 * with identical IDs since we currently don't have means
154 * to atomically check whether a session ID already exists
155 * and make a reservation for it if it does not
156 * (this problem applies to the internal cache as well).
157 */
158 return 0;
159}
160
133int ssl_get_new_session(SSL *s, int session) 161int ssl_get_new_session(SSL *s, int session)
134 { 162 {
135 /* This gets used by clients and servers. */ 163 /* This gets used by clients and servers. */
136 164
165 unsigned int tmp;
137 SSL_SESSION *ss=NULL; 166 SSL_SESSION *ss=NULL;
167 GEN_SESSION_CB cb = def_generate_session_id;
138 168
139 if ((ss=SSL_SESSION_new()) == NULL) return(0); 169 if ((ss=SSL_SESSION_new()) == NULL) return(0);
140 170
@@ -173,25 +203,46 @@ int ssl_get_new_session(SSL *s, int session)
173 SSL_SESSION_free(ss); 203 SSL_SESSION_free(ss);
174 return(0); 204 return(0);
175 } 205 }
176 206 /* Choose which callback will set the session ID */
177 for (;;) 207 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
208 if(s->generate_session_id)
209 cb = s->generate_session_id;
210 else if(s->ctx->generate_session_id)
211 cb = s->ctx->generate_session_id;
212 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
213 /* Choose a session ID */
214 tmp = ss->session_id_length;
215 if(!cb(s, ss->session_id, &tmp))
178 { 216 {
179 SSL_SESSION *r; 217 /* The callback failed */
180 218 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
181 RAND_pseudo_bytes(ss->session_id,ss->session_id_length); 219 SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);
182 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 220 SSL_SESSION_free(ss);
183 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, ss); 221 return(0);
184 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); 222 }
185 if (r == NULL) break; 223 /* Don't allow the callback to set the session length to zero.
186 /* else - woops a session_id match */ 224 * nor set it higher than it was. */
187 /* XXX We should also check the external cache -- 225 if(!tmp || (tmp > ss->session_id_length))
188 * but the probability of a collision is negligible, and 226 {
189 * we could not prevent the concurrent creation of sessions 227 /* The callback set an illegal length */
190 * with identical IDs since we currently don't have means 228 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
191 * to atomically check whether a session ID already exists 229 SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);
192 * and make a reservation for it if it does not 230 SSL_SESSION_free(ss);
193 * (this problem applies to the internal cache as well). 231 return(0);
194 */ 232 }
233 /* If the session length was shrunk and we're SSLv2, pad it */
234 if((tmp < ss->session_id_length) && (s->version == SSL2_VERSION))
235 memset(ss->session_id + tmp, 0, ss->session_id_length - tmp);
236 else
237 ss->session_id_length = tmp;
238 /* Finally, check for a conflict */
239 if(SSL_has_matching_session_id(s, ss->session_id,
240 ss->session_id_length))
241 {
242 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
243 SSL_R_SSL_SESSION_ID_CONFLICT);
244 SSL_SESSION_free(ss);
245 return(0);
195 } 246 }
196 } 247 }
197 else 248 else
@@ -423,10 +474,10 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
423 if ((c != NULL) && (c->session_id_length != 0)) 474 if ((c != NULL) && (c->session_id_length != 0))
424 { 475 {
425 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 476 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
426 r=(SSL_SESSION *)lh_delete(ctx->sessions,c); 477 if ((r = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c)
427 if (r != NULL)
428 { 478 {
429 ret=1; 479 ret=1;
480 r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
430 SSL_SESSION_list_remove(ctx,c); 481 SSL_SESSION_list_remove(ctx,c);
431 } 482 }
432 483
@@ -465,7 +516,7 @@ void SSL_SESSION_free(SSL_SESSION *ss)
465 } 516 }
466#endif 517#endif
467 518
468 CRYPTO_free_ex_data(ssl_session_meth,ss,&ss->ex_data); 519 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
469 520
470 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); 521 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH);
471 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); 522 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH);
@@ -503,6 +554,17 @@ int SSL_set_session(SSL *s, SSL_SESSION *session)
503 session->timeout=s->ctx->session_timeout; 554 session->timeout=s->ctx->session_timeout;
504 } 555 }
505 556
557#ifndef OPENSSL_NO_KRB5
558 if (s->kssl_ctx && !s->kssl_ctx->client_princ &&
559 session->krb5_client_princ_len > 0)
560 {
561 s->kssl_ctx->client_princ = (char *)malloc(session->krb5_client_princ_len + 1);
562 memcpy(s->kssl_ctx->client_princ,session->krb5_client_princ,
563 session->krb5_client_princ_len);
564 s->kssl_ctx->client_princ[session->krb5_client_princ_len] = '\0';
565 }
566#endif /* OPENSSL_NO_KRB5 */
567
506 /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/ 568 /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/
507 CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION); 569 CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION);
508 if (s->session != NULL) 570 if (s->session != NULL)
@@ -594,6 +656,8 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
594 } 656 }
595 } 657 }
596 658
659static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION *, TIMEOUT_PARAM *)
660
597void SSL_CTX_flush_sessions(SSL_CTX *s, long t) 661void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
598 { 662 {
599 unsigned long i; 663 unsigned long i;
@@ -606,7 +670,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
606 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 670 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
607 i=tp.cache->down_load; 671 i=tp.cache->down_load;
608 tp.cache->down_load=0; 672 tp.cache->down_load=0;
609 lh_doall_arg(tp.cache,(void (*)())timeout,&tp); 673 lh_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), &tp);
610 tp.cache->down_load=i; 674 tp.cache->down_load=i;
611 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 675 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
612 } 676 }
diff --git a/src/lib/libssl/src/ssl/ssl_stat.c b/src/lib/libssl/src/ssl/ssl_stat.c
index 8e12461f3b..b16d253081 100644
--- a/src/lib/libssl/src/ssl/ssl_stat.c
+++ b/src/lib/libssl/src/ssl/ssl_stat.c
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "ssl_locl.h" 60#include "ssl_locl.h"
61 61
62char *SSL_state_string_long(SSL *s) 62const char *SSL_state_string_long(const SSL *s)
63 { 63 {
64 char *str; 64 const char *str;
65 65
66 switch (s->state) 66 switch (s->state)
67 { 67 {
@@ -74,7 +74,7 @@ case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break;
74case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; 74case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break;
75case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; 75case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break;
76case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; 76case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break;
77#ifndef NO_SSL2 77#ifndef OPENSSL_NO_SSL2
78case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; 78case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break;
79case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; 79case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break;
80case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; 80case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break;
@@ -115,7 +115,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificat
115case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; 115case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break;
116#endif 116#endif
117 117
118#ifndef NO_SSL3 118#ifndef OPENSSL_NO_SSL3
119/* SSLv3 additions */ 119/* SSLv3 additions */
120case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; 120case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break;
121case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; 121case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break;
@@ -136,7 +136,7 @@ case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break;
136case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; 136case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break;
137case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; 137case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break;
138case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; 138case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break;
139case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify A"; break; 139case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break;
140 140
141case SSL3_ST_CW_CHANGE_A: 141case SSL3_ST_CW_CHANGE_A:
142case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; 142case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break;
@@ -145,7 +145,7 @@ case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break;
145case SSL3_ST_CW_FINISHED_A: 145case SSL3_ST_CW_FINISHED_A:
146case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; 146case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break;
147case SSL3_ST_CW_FINISHED_B: 147case SSL3_ST_CW_FINISHED_B:
148case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished A"; break; 148case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break;
149case SSL3_ST_CR_CHANGE_A: 149case SSL3_ST_CR_CHANGE_A:
150case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; 150case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break;
151case SSL3_ST_CR_CHANGE_B: 151case SSL3_ST_CR_CHANGE_B:
@@ -182,7 +182,7 @@ case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break;
182case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; 182case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break;
183#endif 183#endif
184 184
185#if !defined(NO_SSL2) && !defined(NO_SSL3) 185#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
186/* SSLv2/v3 compatibility states */ 186/* SSLv2/v3 compatibility states */
187/* client */ 187/* client */
188case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; 188case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break;
@@ -199,9 +199,9 @@ default: str="unknown state"; break;
199 return(str); 199 return(str);
200 } 200 }
201 201
202char *SSL_rstate_string_long(SSL *s) 202const char *SSL_rstate_string_long(const SSL *s)
203 { 203 {
204 char *str; 204 const char *str;
205 205
206 switch (s->rstate) 206 switch (s->rstate)
207 { 207 {
@@ -213,9 +213,9 @@ char *SSL_rstate_string_long(SSL *s)
213 return(str); 213 return(str);
214 } 214 }
215 215
216char *SSL_state_string(SSL *s) 216const char *SSL_state_string(const SSL *s)
217 { 217 {
218 char *str; 218 const char *str;
219 219
220 switch (s->state) 220 switch (s->state)
221 { 221 {
@@ -223,7 +223,7 @@ case SSL_ST_BEFORE: str="PINIT "; break;
223case SSL_ST_ACCEPT: str="AINIT "; break; 223case SSL_ST_ACCEPT: str="AINIT "; break;
224case SSL_ST_CONNECT: str="CINIT "; break; 224case SSL_ST_CONNECT: str="CINIT "; break;
225case SSL_ST_OK: str="SSLOK "; break; 225case SSL_ST_OK: str="SSLOK "; break;
226#ifndef NO_SSL2 226#ifndef OPENSSL_NO_SSL2
227case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; 227case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break;
228case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; 228case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break;
229case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; 229case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break;
@@ -264,7 +264,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break;
264case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; 264case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break;
265#endif 265#endif
266 266
267#ifndef NO_SSL3 267#ifndef OPENSSL_NO_SSL3
268/* SSLv3 additions */ 268/* SSLv3 additions */
269case SSL3_ST_SW_FLUSH: 269case SSL3_ST_SW_FLUSH:
270case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; 270case SSL3_ST_CW_FLUSH: str="3FLUSH"; break;
@@ -330,7 +330,7 @@ case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break;
330case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; 330case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break;
331#endif 331#endif
332 332
333#if !defined(NO_SSL2) && !defined(NO_SSL3) 333#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
334/* SSLv2/v3 compatibility states */ 334/* SSLv2/v3 compatibility states */
335/* client */ 335/* client */
336case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; 336case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break;
@@ -347,7 +347,7 @@ default: str="UNKWN "; break;
347 return(str); 347 return(str);
348 } 348 }
349 349
350char *SSL_alert_type_string_long(int value) 350const char *SSL_alert_type_string_long(int value)
351 { 351 {
352 value>>=8; 352 value>>=8;
353 if (value == SSL3_AL_WARNING) 353 if (value == SSL3_AL_WARNING)
@@ -358,7 +358,7 @@ char *SSL_alert_type_string_long(int value)
358 return("unknown"); 358 return("unknown");
359 } 359 }
360 360
361char *SSL_alert_type_string(int value) 361const char *SSL_alert_type_string(int value)
362 { 362 {
363 value>>=8; 363 value>>=8;
364 if (value == SSL3_AL_WARNING) 364 if (value == SSL3_AL_WARNING)
@@ -369,9 +369,9 @@ char *SSL_alert_type_string(int value)
369 return("U"); 369 return("U");
370 } 370 }
371 371
372char *SSL_alert_desc_string(int value) 372const char *SSL_alert_desc_string(int value)
373 { 373 {
374 char *str; 374 const char *str;
375 375
376 switch (value & 0xff) 376 switch (value & 0xff)
377 { 377 {
@@ -387,14 +387,26 @@ char *SSL_alert_desc_string(int value)
387 case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; 387 case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break;
388 case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; 388 case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break;
389 case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; 389 case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break;
390 case TLS1_AD_DECRYPTION_FAILED: str="DC"; break;
391 case TLS1_AD_RECORD_OVERFLOW: str="RO"; break;
392 case TLS1_AD_UNKNOWN_CA: str="CA"; break;
393 case TLS1_AD_ACCESS_DENIED: str="AD"; break;
394 case TLS1_AD_DECODE_ERROR: str="DE"; break;
395 case TLS1_AD_DECRYPT_ERROR: str="CY"; break;
396 case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break;
397 case TLS1_AD_PROTOCOL_VERSION: str="PV"; break;
398 case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break;
399 case TLS1_AD_INTERNAL_ERROR: str="IE"; break;
400 case TLS1_AD_USER_CANCELLED: str="US"; break;
401 case TLS1_AD_NO_RENEGOTIATION: str="NR"; break;
390 default: str="UK"; break; 402 default: str="UK"; break;
391 } 403 }
392 return(str); 404 return(str);
393 } 405 }
394 406
395char *SSL_alert_desc_string_long(int value) 407const char *SSL_alert_desc_string_long(int value)
396 { 408 {
397 char *str; 409 const char *str;
398 410
399 switch (value & 0xff) 411 switch (value & 0xff)
400 { 412 {
@@ -434,14 +446,50 @@ char *SSL_alert_desc_string_long(int value)
434 case SSL3_AD_ILLEGAL_PARAMETER: 446 case SSL3_AD_ILLEGAL_PARAMETER:
435 str="illegal parameter"; 447 str="illegal parameter";
436 break; 448 break;
449 case TLS1_AD_DECRYPTION_FAILED:
450 str="decryption failed";
451 break;
452 case TLS1_AD_RECORD_OVERFLOW:
453 str="record overflow";
454 break;
455 case TLS1_AD_UNKNOWN_CA:
456 str="unknown CA";
457 break;
458 case TLS1_AD_ACCESS_DENIED:
459 str="access denied";
460 break;
461 case TLS1_AD_DECODE_ERROR:
462 str="decode error";
463 break;
464 case TLS1_AD_DECRYPT_ERROR:
465 str="decrypt error";
466 break;
467 case TLS1_AD_EXPORT_RESTRICTION:
468 str="export restriction";
469 break;
470 case TLS1_AD_PROTOCOL_VERSION:
471 str="protocol version";
472 break;
473 case TLS1_AD_INSUFFICIENT_SECURITY:
474 str="insufficient security";
475 break;
476 case TLS1_AD_INTERNAL_ERROR:
477 str="internal error";
478 break;
479 case TLS1_AD_USER_CANCELLED:
480 str="user canceled";
481 break;
482 case TLS1_AD_NO_RENEGOTIATION:
483 str="no renegotiation";
484 break;
437 default: str="unknown"; break; 485 default: str="unknown"; break;
438 } 486 }
439 return(str); 487 return(str);
440 } 488 }
441 489
442char *SSL_rstate_string(SSL *s) 490const char *SSL_rstate_string(const SSL *s)
443 { 491 {
444 char *str; 492 const char *str;
445 493
446 switch (s->rstate) 494 switch (s->rstate)
447 { 495 {
diff --git a/src/lib/libssl/src/ssl/ssl_task.c b/src/lib/libssl/src/ssl/ssl_task.c
index cac701a798..e36af0eb94 100644
--- a/src/lib/libssl/src/ssl/ssl_task.c
+++ b/src/lib/libssl/src/ssl/ssl_task.c
@@ -124,7 +124,7 @@ int LIB$INIT_TIMER(), LIB$SHOW_TIMER();
124#include <string.h> /* from ssltest.c */ 124#include <string.h> /* from ssltest.c */
125#include <errno.h> 125#include <errno.h>
126 126
127#include "openssl/e_os.h" 127#include "e_os.h"
128 128
129#include <openssl/buffer.h> 129#include <openssl/buffer.h>
130#include <openssl/x509.h> 130#include <openssl/x509.h>
diff --git a/src/lib/libssl/src/ssl/ssl_txt.c b/src/lib/libssl/src/ssl/ssl_txt.c
index 6e33eec3e4..40b76b1b26 100644
--- a/src/lib/libssl/src/ssl/ssl_txt.c
+++ b/src/lib/libssl/src/ssl/ssl_txt.c
@@ -60,7 +60,7 @@
60#include <openssl/buffer.h> 60#include <openssl/buffer.h>
61#include "ssl_locl.h" 61#include "ssl_locl.h"
62 62
63#ifndef NO_FP_API 63#ifndef OPENSSL_NO_FP_API
64int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x) 64int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x)
65 { 65 {
66 BIO *b; 66 BIO *b;
@@ -139,6 +139,18 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
139 { 139 {
140 if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err; 140 if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err;
141 } 141 }
142#ifndef OPENSSL_NO_KRB5
143 if (BIO_puts(bp,"\n Krb5 Principal: ") <= 0) goto err;
144 if (x->krb5_client_princ_len == 0)
145 {
146 if (BIO_puts(bp,"None") <= 0) goto err;
147 }
148 else
149 for (i=0; i<x->krb5_client_princ_len; i++)
150 {
151 if (BIO_printf(bp,"%02X",x->krb5_client_princ[i]) <= 0) goto err;
152 }
153#endif /* OPENSSL_NO_KRB5 */
142 if (x->compress_meth != 0) 154 if (x->compress_meth != 0)
143 { 155 {
144 SSL_COMP *comp; 156 SSL_COMP *comp;
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c
index 2ef8a50785..1afdfa7750 100644
--- a/src/lib/libssl/src/ssl/ssltest.c
+++ b/src/lib/libssl/src/ssl/ssltest.c
@@ -55,6 +55,65 @@
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-2000 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#define _XOPEN_SOURCE 600 /* Or gethostname won't be declared properly
113 on Linux and GNU platforms. */
114#define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly
115 on Compaq platforms (at least with DEC C).
116 */
58 117
59#include <assert.h> 118#include <assert.h>
60#include <errno.h> 119#include <errno.h>
@@ -64,20 +123,24 @@
64#include <string.h> 123#include <string.h>
65#include <time.h> 124#include <time.h>
66 125
67#include "openssl/e_os.h" 126#include "e_os.h"
68 127
69#include <openssl/bio.h> 128#include <openssl/bio.h>
70#include <openssl/crypto.h> 129#include <openssl/crypto.h>
71#include <openssl/evp.h> 130#include <openssl/evp.h>
72#include <openssl/x509.h> 131#include <openssl/x509.h>
73#include <openssl/ssl.h> 132#include <openssl/ssl.h>
133#include <openssl/engine.h>
74#include <openssl/err.h> 134#include <openssl/err.h>
75#include <openssl/rand.h> 135#include <openssl/rand.h>
76#ifdef WINDOWS 136#ifdef OPENSSL_SYS_WINDOWS
137#include <winsock.h>
77#include "../crypto/bio/bss_file.c" 138#include "../crypto/bio/bss_file.c"
139#else
140#include OPENSSL_UNISTD
78#endif 141#endif
79 142
80#ifdef VMS 143#ifdef OPENSSL_SYS_VMS
81# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" 144# define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM"
82# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" 145# define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM"
83#else 146#else
@@ -85,12 +148,21 @@
85# define TEST_CLIENT_CERT "../apps/client.pem" 148# define TEST_CLIENT_CERT "../apps/client.pem"
86#endif 149#endif
87 150
151/* There is really no standard for this, so let's assign some tentative
152 numbers. In any case, these numbers are only for this test */
153#define COMP_RLE 1
154#define COMP_ZLIB 2
155
88static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx); 156static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
89#ifndef NO_RSA 157#ifndef OPENSSL_NO_RSA
90static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength); 158static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
91static void free_tmp_rsa(void); 159static void free_tmp_rsa(void);
92#endif 160#endif
93#ifndef NO_DH 161static int MS_CALLBACK app_verify_callback(X509_STORE_CTX *ctx, void *arg);
162#define APP_CALLBACK "Test Callback Argument"
163static char *app_verify_arg = APP_CALLBACK;
164
165#ifndef OPENSSL_NO_DH
94static DH *get_dh512(void); 166static DH *get_dh512(void);
95static DH *get_dh1024(void); 167static DH *get_dh1024(void);
96static DH *get_dh1024dsa(void); 168static DH *get_dh1024dsa(void);
@@ -124,18 +196,18 @@ static void sv_usage(void)
124 fprintf(stderr," -reuse - use session-id reuse\n"); 196 fprintf(stderr," -reuse - use session-id reuse\n");
125 fprintf(stderr," -num <val> - number of connections to perform\n"); 197 fprintf(stderr," -num <val> - number of connections to perform\n");
126 fprintf(stderr," -bytes <val> - number of bytes to swap between client/server\n"); 198 fprintf(stderr," -bytes <val> - number of bytes to swap between client/server\n");
127#ifndef NO_DH 199#ifndef OPENSSL_NO_DH
128 fprintf(stderr," -dhe1024 - use 1024 bit key (safe prime) for DHE\n"); 200 fprintf(stderr," -dhe1024 - use 1024 bit key (safe prime) for DHE\n");
129 fprintf(stderr," -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n"); 201 fprintf(stderr," -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n");
130 fprintf(stderr," -no_dhe - disable DHE\n"); 202 fprintf(stderr," -no_dhe - disable DHE\n");
131#endif 203#endif
132#ifndef NO_SSL2 204#ifndef OPENSSL_NO_SSL2
133 fprintf(stderr," -ssl2 - use SSLv2\n"); 205 fprintf(stderr," -ssl2 - use SSLv2\n");
134#endif 206#endif
135#ifndef NO_SSL3 207#ifndef OPENSSL_NO_SSL3
136 fprintf(stderr," -ssl3 - use SSLv3\n"); 208 fprintf(stderr," -ssl3 - use SSLv3\n");
137#endif 209#endif
138#ifndef NO_TLS1 210#ifndef OPENSSL_NO_TLS1
139 fprintf(stderr," -tls1 - use TLSv1\n"); 211 fprintf(stderr," -tls1 - use TLSv1\n");
140#endif 212#endif
141 fprintf(stderr," -CApath arg - PEM format directory of CA's\n"); 213 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
@@ -148,6 +220,8 @@ static void sv_usage(void)
148 fprintf(stderr," -bio_pair - Use BIO pairs\n"); 220 fprintf(stderr," -bio_pair - Use BIO pairs\n");
149 fprintf(stderr," -f - Test even cases that can't work\n"); 221 fprintf(stderr," -f - Test even cases that can't work\n");
150 fprintf(stderr," -time - measure processor time used by client and server\n"); 222 fprintf(stderr," -time - measure processor time used by client and server\n");
223 fprintf(stderr," -zlib - use zlib compression\n");
224 fprintf(stderr," -time - use rle compression\n");
151 } 225 }
152 226
153static void print_details(SSL *c_ssl, const char *prefix) 227static void print_details(SSL *c_ssl, const char *prefix)
@@ -169,7 +243,7 @@ static void print_details(SSL *c_ssl, const char *prefix)
169 { 243 {
170 if (0) 244 if (0)
171 ; 245 ;
172#ifndef NO_RSA 246#ifndef OPENSSL_NO_RSA
173 else if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL 247 else if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL
174 && pkey->pkey.rsa->n != NULL) 248 && pkey->pkey.rsa->n != NULL)
175 { 249 {
@@ -177,7 +251,7 @@ static void print_details(SSL *c_ssl, const char *prefix)
177 BN_num_bits(pkey->pkey.rsa->n)); 251 BN_num_bits(pkey->pkey.rsa->n));
178 } 252 }
179#endif 253#endif
180#ifndef NO_DSA 254#ifndef OPENSSL_NO_DSA
181 else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL 255 else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL
182 && pkey->pkey.dsa->p != NULL) 256 && pkey->pkey.dsa->p != NULL)
183 { 257 {
@@ -194,6 +268,69 @@ static void print_details(SSL *c_ssl, const char *prefix)
194 BIO_printf(bio_stdout,"\n"); 268 BIO_printf(bio_stdout,"\n");
195 } 269 }
196 270
271static void lock_dbg_cb(int mode, int type, const char *file, int line)
272 {
273 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
274 const char *errstr = NULL;
275 int rw;
276
277 rw = mode & (CRYPTO_READ|CRYPTO_WRITE);
278 if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE)))
279 {
280 errstr = "invalid mode";
281 goto err;
282 }
283
284 if (type < 0 || type > CRYPTO_NUM_LOCKS)
285 {
286 errstr = "type out of bounds";
287 goto err;
288 }
289
290 if (mode & CRYPTO_LOCK)
291 {
292 if (modes[type])
293 {
294 errstr = "already locked";
295 /* must not happen in a single-threaded program
296 * (would deadlock) */
297 goto err;
298 }
299
300 modes[type] = rw;
301 }
302 else if (mode & CRYPTO_UNLOCK)
303 {
304 if (!modes[type])
305 {
306 errstr = "not locked";
307 goto err;
308 }
309
310 if (modes[type] != rw)
311 {
312 errstr = (rw == CRYPTO_READ) ?
313 "CRYPTO_r_unlock on write lock" :
314 "CRYPTO_w_unlock on read lock";
315 }
316
317 modes[type] = 0;
318 }
319 else
320 {
321 errstr = "invalid mode";
322 goto err;
323 }
324
325 err:
326 if (errstr)
327 {
328 /* we cannot use bio_err here */
329 fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
330 errstr, mode, type, file, line);
331 }
332 }
333
197int main(int argc, char *argv[]) 334int main(int argc, char *argv[])
198 { 335 {
199 char *CApath=NULL,*CAfile=NULL; 336 char *CApath=NULL,*CAfile=NULL;
@@ -203,6 +340,7 @@ int main(int argc, char *argv[])
203 int tls1=0,ssl2=0,ssl3=0,ret=1; 340 int tls1=0,ssl2=0,ssl3=0,ret=1;
204 int client_auth=0; 341 int client_auth=0;
205 int server_auth=0,i; 342 int server_auth=0,i;
343 int app_verify=0;
206 char *server_cert=TEST_SERVER_CERT; 344 char *server_cert=TEST_SERVER_CERT;
207 char *server_key=NULL; 345 char *server_key=NULL;
208 char *client_cert=TEST_CLIENT_CERT; 346 char *client_cert=TEST_CLIENT_CERT;
@@ -213,18 +351,33 @@ int main(int argc, char *argv[])
213 SSL *c_ssl,*s_ssl; 351 SSL *c_ssl,*s_ssl;
214 int number=1,reuse=0; 352 int number=1,reuse=0;
215 long bytes=1L; 353 long bytes=1L;
216#ifndef NO_DH 354#ifndef OPENSSL_NO_DH
217 DH *dh; 355 DH *dh;
218 int dhe1024 = 0, dhe1024dsa = 0; 356 int dhe1024 = 0, dhe1024dsa = 0;
219#endif 357#endif
220 int no_dhe = 0; 358 int no_dhe = 0;
221 int print_time = 0; 359 int print_time = 0;
222 clock_t s_time = 0, c_time = 0; 360 clock_t s_time = 0, c_time = 0;
361 int comp = 0;
362 COMP_METHOD *cm = NULL;
223 363
224 verbose = 0; 364 verbose = 0;
225 debug = 0; 365 debug = 0;
226 cipher = 0; 366 cipher = 0;
227 367
368 CRYPTO_set_locking_callback(lock_dbg_cb);
369
370 /* enable memory leak checking unless explicitly disabled */
371 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
372 {
373 CRYPTO_malloc_debug_init();
374 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
375 }
376 else
377 {
378 /* OPENSSL_DEBUG_MEMORY=off */
379 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
380 }
228 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 381 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
229 382
230 RAND_seed(rnd_seed, sizeof rnd_seed); 383 RAND_seed(rnd_seed, sizeof rnd_seed);
@@ -247,7 +400,7 @@ int main(int argc, char *argv[])
247 debug=1; 400 debug=1;
248 else if (strcmp(*argv,"-reuse") == 0) 401 else if (strcmp(*argv,"-reuse") == 0)
249 reuse=1; 402 reuse=1;
250#ifndef NO_DH 403#ifndef OPENSSL_NO_DH
251 else if (strcmp(*argv,"-dhe1024") == 0) 404 else if (strcmp(*argv,"-dhe1024") == 0)
252 dhe1024=1; 405 dhe1024=1;
253 else if (strcmp(*argv,"-dhe1024dsa") == 0) 406 else if (strcmp(*argv,"-dhe1024dsa") == 0)
@@ -333,6 +486,18 @@ int main(int argc, char *argv[])
333 { 486 {
334 print_time = 1; 487 print_time = 1;
335 } 488 }
489 else if (strcmp(*argv,"-zlib") == 0)
490 {
491 comp = COMP_ZLIB;
492 }
493 else if (strcmp(*argv,"-rle") == 0)
494 {
495 comp = COMP_RLE;
496 }
497 else if (strcmp(*argv,"-app_verify") == 0)
498 {
499 app_verify = 1;
500 }
336 else 501 else
337 { 502 {
338 fprintf(stderr,"unknown option %s\n",*argv); 503 fprintf(stderr,"unknown option %s\n",*argv);
@@ -374,7 +539,24 @@ bad:
374 SSL_library_init(); 539 SSL_library_init();
375 SSL_load_error_strings(); 540 SSL_load_error_strings();
376 541
377#if !defined(NO_SSL2) && !defined(NO_SSL3) 542 if (comp == COMP_ZLIB) cm = COMP_zlib();
543 if (comp == COMP_RLE) cm = COMP_rle();
544 if (cm != NULL)
545 {
546 if (cm->type != NID_undef)
547 SSL_COMP_add_compression_method(comp, cm);
548 else
549 {
550 fprintf(stderr,
551 "Warning: %s compression not supported\n",
552 (comp == COMP_RLE ? "rle" :
553 (comp == COMP_ZLIB ? "zlib" :
554 "unknown")));
555 ERR_print_errors_fp(stderr);
556 }
557 }
558
559#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
378 if (ssl2) 560 if (ssl2)
379 meth=SSLv2_method(); 561 meth=SSLv2_method();
380 else 562 else
@@ -386,7 +568,7 @@ bad:
386 else 568 else
387 meth=SSLv23_method(); 569 meth=SSLv23_method();
388#else 570#else
389#ifdef NO_SSL2 571#ifdef OPENSSL_NO_SSL2
390 meth=SSLv3_method(); 572 meth=SSLv3_method();
391#else 573#else
392 meth=SSLv2_method(); 574 meth=SSLv2_method();
@@ -407,7 +589,7 @@ bad:
407 SSL_CTX_set_cipher_list(s_ctx,cipher); 589 SSL_CTX_set_cipher_list(s_ctx,cipher);
408 } 590 }
409 591
410#ifndef NO_DH 592#ifndef OPENSSL_NO_DH
411 if (!no_dhe) 593 if (!no_dhe)
412 { 594 {
413 if (dhe1024dsa) 595 if (dhe1024dsa)
@@ -427,7 +609,7 @@ bad:
427 (void)no_dhe; 609 (void)no_dhe;
428#endif 610#endif
429 611
430#ifndef NO_RSA 612#ifndef OPENSSL_NO_RSA
431 SSL_CTX_set_tmp_rsa_callback(s_ctx,tmp_rsa_cb); 613 SSL_CTX_set_tmp_rsa_callback(s_ctx,tmp_rsa_cb);
432#endif 614#endif
433 615
@@ -467,12 +649,20 @@ bad:
467 SSL_CTX_set_verify(s_ctx, 649 SSL_CTX_set_verify(s_ctx,
468 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 650 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
469 verify_callback); 651 verify_callback);
652 if (app_verify)
653 {
654 SSL_CTX_set_cert_verify_callback(s_ctx, app_verify_callback, app_verify_arg);
655 }
470 } 656 }
471 if (server_auth) 657 if (server_auth)
472 { 658 {
473 BIO_printf(bio_err,"server authentication\n"); 659 BIO_printf(bio_err,"server authentication\n");
474 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER, 660 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
475 verify_callback); 661 verify_callback);
662 if (app_verify)
663 {
664 SSL_CTX_set_cert_verify_callback(s_ctx, app_verify_callback, app_verify_arg);
665 }
476 } 666 }
477 667
478 { 668 {
@@ -483,6 +673,19 @@ bad:
483 c_ssl=SSL_new(c_ctx); 673 c_ssl=SSL_new(c_ctx);
484 s_ssl=SSL_new(s_ctx); 674 s_ssl=SSL_new(s_ctx);
485 675
676#ifndef OPENSSL_NO_KRB5
677 if (c_ssl && c_ssl->kssl_ctx)
678 {
679 char localhost[257];
680
681 if (gethostname(localhost, 256) == 0)
682 {
683 kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER,
684 localhost);
685 }
686 }
687#endif /* OPENSSL_NO_KRB5 */
688
486 for (i=0; i<number; i++) 689 for (i=0; i<number; i++)
487 { 690 {
488 if (!reuse) SSL_set_session(c_ssl,NULL); 691 if (!reuse) SSL_set_session(c_ssl,NULL);
@@ -529,9 +732,11 @@ end:
529 732
530 if (bio_stdout != NULL) BIO_free(bio_stdout); 733 if (bio_stdout != NULL) BIO_free(bio_stdout);
531 734
532#ifndef NO_RSA 735#ifndef OPENSSL_NO_RSA
533 free_tmp_rsa(); 736 free_tmp_rsa();
534#endif 737#endif
738 ENGINE_cleanup();
739 CRYPTO_cleanup_all_ex_data();
535 ERR_free_strings(); 740 ERR_free_strings();
536 ERR_remove_state(0); 741 ERR_remove_state(0);
537 EVP_cleanup(); 742 EVP_cleanup();
@@ -848,10 +1053,10 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
848 if (num > 1) 1053 if (num > 1)
849 --num; /* test restartability even more thoroughly */ 1054 --num; /* test restartability even more thoroughly */
850 1055
851 r = BIO_nwrite(io1, &dataptr, (int)num); 1056 r = BIO_nwrite0(io1, &dataptr);
852 assert(r > 0); 1057 assert(r > 0);
853 assert(r <= (int)num); 1058 if (r < (int)num)
854 num = r; 1059 num = r;
855 r = BIO_read(io2, dataptr, (int)num); 1060 r = BIO_read(io2, dataptr, (int)num);
856 if (r != (int)num) /* can't happen */ 1061 if (r != (int)num) /* can't happen */
857 { 1062 {
@@ -860,6 +1065,13 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
860 goto err; 1065 goto err;
861 } 1066 }
862 progress = 1; 1067 progress = 1;
1068 r = BIO_nwrite(io1, &dataptr, (int)num);
1069 if (r != (int)num) /* can't happen */
1070 {
1071 fprintf(stderr, "ERROR: BIO_nwrite() did not accept "
1072 "BIO_nwrite0() bytes");
1073 goto err;
1074 }
863 1075
864 if (debug) 1076 if (debug)
865 printf((io2 == client_io) ? 1077 printf((io2 == client_io) ?
@@ -1245,7 +1457,26 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
1245 return(ok); 1457 return(ok);
1246 } 1458 }
1247 1459
1248#ifndef NO_RSA 1460static int MS_CALLBACK app_verify_callback(X509_STORE_CTX *ctx, void *arg)
1461 {
1462 char *s = NULL,buf[256];
1463 int ok=1;
1464
1465 fprintf(stderr, "In app_verify_callback, allowing cert. ");
1466 fprintf(stderr, "Arg is: %s\n", (char *)arg);
1467 fprintf(stderr, "Finished printing do we have a context? 0x%x a cert? 0x%x\n",
1468 (unsigned int)ctx, (unsigned int)ctx->cert);
1469 if (ctx->cert)
1470 s=X509_NAME_oneline(X509_get_subject_name(ctx->cert),buf,256);
1471 if (s != NULL)
1472 {
1473 fprintf(stderr,"cert depth=%d %s\n",ctx->error_depth,buf);
1474 }
1475
1476 return(ok);
1477 }
1478
1479#ifndef OPENSSL_NO_RSA
1249static RSA *rsa_tmp=NULL; 1480static RSA *rsa_tmp=NULL;
1250 1481
1251static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength) 1482static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
@@ -1271,14 +1502,14 @@ static void free_tmp_rsa(void)
1271 } 1502 }
1272#endif 1503#endif
1273 1504
1274#ifndef NO_DH 1505#ifndef OPENSSL_NO_DH
1275/* These DH parameters have been generated as follows: 1506/* These DH parameters have been generated as follows:
1276 * $ openssl dhparam -C -noout 512 1507 * $ openssl dhparam -C -noout 512
1277 * $ openssl dhparam -C -noout 1024 1508 * $ openssl dhparam -C -noout 1024
1278 * $ openssl dhparam -C -noout -dsaparam 1024 1509 * $ openssl dhparam -C -noout -dsaparam 1024
1279 * (The third function has been renamed to avoid name conflicts.) 1510 * (The third function has been renamed to avoid name conflicts.)
1280 */ 1511 */
1281DH *get_dh512() 1512static DH *get_dh512()
1282 { 1513 {
1283 static unsigned char dh512_p[]={ 1514 static unsigned char dh512_p[]={
1284 0xCB,0xC8,0xE1,0x86,0xD0,0x1F,0x94,0x17,0xA6,0x99,0xF0,0xC6, 1515 0xCB,0xC8,0xE1,0x86,0xD0,0x1F,0x94,0x17,0xA6,0x99,0xF0,0xC6,
@@ -1301,7 +1532,7 @@ DH *get_dh512()
1301 return(dh); 1532 return(dh);
1302 } 1533 }
1303 1534
1304DH *get_dh1024() 1535static DH *get_dh1024()
1305 { 1536 {
1306 static unsigned char dh1024_p[]={ 1537 static unsigned char dh1024_p[]={
1307 0xF8,0x81,0x89,0x7D,0x14,0x24,0xC5,0xD1,0xE6,0xF7,0xBF,0x3A, 1538 0xF8,0x81,0x89,0x7D,0x14,0x24,0xC5,0xD1,0xE6,0xF7,0xBF,0x3A,
@@ -1329,7 +1560,7 @@ DH *get_dh1024()
1329 return(dh); 1560 return(dh);
1330 } 1561 }
1331 1562
1332DH *get_dh1024dsa() 1563static DH *get_dh1024dsa()
1333 { 1564 {
1334 static unsigned char dh1024_p[]={ 1565 static unsigned char dh1024_p[]={
1335 0xC8,0x00,0xF7,0x08,0x07,0x89,0x4D,0x90,0x53,0xF3,0xD5,0x00, 1566 0xC8,0x00,0xF7,0x08,0x07,0x89,0x4D,0x90,0x53,0xF3,0xD5,0x00,
diff --git a/src/lib/libssl/src/ssl/t1_enc.c b/src/lib/libssl/src/ssl/t1_enc.c
index a0758e9261..b80525f3ba 100644
--- a/src/lib/libssl/src/ssl/t1_enc.c
+++ b/src/lib/libssl/src/ssl/t1_enc.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-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 <openssl/comp.h> 113#include <openssl/comp.h>
61#include <openssl/md5.h>
62#include <openssl/sha.h>
63#include <openssl/evp.h> 114#include <openssl/evp.h>
64#include <openssl/hmac.h> 115#include <openssl/hmac.h>
65#include "ssl_locl.h" 116#include "ssl_locl.h"
117#include <openssl/md5.h>
66 118
67static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, 119static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
68 int sec_len, unsigned char *seed, int seed_len, 120 int sec_len, unsigned char *seed, int seed_len,
@@ -77,16 +129,20 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
77 129
78 chunk=EVP_MD_size(md); 130 chunk=EVP_MD_size(md);
79 131
80 HMAC_Init(&ctx,sec,sec_len,md); 132 HMAC_CTX_init(&ctx);
133 HMAC_CTX_init(&ctx_tmp);
134 HMAC_Init_ex(&ctx,sec,sec_len,md, NULL);
135 HMAC_Init_ex(&ctx_tmp,sec,sec_len,md, NULL);
81 HMAC_Update(&ctx,seed,seed_len); 136 HMAC_Update(&ctx,seed,seed_len);
82 HMAC_Final(&ctx,A1,&A1_len); 137 HMAC_Final(&ctx,A1,&A1_len);
83 138
84 n=0; 139 n=0;
85 for (;;) 140 for (;;)
86 { 141 {
87 HMAC_Init(&ctx,NULL,0,NULL); /* re-init */ 142 HMAC_Init_ex(&ctx,NULL,0,NULL,NULL); /* re-init */
143 HMAC_Init_ex(&ctx_tmp,NULL,0,NULL,NULL); /* re-init */
88 HMAC_Update(&ctx,A1,A1_len); 144 HMAC_Update(&ctx,A1,A1_len);
89 memcpy(&ctx_tmp,&ctx,sizeof(ctx)); /* Copy for A2 */ /* not needed for last one */ 145 HMAC_Update(&ctx_tmp,A1,A1_len);
90 HMAC_Update(&ctx,seed,seed_len); 146 HMAC_Update(&ctx,seed,seed_len);
91 147
92 if (olen > chunk) 148 if (olen > chunk)
@@ -103,8 +159,8 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
103 break; 159 break;
104 } 160 }
105 } 161 }
106 HMAC_cleanup(&ctx); 162 HMAC_CTX_cleanup(&ctx);
107 HMAC_cleanup(&ctx_tmp); 163 HMAC_CTX_cleanup(&ctx_tmp);
108 memset(A1,0,sizeof(A1)); 164 memset(A1,0,sizeof(A1));
109 } 165 }
110 166
@@ -148,6 +204,17 @@ static void tls1_generate_key_block(SSL *s, unsigned char *km,
148 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf), 204 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf),
149 s->session->master_key,s->session->master_key_length, 205 s->session->master_key,s->session->master_key_length,
150 km,tmp,num); 206 km,tmp,num);
207#ifdef KSSL_DEBUG
208 printf("tls1_generate_key_block() ==> %d byte master_key =\n\t",
209 s->session->master_key_length);
210 {
211 int i;
212 for (i=0; i < s->session->master_key_length; i++)
213 {
214 printf("%02X", s->session->master_key[i]);
215 }
216 printf("\n"); }
217#endif /* KSSL_DEBUG */
151 } 218 }
152 219
153int tls1_change_cipher_state(SSL *s, int which) 220int tls1_change_cipher_state(SSL *s, int which)
@@ -166,19 +233,35 @@ int tls1_change_cipher_state(SSL *s, int which)
166 const EVP_CIPHER *c; 233 const EVP_CIPHER *c;
167 const SSL_COMP *comp; 234 const SSL_COMP *comp;
168 const EVP_MD *m; 235 const EVP_MD *m;
169 int _exp,n,i,j,k,exp_label_len,cl; 236 int is_export,n,i,j,k,exp_label_len,cl;
237 int reuse_dd = 0;
170 238
171 _exp=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher); 239 is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
172 c=s->s3->tmp.new_sym_enc; 240 c=s->s3->tmp.new_sym_enc;
173 m=s->s3->tmp.new_hash; 241 m=s->s3->tmp.new_hash;
174 comp=s->s3->tmp.new_compression; 242 comp=s->s3->tmp.new_compression;
175 key_block=s->s3->tmp.key_block; 243 key_block=s->s3->tmp.key_block;
176 244
245#ifdef KSSL_DEBUG
246 printf("tls1_change_cipher_state(which= %d) w/\n", which);
247 printf("\talg= %ld, comp= %p\n", s->s3->tmp.new_cipher->algorithms,
248 comp);
249 printf("\tevp_cipher == %p ==? &d_cbc_ede_cipher3\n", c);
250 printf("\tevp_cipher: nid, blksz= %d, %d, keylen=%d, ivlen=%d\n",
251 c->nid,c->block_size,c->key_len,c->iv_len);
252 printf("\tkey_block: len= %d, data= ", s->s3->tmp.key_block_length);
253 {
254 int i;
255 for (i=0; i<s->s3->tmp.key_block_length; i++)
256 printf("%02x", key_block[i]); printf("\n");
257 }
258#endif /* KSSL_DEBUG */
259
177 if (which & SSL3_CC_READ) 260 if (which & SSL3_CC_READ)
178 { 261 {
179 if ((s->enc_read_ctx == NULL) && 262 if (s->enc_read_ctx != NULL)
180 ((s->enc_read_ctx=(EVP_CIPHER_CTX *) 263 reuse_dd = 1;
181 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 264 else if ((s->enc_read_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
182 goto err; 265 goto err;
183 dd= s->enc_read_ctx; 266 dd= s->enc_read_ctx;
184 s->read_hash=m; 267 s->read_hash=m;
@@ -206,6 +289,10 @@ int tls1_change_cipher_state(SSL *s, int which)
206 } 289 }
207 else 290 else
208 { 291 {
292 if (s->enc_write_ctx != NULL)
293 reuse_dd = 1;
294 else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
295 goto err;
209 if ((s->enc_write_ctx == NULL) && 296 if ((s->enc_write_ctx == NULL) &&
210 ((s->enc_write_ctx=(EVP_CIPHER_CTX *) 297 ((s->enc_write_ctx=(EVP_CIPHER_CTX *)
211 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 298 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
@@ -230,13 +317,15 @@ int tls1_change_cipher_state(SSL *s, int which)
230 mac_secret= &(s->s3->write_mac_secret[0]); 317 mac_secret= &(s->s3->write_mac_secret[0]);
231 } 318 }
232 319
320 if (reuse_dd)
321 EVP_CIPHER_CTX_cleanup(dd);
233 EVP_CIPHER_CTX_init(dd); 322 EVP_CIPHER_CTX_init(dd);
234 323
235 p=s->s3->tmp.key_block; 324 p=s->s3->tmp.key_block;
236 i=EVP_MD_size(m); 325 i=EVP_MD_size(m);
237 cl=EVP_CIPHER_key_length(c); 326 cl=EVP_CIPHER_key_length(c);
238 j=_exp ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ? 327 j=is_export ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ?
239 cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl; 328 cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl;
240 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */ 329 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */
241 k=EVP_CIPHER_iv_length(c); 330 k=EVP_CIPHER_iv_length(c);
242 er1= &(s->s3->client_random[0]); 331 er1= &(s->s3->client_random[0]);
@@ -264,7 +353,7 @@ int tls1_change_cipher_state(SSL *s, int which)
264 353
265 if (n > s->s3->tmp.key_block_length) 354 if (n > s->s3->tmp.key_block_length)
266 { 355 {
267 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,SSL_R_INTERNAL_ERROR); 356 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_INTERNAL_ERROR);
268 goto err2; 357 goto err2;
269 } 358 }
270 359
@@ -273,7 +362,7 @@ int tls1_change_cipher_state(SSL *s, int which)
273printf("which = %04X\nmac key=",which); 362printf("which = %04X\nmac key=",which);
274{ int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); } 363{ int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); }
275#endif 364#endif
276 if (_exp) 365 if (is_export)
277 { 366 {
278 /* In here I set both the read and write key/iv to the 367 /* In here I set both the read and write key/iv to the
279 * same value since only the correct one will be used :-). 368 * same value since only the correct one will be used :-).
@@ -309,8 +398,18 @@ printf("which = %04X\nmac key=",which);
309 } 398 }
310 399
311 s->session->key_arg_length=0; 400 s->session->key_arg_length=0;
401#ifdef KSSL_DEBUG
402 {
403 int i;
404 printf("EVP_CipherInit_ex(dd,c,key=,iv=,which)\n");
405 printf("\tkey= "); for (i=0; i<c->key_len; i++) printf("%02x", key[i]);
406 printf("\n");
407 printf("\t iv= "); for (i=0; i<c->iv_len; i++) printf("%02x", iv[i]);
408 printf("\n");
409 }
410#endif /* KSSL_DEBUG */
312 411
313 EVP_CipherInit(dd,c,key,iv,(which & SSL3_CC_WRITE)); 412 EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE));
314#ifdef TLS_DEBUG 413#ifdef TLS_DEBUG
315printf("which = %04X\nkey=",which); 414printf("which = %04X\nkey=",which);
316{ int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); } 415{ int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); }
@@ -338,6 +437,10 @@ int tls1_setup_key_block(SSL *s)
338 int num; 437 int num;
339 SSL_COMP *comp; 438 SSL_COMP *comp;
340 439
440#ifdef KSSL_DEBUG
441 printf ("tls1_setup_key_block()\n");
442#endif /* KSSL_DEBUG */
443
341 if (s->s3->tmp.key_block_length != 0) 444 if (s->s3->tmp.key_block_length != 0)
342 return(1); 445 return(1);
343 446
@@ -380,6 +483,14 @@ printf("\nkey block\n");
380{ int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); } 483{ int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); }
381#endif 484#endif
382 485
486 /* enable vulnerability countermeasure for CBC ciphers with
487 * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */
488 s->s3->need_empty_fragments = 1;
489#ifndef NO_RC4
490 if ((s->session->cipher != NULL) && ((s->session->cipher->algorithms & SSL_ENC_MASK) == SSL_RC4))
491 s->s3->need_empty_fragments = 0;
492#endif
493
383 return(1); 494 return(1);
384err: 495err:
385 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE); 496 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);
@@ -417,6 +528,10 @@ int tls1_enc(SSL *s, int send)
417 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx); 528 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx);
418 } 529 }
419 530
531#ifdef KSSL_DEBUG
532 printf("tls1_enc(%d)\n", send);
533#endif /* KSSL_DEBUG */
534
420 if ((s->session == NULL) || (ds == NULL) || 535 if ((s->session == NULL) || (ds == NULL) ||
421 (enc == NULL)) 536 (enc == NULL))
422 { 537 {
@@ -447,18 +562,45 @@ int tls1_enc(SSL *s, int send)
447 rec->length+=i; 562 rec->length+=i;
448 } 563 }
449 564
565#ifdef KSSL_DEBUG
566 {
567 unsigned long ui;
568 printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n",
569 ds,rec->data,rec->input,l);
570 printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n",
571 ds->buf_len, ds->cipher->key_len,
572 DES_KEY_SZ, DES_SCHEDULE_SZ,
573 ds->cipher->iv_len);
574 printf("\t\tIV: ");
575 for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]);
576 printf("\n");
577 printf("\trec->input=");
578 for (ui=0; ui<l; ui++) printf(" %02x", rec->input[ui]);
579 printf("\n");
580 }
581#endif /* KSSL_DEBUG */
582
450 if (!send) 583 if (!send)
451 { 584 {
452 if (l == 0 || l%bs != 0) 585 if (l == 0 || l%bs != 0)
453 { 586 {
454 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 587 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
455 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR); 588 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
456 return(0); 589 return 0;
457 } 590 }
458 } 591 }
459 592
460 EVP_Cipher(ds,rec->data,rec->input,l); 593 EVP_Cipher(ds,rec->data,rec->input,l);
461 594
595#ifdef KSSL_DEBUG
596 {
597 unsigned long i;
598 printf("\trec->data=");
599 for (i=0; i<l; i++)
600 printf(" %02x", rec->data[i]); printf("\n");
601 }
602#endif /* KSSL_DEBUG */
603
462 if ((bs != 1) && !send) 604 if ((bs != 1) && !send)
463 { 605 {
464 ii=i=rec->data[l-1]; /* padding_length */ 606 ii=i=rec->data[l-1]; /* padding_length */
@@ -476,17 +618,18 @@ int tls1_enc(SSL *s, int send)
476 * All of them must have value 'padding_length'. */ 618 * All of them must have value 'padding_length'. */
477 if (i > (int)rec->length) 619 if (i > (int)rec->length)
478 { 620 {
479 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 621 /* Incorrect padding. SSLerr() and ssl3_alert are done
480 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); 622 * by caller: we don't want to reveal whether this is
481 return(0); 623 * a decryption error or a MAC verification failure
624 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
625 return -1;
482 } 626 }
483 for (j=(int)(l-i); j<(int)l; j++) 627 for (j=(int)(l-i); j<(int)l; j++)
484 { 628 {
485 if (rec->data[j] != ii) 629 if (rec->data[j] != ii)
486 { 630 {
487 SSLerr(SSL_F_TLS1_ENC,SSL_R_DECRYPTION_FAILED); 631 /* Incorrect padding */
488 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); 632 return -1;
489 return(0);
490 } 633 }
491 } 634 }
492 rec->length-=i; 635 rec->length-=i;
@@ -500,8 +643,10 @@ int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in_ctx, unsigned char *out)
500 unsigned int ret; 643 unsigned int ret;
501 EVP_MD_CTX ctx; 644 EVP_MD_CTX ctx;
502 645
503 EVP_MD_CTX_copy(&ctx,in_ctx); 646 EVP_MD_CTX_init(&ctx);
504 EVP_DigestFinal(&ctx,out,&ret); 647 EVP_MD_CTX_copy_ex(&ctx,in_ctx);
648 EVP_DigestFinal_ex(&ctx,out,&ret);
649 EVP_MD_CTX_cleanup(&ctx);
505 return((int)ret); 650 return((int)ret);
506 } 651 }
507 652
@@ -517,17 +662,18 @@ int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
517 memcpy(q,str,slen); 662 memcpy(q,str,slen);
518 q+=slen; 663 q+=slen;
519 664
520 EVP_MD_CTX_copy(&ctx,in1_ctx); 665 EVP_MD_CTX_init(&ctx);
521 EVP_DigestFinal(&ctx,q,&i); 666 EVP_MD_CTX_copy_ex(&ctx,in1_ctx);
667 EVP_DigestFinal_ex(&ctx,q,&i);
522 q+=i; 668 q+=i;
523 EVP_MD_CTX_copy(&ctx,in2_ctx); 669 EVP_MD_CTX_copy_ex(&ctx,in2_ctx);
524 EVP_DigestFinal(&ctx,q,&i); 670 EVP_DigestFinal_ex(&ctx,q,&i);
525 q+=i; 671 q+=i;
526 672
527 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), 673 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf),
528 s->session->master_key,s->session->master_key_length, 674 s->session->master_key,s->session->master_key_length,
529 out,buf2,12); 675 out,buf2,12);
530 memset(&ctx,0,sizeof(EVP_MD_CTX)); 676 EVP_MD_CTX_cleanup(&ctx);
531 677
532 return((int)12); 678 return((int)12);
533 } 679 }
@@ -566,11 +712,13 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
566 buf[4]=rec->length&0xff; 712 buf[4]=rec->length&0xff;
567 713
568 /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */ 714 /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */
569 HMAC_Init(&hmac,mac_sec,EVP_MD_size(hash),hash); 715 HMAC_CTX_init(&hmac);
716 HMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash,NULL);
570 HMAC_Update(&hmac,seq,8); 717 HMAC_Update(&hmac,seq,8);
571 HMAC_Update(&hmac,buf,5); 718 HMAC_Update(&hmac,buf,5);
572 HMAC_Update(&hmac,rec->input,rec->length); 719 HMAC_Update(&hmac,rec->input,rec->length);
573 HMAC_Final(&hmac,md,&md_size); 720 HMAC_Final(&hmac,md,&md_size);
721 HMAC_CTX_cleanup(&hmac);
574 722
575#ifdef TLS_DEBUG 723#ifdef TLS_DEBUG
576printf("sec="); 724printf("sec=");
@@ -601,6 +749,10 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
601 unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE]; 749 unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE];
602 unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH]; 750 unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH];
603 751
752#ifdef KSSL_DEBUG
753 printf ("tls1_generate_master_secret(%p,%p, %p, %d)\n", s,out, p,len);
754#endif /* KSSL_DEBUG */
755
604 /* Setup the stuff to munge */ 756 /* Setup the stuff to munge */
605 memcpy(buf,TLS_MD_MASTER_SECRET_CONST, 757 memcpy(buf,TLS_MD_MASTER_SECRET_CONST,
606 TLS_MD_MASTER_SECRET_CONST_SIZE); 758 TLS_MD_MASTER_SECRET_CONST_SIZE);
@@ -611,6 +763,9 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
611 tls1_PRF(s->ctx->md5,s->ctx->sha1, 763 tls1_PRF(s->ctx->md5,s->ctx->sha1,
612 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, 764 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len,
613 s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); 765 s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE);
766#ifdef KSSL_DEBUG
767 printf ("tls1_generate_master_secret() complete\n");
768#endif /* KSSL_DEBUG */
614 return(SSL3_MASTER_SECRET_SIZE); 769 return(SSL3_MASTER_SECRET_SIZE);
615 } 770 }
616 771
diff --git a/src/lib/libssl/src/ssl/tls1.h b/src/lib/libssl/src/ssl/tls1.h
index cf92ae034f..88ec5fb527 100644
--- a/src/lib/libssl/src/ssl/tls1.h
+++ b/src/lib/libssl/src/ssl/tls1.h
@@ -96,6 +96,22 @@ extern "C" {
96#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 96#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065
97#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 97#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066
98 98
99 /* AES ciphersuites from draft ietf-tls-ciphersuite-03.txt */
100
101#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F
102#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030
103#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031
104#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032
105#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033
106#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034
107
108#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035
109#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036
110#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037
111#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038
112#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039
113#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A
114
99/* XXX 115/* XXX
100 * Inconsistency alert: 116 * Inconsistency alert:
101 * The OpenSSL names of ciphers with ephemeral DH here include the string 117 * The OpenSSL names of ciphers with ephemeral DH here include the string
@@ -110,6 +126,20 @@ extern "C" {
110#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" 126#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA"
111#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" 127#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA"
112#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" 128#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"
129 /* AES ciphersuites from draft-ietf-tls-ciphersuite-06.txt */
130#define TLS1_TXT_RSA_WITH_AES_128_SHA "AESdraft128-SHA"
131#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AESdraft128-SHA"
132#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AESdraft128-SHA"
133#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AESdraft128-SHA"
134#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AESdraft128-SHA"
135#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AESdraft128-SHA"
136
137#define TLS1_TXT_RSA_WITH_AES_256_SHA "AESdraft256-SHA"
138#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AESdraft256-SHA"
139#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AESdraft256-SHA"
140#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AESdraft256-SHA"
141#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AESdraft256-SHA"
142#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AESdraft256-SHA"
113 143
114 144
115#define TLS_CT_RSA_SIGN 1 145#define TLS_CT_RSA_SIGN 1
diff --git a/src/lib/libssl/src/test/Makefile.ssl b/src/lib/libssl/src/test/Makefile.ssl
index 7384243cbd..a11e3dfcd7 100644
--- a/src/lib/libssl/src/test/Makefile.ssl
+++ b/src/lib/libssl/src/test/Makefile.ssl
@@ -5,14 +5,15 @@
5DIR= test 5DIR= test
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDES= -I../include 8INCLUDES= -I$(TOP) -I../include $(KRB5_INCLUDES)
9CFLAG= -g 9CFLAG= -g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP= /usr/local/ssl 12INSTALLTOP= /usr/local/ssl
13MAKEFILE= Makefile.ssl 13MAKEFILE= Makefile.ssl
14MAKE= make -f $(MAKEFILE) 14MAKE= make -f $(MAKEFILE)
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16PERL= perl 17PERL= perl
17 18
18PEX_LIBS= 19PEX_LIBS=
@@ -31,6 +32,7 @@ LIBCRYPTO= -L.. -lcrypto
31LIBSSL= -L.. -lssl 32LIBSSL= -L.. -lssl
32 33
33BNTEST= bntest 34BNTEST= bntest
35ECTEST= ectest
34EXPTEST= exptest 36EXPTEST= exptest
35IDEATEST= ideatest 37IDEATEST= ideatest
36SHATEST= shatest 38SHATEST= shatest
@@ -54,27 +56,33 @@ METHTEST= methtest
54SSLTEST= ssltest 56SSLTEST= ssltest
55RSATEST= rsa_test 57RSATEST= rsa_test
56ENGINETEST= enginetest 58ENGINETEST= enginetest
59EVPTEST= evp_test
57 60
58EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD4TEST) $(MD5TEST) $(HMACTEST) \ 61TESTS= alltests
62
63EXE= $(BNTEST) $(ECTEST) $(IDEATEST) $(MD2TEST) $(MD4TEST) $(MD5TEST) $(HMACTEST) \
59 $(RC2TEST) $(RC4TEST) $(RC5TEST) \ 64 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
60 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ 65 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
61 $(RANDTEST) $(DHTEST) $(ENGINETEST) \ 66 $(RANDTEST) $(DHTEST) $(ENGINETEST) \
62 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) $(RSATEST) 67 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) $(RSATEST) \
68 $(EVPTEST)
63 69
64# $(METHTEST) 70# $(METHTEST)
65 71
66OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD4TEST).o $(MD5TEST).o \ 72OBJ= $(BNTEST).o $(ECTEST).o $(IDEATEST).o $(MD2TEST).o $(MD4TEST).o $(MD5TEST).o \
67 $(HMACTEST).o \ 73 $(HMACTEST).o \
68 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ 74 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
69 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ 75 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
70 $(RANDTEST).o $(DHTEST).o $(ENGINETEST).o $(CASTTEST).o \ 76 $(RANDTEST).o $(DHTEST).o $(ENGINETEST).o $(CASTTEST).o \
71 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o $(RSATEST).o 77 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o $(RSATEST).o \
72SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \ 78 $(EVPTEST).o
79SRC= $(BNTEST).c $(ECTEST).c $(IDEATEST).c $(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \
73 $(HMACTEST).c \ 80 $(HMACTEST).c \
74 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ 81 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
75 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ 82 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
76 $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c $(CASTTEST).c \ 83 $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c $(CASTTEST).c \
77 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c $(RSATEST).c 84 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c $(RSATEST).c \
85 $(EVPTEST).c
78 86
79EXHEADER= 87EXHEADER=
80HEADER= $(EXHEADER) 88HEADER= $(EXHEADER)
@@ -82,7 +90,7 @@ HEADER= $(EXHEADER)
82ALL= $(GENERAL) $(SRC) $(HEADER) 90ALL= $(GENERAL) $(SRC) $(HEADER)
83 91
84top: 92top:
85 (cd ..; $(MAKE) DIRS=$(DIR) all) 93 (cd ..; $(MAKE) DIRS=$(DIR) TESTS=$(TESTS) all)
86 94
87all: exe 95all: exe
88 96
@@ -101,16 +109,25 @@ install:
101tags: 109tags:
102 ctags $(SRC) 110 ctags $(SRC)
103 111
104tests: exe apps \ 112tests: exe apps $(TESTS)
113
114apps:
115 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
116
117alltests:
118 (LIBPATH="`cd ..; pwd`"; LD_LIBRARY_PATH=$$LIBPATH; SHLIB_PATH=$$LIBPATH; \
119 export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
120 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' alltests.chooser)
121alltests.chooser: \
105 test_des test_idea test_sha test_md4 test_md5 test_hmac \ 122 test_des test_idea test_sha test_md4 test_md5 test_hmac \
106 test_md2 test_mdc2 \ 123 test_md2 test_mdc2 \
107 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast \ 124 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast test_rd \
108 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \ 125 test_rand test_bn test_ec test_enc test_x509 test_rsa test_crl test_sid \
109 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \ 126 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \
110 test_ss test_ca test_engine test_ssl 127 test_ss test_ca test_engine test_evp test_ssl
111 128
112apps: 129test_evp:
113 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) 130 ./$(EVPTEST) evptests.txt
114 131
115test_des: 132test_des:
116 ./$(DESTEST) 133 ./$(DESTEST)
@@ -196,6 +213,10 @@ test_bn:
196 @echo 'test a^b%c implementations' 213 @echo 'test a^b%c implementations'
197 ./$(EXPTEST) 214 ./$(EXPTEST)
198 215
216test_ec:
217 @echo 'test elliptic curves'
218 ./$(ECTEST)
219
199test_verify: 220test_verify:
200 @echo "The following command should have some OK's and some failures" 221 @echo "The following command should have some OK's and some failures"
201 @echo "There are definitly a few expired certificates" 222 @echo "There are definitly a few expired certificates"
@@ -230,6 +251,10 @@ test_ca:
230 @echo "Generate and certify a test certificate via the 'ca' program" 251 @echo "Generate and certify a test certificate via the 'ca' program"
231 @sh ./testca 252 @sh ./testca
232 253
254test_rd: #$(RDTEST)
255# @echo "test Rijndael"
256# ./$(RDTEST)
257
233lint: 258lint:
234 lint -DLINT $(INCLUDES) $(SRC)>fluff 259 lint -DLINT $(INCLUDES) $(SRC)>fluff
235 260
@@ -241,7 +266,7 @@ dclean:
241 mv -f Makefile.new $(MAKEFILE) 266 mv -f Makefile.new $(MAKEFILE)
242 267
243clean: 268clean:
244 rm -f .rnd tmp.bntest tmp.bctest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log 269 rm -f .rnd tmp.bntest tmp.bctest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss *.srl log
245 270
246$(DLIBSSL): 271$(DLIBSSL):
247 (cd ../ssl; $(MAKE)) 272 (cd ../ssl; $(MAKE))
@@ -255,6 +280,9 @@ $(RSATEST): $(RSATEST).o $(DLIBCRYPTO)
255$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) 280$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
256 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 281 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257 282
283$(ECTEST): $(ECTEST).o $(DLIBCRYPTO)
284 $(CC) -o $(ECTEST) $(CFLAGS) $(ECTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
285
258$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) 286$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 287 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260 288
@@ -316,126 +344,198 @@ $(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
316 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 344 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
317 345
318$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) 346$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
319 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) 347 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBKRB5) $(LIBCRYPTO) $(EX_LIBS)
320 348
321$(ENGINETEST): $(ENGINETEST).o $(DLIBCRYPTO) 349$(ENGINETEST): $(ENGINETEST).o $(DLIBCRYPTO)
322 $(CC) -o $(ENGINETEST) $(CFLAGS) $(ENGINETEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 350 $(CC) -o $(ENGINETEST) $(CFLAGS) $(ENGINETEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
323 351
352$(EVPTEST): $(EVPTEST).o $(DLIBCRYPTO)
353 $(CC) -o $(EVPTEST) $(CFLAGS) $(EVPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
354
355#$(RDTEST).o: $(RDTEST).c
356# $(CC) -c $(CFLAGS) -DINTERMEDIATE_VALUE_KAT -DTRACE_KAT_MCT $(RDTEST).c
357
358#$(RDTEST): $(RDTEST).o $(DLIBCRYPTO)
359# $(CC) -o $(RDTEST) $(CFLAGS) $(RDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
360
324# DO NOT DELETE THIS LINE -- make depend depends on it. 361# DO NOT DELETE THIS LINE -- make depend depends on it.
325 362
326bftest.o: ../include/openssl/blowfish.h 363bftest.o: ../include/openssl/blowfish.h ../include/openssl/e_os2.h
327bntest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 364bftest.o: ../include/openssl/opensslconf.h bftest.c
328bntest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 365bntest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
329bntest.o: ../include/openssl/buffer.h ../include/openssl/cast.h 366bntest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
330bntest.o: ../include/openssl/crypto.h ../include/openssl/des.h 367bntest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
331bntest.o: ../include/openssl/dh.h ../include/openssl/dsa.h 368bntest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
332bntest.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
333bntest.o: ../include/openssl/err.h ../include/openssl/evp.h 369bntest.o: ../include/openssl/err.h ../include/openssl/evp.h
334bntest.o: ../include/openssl/idea.h ../include/openssl/lhash.h 370bntest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
335bntest.o: ../include/openssl/md2.h ../include/openssl/md4.h 371bntest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
336bntest.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 372bntest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
337bntest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
338bntest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
339bntest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 373bntest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
340bntest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
341bntest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
342bntest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 374bntest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
343bntest.o: ../include/openssl/sha.h ../include/openssl/stack.h 375bntest.o: ../include/openssl/sha.h ../include/openssl/stack.h
344bntest.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 376bntest.o: ../include/openssl/symhacks.h ../include/openssl/x509.h
345bntest.o: ../include/openssl/x509_vfy.h 377bntest.o: ../include/openssl/x509_vfy.h bntest.c
346casttest.o: ../include/openssl/cast.h 378casttest.o: ../include/openssl/cast.h casttest.c
347destest.o: ../include/openssl/des.h ../include/openssl/e_os2.h 379destest.o: ../include/openssl/crypto.h ../include/openssl/des.h
348destest.o: ../include/openssl/opensslconf.h 380destest.o: ../include/openssl/des_old.h ../include/openssl/e_os2.h
381destest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
382destest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
383destest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
384destest.o: ../include/openssl/ui_compat.h destest.c
349dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h 385dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h
350dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 386dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
351dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 387dhtest.o: ../include/openssl/e_os2.h ../include/openssl/err.h
388dhtest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
389dhtest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
352dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h 390dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
353dhtest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 391dhtest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h dhtest.c
354dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h 392dsatest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
355dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 393dsatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
356dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h 394dsatest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
357dsatest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 395dsatest.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
358dsatest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 396dsatest.o: ../include/openssl/err.h ../include/openssl/lhash.h
359dsatest.o: ../include/openssl/safestack.h ../include/openssl/stack.h 397dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
360dsatest.o: ../include/openssl/symhacks.h 398dsatest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
399dsatest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
400dsatest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
401dsatest.o: ../include/openssl/ui.h dsatest.c
402ectest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
403ectest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
404ectest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
405ectest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
406ectest.o: ../include/openssl/engine.h ../include/openssl/err.h
407ectest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
408ectest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
409ectest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
410ectest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
411ectest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h ectest.c
361enginetest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 412enginetest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
362enginetest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 413enginetest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
363enginetest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 414enginetest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
364enginetest.o: ../include/openssl/des.h ../include/openssl/dh.h
365enginetest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 415enginetest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
366enginetest.o: ../include/openssl/engine.h ../include/openssl/err.h 416enginetest.o: ../include/openssl/engine.h ../include/openssl/err.h
367enginetest.o: ../include/openssl/evp.h ../include/openssl/idea.h 417enginetest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
368enginetest.o: ../include/openssl/lhash.h ../include/openssl/md2.h 418enginetest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
369enginetest.o: ../include/openssl/md4.h ../include/openssl/md5.h 419enginetest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
370enginetest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 420enginetest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
371enginetest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 421enginetest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
372enginetest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 422enginetest.o: enginetest.c
373enginetest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 423evp_test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
374enginetest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 424evp_test.o: ../include/openssl/bn.h ../include/openssl/conf.h
375enginetest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 425evp_test.o: ../include/openssl/crypto.h ../include/openssl/dh.h
376enginetest.o: ../include/openssl/sha.h ../include/openssl/stack.h 426evp_test.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
377enginetest.o: ../include/openssl/symhacks.h 427evp_test.o: ../include/openssl/engine.h ../include/openssl/err.h
428evp_test.o: ../include/openssl/evp.h ../include/openssl/lhash.h
429evp_test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
430evp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
431evp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
432evp_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
433evp_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
434evp_test.o: ../include/openssl/ui.h evp_test.c
378exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h 435exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h
379exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h 436exptest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
380exptest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 437exptest.o: ../include/openssl/err.h ../include/openssl/lhash.h
381exptest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 438exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
439exptest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
382exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h 440exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
383exptest.o: ../include/openssl/symhacks.h 441exptest.o: ../include/openssl/symhacks.h exptest.c
384hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 442hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
385hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 443hmactest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
386hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 444hmactest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
387hmactest.o: ../include/openssl/des.h ../include/openssl/dh.h 445hmactest.o: ../include/openssl/hmac.h ../include/openssl/md5.h
388hmactest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 446hmactest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
389hmactest.o: ../include/openssl/evp.h ../include/openssl/hmac.h 447hmactest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
390hmactest.o: ../include/openssl/idea.h ../include/openssl/md2.h 448hmactest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
391hmactest.o: ../include/openssl/md4.h ../include/openssl/md5.h 449hmactest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h hmactest.c
392hmactest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
393hmactest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
394hmactest.o: ../include/openssl/opensslv.h ../include/openssl/rc2.h
395hmactest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
396hmactest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
397hmactest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
398hmactest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
399ideatest.o: ../include/openssl/idea.h ../include/openssl/opensslconf.h 450ideatest.o: ../include/openssl/idea.h ../include/openssl/opensslconf.h
400md2test.o: ../include/openssl/md2.h ../include/openssl/opensslconf.h 451ideatest.o: ideatest.c
401md4test.o: ../include/openssl/md4.h 452md2test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
402md5test.o: ../include/openssl/md5.h 453md2test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
403mdc2test.o: ../include/openssl/des.h ../include/openssl/e_os2.h 454md2test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
404mdc2test.o: ../include/openssl/mdc2.h ../include/openssl/opensslconf.h 455md2test.o: ../include/openssl/md2.h ../include/openssl/obj_mac.h
405randtest.o: ../include/openssl/rand.h 456md2test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
406rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h 457md2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
407rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h 458md2test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
408rc5test.o: ../include/openssl/rc5.h 459md2test.o: ../include/openssl/symhacks.h md2test.c
409rmdtest.o: ../include/openssl/ripemd.h 460md4test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
410rsa_test.o: ../include/openssl/bio.h ../include/openssl/bn.h 461md4test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
411rsa_test.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 462md4test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
412rsa_test.o: ../include/openssl/e_os2.h ../include/openssl/err.h 463md4test.o: ../include/openssl/md4.h ../include/openssl/obj_mac.h
413rsa_test.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 464md4test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
414rsa_test.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 465md4test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
466md4test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
467md4test.o: ../include/openssl/symhacks.h md4test.c
468md5test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
469md5test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
470md5test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
471md5test.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
472md5test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
473md5test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
474md5test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
475md5test.o: ../include/openssl/symhacks.h md5test.c
476mdc2test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
477mdc2test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
478mdc2test.o: ../include/openssl/des.h ../include/openssl/des_old.h
479mdc2test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
480mdc2test.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
481mdc2test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
482mdc2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
483mdc2test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
484mdc2test.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
485mdc2test.o: ../include/openssl/ui_compat.h mdc2test.c
486randtest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h randtest.c
487rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h rc2test.c
488rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h rc4test.c
489rc5test.o: ../include/openssl/rc5.h rc5test.c
490rmdtest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
491rmdtest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
492rmdtest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
493rmdtest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
494rmdtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
495rmdtest.o: ../include/openssl/ossl_typ.h ../include/openssl/ripemd.h
496rmdtest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
497rmdtest.o: ../include/openssl/symhacks.h rmdtest.c
498rsa_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
499rsa_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
500rsa_test.o: ../include/openssl/dh.h ../include/openssl/dsa.h
501rsa_test.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
502rsa_test.o: ../include/openssl/err.h ../include/openssl/lhash.h
503rsa_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
504rsa_test.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
415rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 505rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
416rsa_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 506rsa_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
417sha1test.o: ../include/openssl/sha.h 507rsa_test.o: ../include/openssl/ui.h rsa_test.c
418shatest.o: ../include/openssl/sha.h 508sha1test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
419ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 509sha1test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
420ssltest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 510sha1test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
421ssltest.o: ../include/openssl/buffer.h ../include/openssl/cast.h 511sha1test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
512sha1test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
513sha1test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
514sha1test.o: ../include/openssl/sha.h ../include/openssl/stack.h
515sha1test.o: ../include/openssl/symhacks.h sha1test.c
516shatest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
517shatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
518shatest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
519shatest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
520shatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
521shatest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
522shatest.o: ../include/openssl/sha.h ../include/openssl/stack.h
523shatest.o: ../include/openssl/symhacks.h shatest.c
524ssltest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
525ssltest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
422ssltest.o: ../include/openssl/comp.h ../include/openssl/crypto.h 526ssltest.o: ../include/openssl/comp.h ../include/openssl/crypto.h
423ssltest.o: ../include/openssl/des.h ../include/openssl/dh.h 527ssltest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
424ssltest.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 528ssltest.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
425ssltest.o: ../include/openssl/e_os2.h ../include/openssl/err.h 529ssltest.o: ../include/openssl/err.h ../include/openssl/evp.h
426ssltest.o: ../include/openssl/evp.h ../include/openssl/idea.h 530ssltest.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
427ssltest.o: ../include/openssl/lhash.h ../include/openssl/md2.h 531ssltest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
428ssltest.o: ../include/openssl/md4.h ../include/openssl/md5.h 532ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
429ssltest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 533ssltest.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
430ssltest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
431ssltest.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
432ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 534ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
433ssltest.o: ../include/openssl/rand.h ../include/openssl/rc2.h 535ssltest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
434ssltest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
435ssltest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
436ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h 536ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
437ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 537ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
438ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 538ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
439ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 539ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
440ssltest.o: ../include/openssl/tls1.h ../include/openssl/x509.h 540ssltest.o: ../include/openssl/tls1.h ../include/openssl/ui.h
441ssltest.o: ../include/openssl/x509_vfy.h 541ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.c
diff --git a/src/lib/libssl/src/test/maketests.com b/src/lib/libssl/src/test/maketests.com
index 135e0bfeb9..e0be3dd43b 100644
--- a/src/lib/libssl/src/test/maketests.com
+++ b/src/lib/libssl/src/test/maketests.com
@@ -143,11 +143,12 @@ $ GOSUB CHECK_OPT_FILE
143$! 143$!
144$! Define The TEST Files. 144$! Define The TEST Files.
145$! 145$!
146$ TEST_FILES = "BNTEST,IDEATEST,MD2TEST,MD4TEST,MD5TEST,HMACTEST,"+ - 146$ TEST_FILES = "BNTEST,ECTEST,IDEATEST,MD2TEST,MD4TEST,MD5TEST,HMACTEST,"+ -
147 "RC2TEST,RC4TEST,RC5TEST,"+ - 147 "RC2TEST,RC4TEST,RC5TEST,"+ -
148 "DESTEST,SHATEST,SHA1TEST,MDC2TEST,RMDTEST,"+ - 148 "DESTEST,SHATEST,SHA1TEST,MDC2TEST,RMDTEST,"+ -
149 "RANDTEST,DHTEST,"+ - 149 "RANDTEST,DHTEST,ENGINETEST,"+ -
150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST" 150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST,"+ -
151 "EVP_TEST"
151$ TCPIP_PROGRAMS = ",," 152$ TCPIP_PROGRAMS = ",,"
152$ IF COMPILER .EQS. "VAXC" THEN - 153$ IF COMPILER .EQS. "VAXC" THEN -
153 TCPIP_PROGRAMS = ",SSLTEST," 154 TCPIP_PROGRAMS = ",SSLTEST,"
@@ -514,6 +515,7 @@ $ CHECK_OPTIONS:
514$! 515$!
515$! Check To See If P1 Is Blank. 516$! Check To See If P1 Is Blank.
516$! 517$!
518$ P1 = "NORSAREF"
517$ IF (P1.EQS."NORSAREF") 519$ IF (P1.EQS."NORSAREF")
518$ THEN 520$ THEN
519$! 521$!
@@ -729,31 +731,7 @@ $ ENDIF
729$! 731$!
730$! Set Up Initial CC Definitions, Possibly With User Ones 732$! Set Up Initial CC Definitions, Possibly With User Ones
731$! 733$!
732$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 734$ CCDEFS = "TCPIP_TYPE_''P4'"
733$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
734$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
735$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
736$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
737$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
738$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
739$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
740$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
741$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
742$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
743$ IF F$TRNLNM("OPENSSL_NO_DES")
744$ THEN
745$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
746$ ELSE
747$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
748$ ENDIF
749$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
750$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
751$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
752$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
753$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
754$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
755$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
756$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
757$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 735$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
758$ CCEXTRAFLAGS = "" 736$ CCEXTRAFLAGS = ""
759$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 737$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -785,7 +763,8 @@ $ CC = "CC"
785$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" - 763$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
786 THEN CC = "CC/DECC" 764 THEN CC = "CC/DECC"
787$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 765$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
788 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS 766 "/NOLIST/PREFIX=ALL" + -
767 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
789$! 768$!
790$! Define The Linker Options File Name. 769$! Define The Linker Options File Name.
791$! 770$!
@@ -817,7 +796,8 @@ $ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
817$ EXIT 796$ EXIT
818$ ENDIF 797$ ENDIF
819$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 798$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
820$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 799$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
800 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
821$ CCDEFS = CCDEFS + ",""VAXC""" 801$ CCDEFS = CCDEFS + ",""VAXC"""
822$! 802$!
823$! Define <sys> As SYS$COMMON:[SYSLIB] 803$! Define <sys> As SYS$COMMON:[SYSLIB]
@@ -847,7 +827,8 @@ $ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
847$! 827$!
848$! Use GNU C... 828$! Use GNU C...
849$! 829$!
850$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 830$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
831 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
851$! 832$!
852$! Define The Linker Options File Name. 833$! Define The Linker Options File Name.
853$! 834$!
@@ -1050,6 +1031,7 @@ $!
1050$! Save directory information 1031$! Save directory information
1051$! 1032$!
1052$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;" 1033$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1034$ __HERE = F$EDIT(__HERE,"UPCASE")
1053$ __TOP = __HERE - "TEST]" 1035$ __TOP = __HERE - "TEST]"
1054$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]" 1036$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1055$! 1037$!
diff --git a/src/lib/libssl/src/test/tests.com b/src/lib/libssl/src/test/tests.com
index df8f46e75d..07a3c7f16d 100644
--- a/src/lib/libssl/src/test/tests.com
+++ b/src/lib/libssl/src/test/tests.com
@@ -21,14 +21,15 @@ $ else
21$ tests := - 21$ tests := -
22 test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,- 22 test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,-
23 test_md2,test_mdc2,- 23 test_md2,test_mdc2,-
24 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,- 24 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,test_rd,-
25 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,- 25 test_rand,test_bn,test_ec,test_enc,test_x509,test_rsa,test_crl,test_sid,-
26 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,- 26 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
27 test_ss,test_ca,test_ssl 27 test_ss,test_ca,test_engine,test_ssl,test_evp
28$ endif 28$ endif
29$ tests = f$edit(tests,"COLLAPSE") 29$ tests = f$edit(tests,"COLLAPSE")
30$ 30$
31$ BNTEST := bntest 31$ BNTEST := bntest
32$ ECTEST := ectest
32$ EXPTEST := exptest 33$ EXPTEST := exptest
33$ IDEATEST := ideatest 34$ IDEATEST := ideatest
34$ SHATEST := shatest 35$ SHATEST := shatest
@@ -51,6 +52,8 @@ $ DSATEST := dsatest
51$ METHTEST := methtest 52$ METHTEST := methtest
52$ SSLTEST := ssltest 53$ SSLTEST := ssltest
53$ RSATEST := rsa_test 54$ RSATEST := rsa_test
55$ ENGINETEST := enginetest
56$ EVPTEST := evp_test
54$ 57$
55$ tests_i = 0 58$ tests_i = 0
56$ loop_tests: 59$ loop_tests:
@@ -60,6 +63,9 @@ $ if tests_e .eqs. "," then goto exit
60$ gosub 'tests_e' 63$ gosub 'tests_e'
61$ goto loop_tests 64$ goto loop_tests
62$ 65$
66$ test_evp:
67$ mcr 'texe_dir''evptest' evptests.txt
68$ return
63$ test_des: 69$ test_des:
64$ mcr 'texe_dir''destest' 70$ mcr 'texe_dir''destest'
65$ return 71$ return
@@ -157,7 +163,7 @@ RECORD
157$ create/fdl=bntest-vms.fdl bntest-vms.sh 163$ create/fdl=bntest-vms.fdl bntest-vms.sh
158$ open/append foo bntest-vms.sh 164$ open/append foo bntest-vms.sh
159$ type/output=foo: sys$input: 165$ type/output=foo: sys$input:
160<< __FOO__ bc | perl -e 'while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} print STDERR "."; $i++;} print STDERR "\n$i tests passed\n"' 166<< __FOO__ sh -c "`sh ./bctest`" | perl -e '$i=0; while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} else {print STDERR "."; $i++;}} print STDERR "\n$i tests passed\n"'
161$ define/user sys$output bntest-vms.tmp 167$ define/user sys$output bntest-vms.tmp
162$ mcr 'texe_dir''bntest' 168$ mcr 'texe_dir''bntest'
163$ copy bntest-vms.tmp foo: 169$ copy bntest-vms.tmp foo:
@@ -165,12 +171,17 @@ $ delete bntest-vms.tmp;*
165$ type/output=foo: sys$input: 171$ type/output=foo: sys$input:
166__FOO__ 172__FOO__
167$ close foo 173$ close foo
168$ write sys$output "-- copy the [.test]bntest-vms.sh file to a Unix system and run it" 174$ write sys$output "-- copy the [.test]bntest-vms.sh and [.test]bctest files to a Unix system and"
169$ write sys$output "-- through sh or bash to verify that the bignum operations went well." 175$ write sys$output "-- run bntest-vms.sh through sh or bash to verify that the bignum operations"
176$ write sys$output "-- went well."
170$ write sys$output "" 177$ write sys$output ""
171$ write sys$output "test a^b%c implementations" 178$ write sys$output "test a^b%c implementations"
172$ mcr 'texe_dir''exptest' 179$ mcr 'texe_dir''exptest'
173$ return 180$ return
181$ test_ec:
182$ write sys$output "test elliptic curves"
183$ mcr 'texe_dir''ectest'
184$ return
174$ test_verify: 185$ test_verify:
175$ write sys$output "The following command should have some OK's and some failures" 186$ write sys$output "The following command should have some OK's and some failures"
176$ write sys$output "There are definitly a few expired certificates" 187$ write sys$output "There are definitly a few expired certificates"
@@ -201,6 +212,10 @@ $ test_ss:
201$ write sys$output "Generate and certify a test certificate" 212$ write sys$output "Generate and certify a test certificate"
202$ @testss.com 213$ @testss.com
203$ return 214$ return
215$ test_engine:
216$ write sys$output "Manipulate the ENGINE structures"
217$ mcr 'texe_dir''enginetest'
218$ return
204$ test_ssl: 219$ test_ssl:
205$ write sys$output "test SSL protocol" 220$ write sys$output "test SSL protocol"
206$ gosub maybe_test_ss 221$ gosub maybe_test_ss
@@ -220,6 +235,10 @@ $ write sys$output "Generate and certify a test certificate via the 'ca' pro
220$ @testca.com 235$ @testca.com
221$ endif 236$ endif
222$ return 237$ return
238$ test_rd:
239$ write sys$output "test Rijndael"
240$ !mcr 'texe_dir''rdtest'
241$ return
223$ 242$
224$ 243$
225$ exit: 244$ exit:
diff --git a/src/lib/libssl/src/test/testss b/src/lib/libssl/src/test/testss
index da62997a5f..8d3557f356 100644
--- a/src/lib/libssl/src/test/testss
+++ b/src/lib/libssl/src/test/testss
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2 2
3digest='-mdc2' 3digest='-md5'
4reqcmd="../apps/openssl req" 4reqcmd="../apps/openssl req"
5x509cmd="../apps/openssl x509 $digest" 5x509cmd="../apps/openssl x509 $digest"
6verifycmd="../apps/openssl verify" 6verifycmd="../apps/openssl verify"
@@ -19,7 +19,16 @@ Ucert="certU.ss"
19 19
20echo 20echo
21echo "make a certificate request using 'req'" 21echo "make a certificate request using 'req'"
22$reqcmd -config $CAconf -out $CAreq -keyout $CAkey -new #>err.ss 22
23echo "string to make the random number generator think it has entropy" >> ./.rnd
24
25if ../apps/openssl no-rsa; then
26 req_new='-newkey dsa:../apps/dsa512.pem'
27else
28 req_new='-new'
29fi
30
31$reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss
23if [ $? != 0 ]; then 32if [ $? != 0 ]; then
24 echo "error using 'req' to generate a certificate request" 33 echo "error using 'req' to generate a certificate request"
25 exit 1 34 exit 1
@@ -60,7 +69,7 @@ fi
60 69
61echo 70echo
62echo "make another certificate request using 'req'" 71echo "make another certificate request using 'req'"
63$reqcmd -config $Uconf -out $Ureq -keyout $Ukey -new >err.ss 72$reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss
64if [ $? != 0 ]; then 73if [ $? != 0 ]; then
65 echo "error using 'req' to generate a certificate request" 74 echo "error using 'req' to generate a certificate request"
66 exit 1 75 exit 1
diff --git a/src/lib/libssl/src/test/testssl b/src/lib/libssl/src/test/testssl
index a88e290c57..ba5e41c861 100644
--- a/src/lib/libssl/src/test/testssl
+++ b/src/lib/libssl/src/test/testssl
@@ -1,81 +1,137 @@
1#!/bin/sh 1#!/bin/sh
2 2
3if [ "$1" = "" ]; then
4 key=../apps/server.pem
5else
6 key="$1"
7fi
8if [ "$2" = "" ]; then
9 cert=../apps/server.pem
10else
11 cert="$2"
12fi
13ssltest="./ssltest -key $key -cert $cert -c_key $key -c_cert $cert"
14
15if ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then
16 dsa_cert=YES
17else
18 dsa_cert=NO
19fi
20
21if [ "$3" = "" ]; then
22 CA="-CApath ../certs"
23else
24 CA="-CAfile $3"
25fi
26
27if [ "$4" = "" ]; then
28 extra=""
29else
30 extra="$4"
31fi
32
33#############################################################################
34
3echo test sslv2 35echo test sslv2
4./ssltest -ssl2 || exit 1 36$ssltest -ssl2 $extra || exit 1
5 37
6echo test sslv2 with server authentication 38echo test sslv2 with server authentication
7./ssltest -ssl2 -server_auth -CApath ../certs || exit 1 39$ssltest -ssl2 -server_auth $CA $extra || exit 1
8 40
9echo test sslv2 with client authentication 41if [ $dsa_cert = NO ]; then
10./ssltest -ssl2 -client_auth -CApath ../certs || exit 1 42 echo test sslv2 with client authentication
43 $ssltest -ssl2 -client_auth $CA $extra || exit 1
11 44
12echo test sslv2 with both client and server authentication 45 echo test sslv2 with both client and server authentication
13./ssltest -ssl2 -server_auth -client_auth -CApath ../certs || exit 1 46 $ssltest -ssl2 -server_auth -client_auth $CA $extra || exit 1
47fi
14 48
15echo test sslv3 49echo test sslv3
16./ssltest -ssl3 || exit 1 50$ssltest -ssl3 $extra || exit 1
17 51
18echo test sslv3 with server authentication 52echo test sslv3 with server authentication
19./ssltest -ssl3 -server_auth -CApath ../certs || exit 1 53$ssltest -ssl3 -server_auth $CA $extra || exit 1
20 54
21echo test sslv3 with client authentication 55echo test sslv3 with client authentication
22./ssltest -ssl3 -client_auth -CApath ../certs || exit 1 56$ssltest -ssl3 -client_auth $CA $extra || exit 1
23 57
24echo test sslv3 with both client and server authentication 58echo test sslv3 with both client and server authentication
25./ssltest -ssl3 -server_auth -client_auth -CApath ../certs || exit 1 59$ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1
26 60
27echo test sslv2/sslv3 61echo test sslv2/sslv3
28./ssltest || exit 1 62$ssltest $extra || exit 1
29 63
30echo test sslv2/sslv3 with server authentication 64echo test sslv2/sslv3 with server authentication
31./ssltest -server_auth -CApath ../certs || exit 1 65$ssltest -server_auth $CA $extra || exit 1
32 66
33echo test sslv2/sslv3 with client authentication 67echo test sslv2/sslv3 with client authentication
34./ssltest -client_auth -CApath ../certs || exit 1 68$ssltest -client_auth $CA $extra || exit 1
35 69
36echo test sslv2/sslv3 with both client and server authentication 70echo test sslv2/sslv3 with both client and server authentication
37./ssltest -server_auth -client_auth -CApath ../certs || exit 1 71$ssltest -server_auth -client_auth $CA $extra || exit 1
38 72
39echo test sslv2 via BIO pair 73echo test sslv2 via BIO pair
40./ssltest -bio_pair -ssl2 || exit 1 74$ssltest -bio_pair -ssl2 $extra || exit 1
41 75
42echo test sslv2 with server authentication via BIO pair 76echo test sslv2 with server authentication via BIO pair
43./ssltest -bio_pair -ssl2 -server_auth -CApath ../certs || exit 1 77$ssltest -bio_pair -ssl2 -server_auth $CA $extra || exit 1
44 78
45echo test sslv2 with client authentication via BIO pair 79if [ $dsa_cert = NO ]; then
46./ssltest -bio_pair -ssl2 -client_auth -CApath ../certs || exit 1 80 echo test sslv2 with client authentication via BIO pair
81 $ssltest -bio_pair -ssl2 -client_auth $CA $extra || exit 1
47 82
48echo test sslv2 with both client and server authentication via BIO pair 83 echo test sslv2 with both client and server authentication via BIO pair
49./ssltest -bio_pair -ssl2 -server_auth -client_auth -CApath ../certs || exit 1 84 $ssltest -bio_pair -ssl2 -server_auth -client_auth $CA $extra || exit 1
85fi
50 86
51echo test sslv3 via BIO pair 87echo test sslv3 via BIO pair
52./ssltest -bio_pair -ssl3 || exit 1 88$ssltest -bio_pair -ssl3 $extra || exit 1
53 89
54echo test sslv3 with server authentication via BIO pair 90echo test sslv3 with server authentication via BIO pair
55./ssltest -bio_pair -ssl3 -server_auth -CApath ../certs || exit 1 91$ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1
56 92
57echo test sslv3 with client authentication via BIO pair 93echo test sslv3 with client authentication via BIO pair
58./ssltest -bio_pair -ssl3 -client_auth -CApath ../certs || exit 1 94$ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1
59 95
60echo test sslv3 with both client and server authentication via BIO pair 96echo test sslv3 with both client and server authentication via BIO pair
61./ssltest -bio_pair -ssl3 -server_auth -client_auth -CApath ../certs || exit 1 97$ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1
62 98
63echo test sslv2/sslv3 via BIO pair 99echo test sslv2/sslv3 via BIO pair
64./ssltest || exit 1 100$ssltest $extra || exit 1
65 101
66echo test sslv2/sslv3 w/o DHE via BIO pair 102if [ $dsa_cert = NO ]; then
67./ssltest -bio_pair -no_dhe || exit 1 103 echo test sslv2/sslv3 w/o DHE via BIO pair
104 $ssltest -bio_pair -no_dhe $extra || exit 1
105fi
68 106
69echo test sslv2/sslv3 with 1024bit DHE 107echo test sslv2/sslv3 with 1024bit DHE via BIO pair
70./ssltest -bio_pair -dhe1024 -v || exit 1 108$ssltest -bio_pair -dhe1024dsa -v $extra || exit 1
71 109
72echo test sslv2/sslv3 with server authentication 110echo test sslv2/sslv3 with server authentication
73./ssltest -bio_pair -server_auth -CApath ../certs || exit 1 111$ssltest -bio_pair -server_auth $CA $extra || exit 1
74 112
75echo test sslv2/sslv3 with client authentication via BIO pair 113echo test sslv2/sslv3 with client authentication via BIO pair
76./ssltest -bio_pair -client_auth -CApath ../certs || exit 1 114$ssltest -bio_pair -client_auth $CA $extra || exit 1
77 115
78echo test sslv2/sslv3 with both client and server authentication via BIO pair 116echo test sslv2/sslv3 with both client and server authentication via BIO pair
79./ssltest -bio_pair -server_auth -client_auth -CApath ../certs || exit 1 117$ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1
118
119echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify
120$ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1
121
122#############################################################################
123
124echo test tls1 with 1024bit anonymous DH, multiple handshakes
125$ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1
126
127if ../apps/openssl no-rsa; then
128 echo skipping RSA tests
129else
130 echo test tls1 with 1024bit RSA, no DHE, multiple handshakes
131 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1
132
133 echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
134 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
135fi
80 136
81exit 0 137exit 0
diff --git a/src/lib/libssl/src/test/tmp.bctest b/src/lib/libssl/src/test/tmp.bctest
new file mode 100644
index 0000000000..aa47d0d46d
--- /dev/null
+++ b/src/lib/libssl/src/test/tmp.bctest
@@ -0,0 +1,2 @@
10
20
diff --git a/src/lib/libssl/src/tools/Makefile.ssl b/src/lib/libssl/src/tools/Makefile.ssl
index 537e6ed98d..efbc284299 100644
--- a/src/lib/libssl/src/tools/Makefile.ssl
+++ b/src/lib/libssl/src/tools/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= tools 5DIR= tools
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -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
16 17
17CFLAGS= $(INCLUDES) $(CFLAG) 18CFLAGS= $(INCLUDES) $(CFLAG)
diff --git a/src/lib/libssl/src/tools/c89.sh b/src/lib/libssl/src/tools/c89.sh
new file mode 100644
index 0000000000..b25c9fda2d
--- /dev/null
+++ b/src/lib/libssl/src/tools/c89.sh
@@ -0,0 +1,15 @@
1#!/bin/sh -k
2#
3# Re-order arguments so that -L comes first
4#
5opts=""
6lopts=""
7
8for arg in $* ; do
9 case $arg in
10 -L*) lopts="$lopts $arg" ;;
11 *) opts="$opts $arg" ;;
12 esac
13done
14
15c89 $lopts $opts
diff --git a/src/lib/libssl/src/tools/c_rehash.in b/src/lib/libssl/src/tools/c_rehash.in
index 26db8999d8..69da98ff2c 100644
--- a/src/lib/libssl/src/tools/c_rehash.in
+++ b/src/lib/libssl/src/tools/c_rehash.in
@@ -100,7 +100,7 @@ sub check_file {
100 100
101sub link_hash_cert { 101sub link_hash_cert {
102 my $fname = $_[0]; 102 my $fname = $_[0];
103 my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in $fname`; 103 my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in "$fname"`;
104 chomp $hash; 104 chomp $hash;
105 chomp $fprint; 105 chomp $fprint;
106 $fprint =~ s/^.*=//; 106 $fprint =~ s/^.*=//;
@@ -130,7 +130,7 @@ sub link_hash_cert {
130 130
131sub link_hash_crl { 131sub link_hash_crl {
132 my $fname = $_[0]; 132 my $fname = $_[0];
133 my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in $fname`; 133 my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in "$fname"`;
134 chomp $hash; 134 chomp $hash;
135 chomp $fprint; 135 chomp $fprint;
136 $fprint =~ s/^.*=//; 136 $fprint =~ s/^.*=//;
diff --git a/src/lib/libssl/src/util/clean-depend.pl b/src/lib/libssl/src/util/clean-depend.pl
index 0193e726fe..6c485d1e2f 100644
--- a/src/lib/libssl/src/util/clean-depend.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/cygwin.sh b/src/lib/libssl/src/util/cygwin.sh
new file mode 100644
index 0000000000..b607399b02
--- /dev/null
+++ b/src/lib/libssl/src/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/libssl/src/util/domd b/src/lib/libssl/src/util/domd
index 9f75131f22..aa99cb0523 100644
--- a/src/lib/libssl/src/util/domd
+++ b/src/lib/libssl/src/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/libssl/src/util/libeay.num b/src/lib/libssl/src/util/libeay.num
index 84ae840804..b74749e5de 100644
--- a/src/lib/libssl/src/util/libeay.num
+++ b/src/lib/libssl/src/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/libssl/src/util/mk1mf.pl b/src/lib/libssl/src/util/mk1mf.pl
index 46755fa287..8b6b2e668a 100644
--- a/src/lib/libssl/src/util/mk1mf.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkdef.pl b/src/lib/libssl/src/util/mkdef.pl
index ba453358cf..071036a6d2 100644
--- a/src/lib/libssl/src/util/mkdef.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkerr.pl b/src/lib/libssl/src/util/mkerr.pl
index 7d98b5234d..6c2237d142 100644
--- a/src/lib/libssl/src/util/mkerr.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkfiles.pl b/src/lib/libssl/src/util/mkfiles.pl
index 470feea76f..29e1404c69 100644
--- a/src/lib/libssl/src/util/mkfiles.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/mkstack.pl b/src/lib/libssl/src/util/mkstack.pl
index 3ee13fe7c9..085c50f790 100644
--- a/src/lib/libssl/src/util/mkstack.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/BC-16.pl b/src/lib/libssl/src/util/pl/BC-16.pl
index 6c6df4fe0b..2033f524ca 100644
--- a/src/lib/libssl/src/util/pl/BC-16.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/BC-32.pl b/src/lib/libssl/src/util/pl/BC-32.pl
index 20cb3a9c50..78d60616a6 100644
--- a/src/lib/libssl/src/util/pl/BC-32.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/OS2-EMX.pl b/src/lib/libssl/src/util/pl/OS2-EMX.pl
new file mode 100644
index 0000000000..57180556ca
--- /dev/null
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/VC-16.pl b/src/lib/libssl/src/util/pl/VC-16.pl
index a5079d4ca7..7cda5e67a9 100644
--- a/src/lib/libssl/src/util/pl/VC-16.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/pl/VC-32.pl b/src/lib/libssl/src/util/pl/VC-32.pl
index 7c6674b971..50bfb34385 100644
--- a/src/lib/libssl/src/util/pl/VC-32.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/selftest.pl b/src/lib/libssl/src/util/selftest.pl
index eb50d52ff8..276b81183d 100644
--- a/src/lib/libssl/src/util/selftest.pl
+++ b/src/lib/libssl/src/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/libssl/src/util/ssleay.num b/src/lib/libssl/src/util/ssleay.num
index 561bac2ec9..fdea47205d 100644
--- a/src/lib/libssl/src/util/ssleay.num
+++ b/src/lib/libssl/src/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/libssl/ssl.h b/src/lib/libssl/ssl.h
index 9de9e611ab..833f761690 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -55,20 +55,130 @@
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 */
111/* ====================================================================
112 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
113 *
114 * Redistribution and use in source and binary forms, with or without
115 * modification, are permitted provided that the following conditions
116 * are met:
117 *
118 * 1. Redistributions of source code must retain the above copyright
119 * notice, this list of conditions and the following disclaimer.
120 *
121 * 2. Redistributions in binary form must reproduce the above copyright
122 * notice, this list of conditions and the following disclaimer in
123 * the documentation and/or other materials provided with the
124 * distribution.
125 *
126 * 3. All advertising materials mentioning features or use of this
127 * software must display the following acknowledgment:
128 * "This product includes software developed by the OpenSSL Project
129 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
130 *
131 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
132 * endorse or promote products derived from this software without
133 * prior written permission. For written permission, please contact
134 * openssl-core@openssl.org.
135 *
136 * 5. Products derived from this software may not be called "OpenSSL"
137 * nor may "OpenSSL" appear in their names without prior written
138 * permission of the OpenSSL Project.
139 *
140 * 6. Redistributions of any form whatsoever must retain the following
141 * acknowledgment:
142 * "This product includes software developed by the OpenSSL Project
143 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
144 *
145 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
146 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
147 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
148 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
149 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
150 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
151 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
152 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
153 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
154 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
155 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
156 * OF THE POSSIBILITY OF SUCH DAMAGE.
157 * ====================================================================
158 *
159 * This product includes cryptographic software written by Eric Young
160 * (eay@cryptsoft.com). This product includes software written by Tim
161 * Hudson (tjh@cryptsoft.com).
162 *
163 */
58 164
59#ifndef HEADER_SSL_H 165#ifndef HEADER_SSL_H
60#define HEADER_SSL_H 166#define HEADER_SSL_H
61 167
62#ifndef NO_COMP 168#include <openssl/e_os2.h>
169
170#ifndef OPENSSL_NO_COMP
63#include <openssl/comp.h> 171#include <openssl/comp.h>
64#endif 172#endif
65#ifndef NO_BIO 173#ifndef OPENSSL_NO_BIO
66#include <openssl/bio.h> 174#include <openssl/bio.h>
67#endif 175#endif
68#ifndef NO_X509 176#ifndef OPENSSL_NO_X509
69#include <openssl/x509.h> 177#include <openssl/x509.h>
70#endif 178#endif
179#include <openssl/kssl.h>
71#include <openssl/safestack.h> 180#include <openssl/safestack.h>
181#include <openssl/symhacks.h>
72 182
73#ifdef __cplusplus 183#ifdef __cplusplus
74extern "C" { 184extern "C" {
@@ -92,6 +202,16 @@ extern "C" {
92#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 202#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5
93#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA 203#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA
94 204
205/* VRS Additional Kerberos5 entries
206 */
207#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA
208#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5
209#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA
210#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5
211#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
212#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
213#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256
214
95#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 215#define SSL_MAX_SSL_SESSION_ID_LENGTH 32
96#define SSL_MAX_SID_CTX_LENGTH 32 216#define SSL_MAX_SID_CTX_LENGTH 32
97 217
@@ -112,6 +232,10 @@ extern "C" {
112#define SSL_TXT_eNULL "eNULL" 232#define SSL_TXT_eNULL "eNULL"
113#define SSL_TXT_NULL "NULL" 233#define SSL_TXT_NULL "NULL"
114 234
235#define SSL_TXT_kKRB5 "kKRB5"
236#define SSL_TXT_aKRB5 "aKRB5"
237#define SSL_TXT_KRB5 "KRB5"
238
115#define SSL_TXT_kRSA "kRSA" 239#define SSL_TXT_kRSA "kRSA"
116#define SSL_TXT_kDHr "kDHr" 240#define SSL_TXT_kDHr "kDHr"
117#define SSL_TXT_kDHd "kDHd" 241#define SSL_TXT_kDHd "kDHd"
@@ -129,6 +253,7 @@ extern "C" {
129#define SSL_TXT_RC4 "RC4" 253#define SSL_TXT_RC4 "RC4"
130#define SSL_TXT_RC2 "RC2" 254#define SSL_TXT_RC2 "RC2"
131#define SSL_TXT_IDEA "IDEA" 255#define SSL_TXT_IDEA "IDEA"
256#define SSL_TXT_AES "AESdraft" /* AES ciphersuites are not yet official (thus excluded from 'ALL') */
132#define SSL_TXT_MD5 "MD5" 257#define SSL_TXT_MD5 "MD5"
133#define SSL_TXT_SHA1 "SHA1" 258#define SSL_TXT_SHA1 "SHA1"
134#define SSL_TXT_SHA "SHA" 259#define SSL_TXT_SHA "SHA"
@@ -141,9 +266,10 @@ extern "C" {
141#define SSL_TXT_TLSV1 "TLSv1" 266#define SSL_TXT_TLSV1 "TLSv1"
142#define SSL_TXT_ALL "ALL" 267#define SSL_TXT_ALL "ALL"
143 268
144/* 'DEFAULT' at the start of the cipher list insert the following string 269/* The following cipher list is used by default.
145 * in addition to this being the default cipher string */ 270 * It also is substituted when an application-defined cipher list string
146#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+SSLv2:@STRENGTH" 271 * starts with 'DEFAULT'. */
272#define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */
147 273
148/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ 274/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
149#define SSL_SENT_SHUTDOWN 1 275#define SSL_SENT_SHUTDOWN 1
@@ -164,8 +290,8 @@ extern "C" {
164extern "C" { 290extern "C" {
165#endif 291#endif
166 292
167#if (defined(NO_RSA) || defined(NO_MD5)) && !defined(NO_SSL2) 293#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)
168#define NO_SSL2 294#define OPENSSL_NO_SSL2
169#endif 295#endif
170 296
171#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 297#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
@@ -211,8 +337,8 @@ typedef struct ssl_method_st
211 int (*ssl_shutdown)(SSL *s); 337 int (*ssl_shutdown)(SSL *s);
212 int (*ssl_renegotiate)(SSL *s); 338 int (*ssl_renegotiate)(SSL *s);
213 int (*ssl_renegotiate_check)(SSL *s); 339 int (*ssl_renegotiate_check)(SSL *s);
214 long (*ssl_ctrl)(SSL *s,int cmd,long larg,char *parg); 340 long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg);
215 long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,char *parg); 341 long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg);
216 SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); 342 SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
217 int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); 343 int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr);
218 int (*ssl_pending)(SSL *s); 344 int (*ssl_pending)(SSL *s);
@@ -233,6 +359,7 @@ typedef struct ssl_method_st
233 * Cipher OCTET_STRING, -- the 3 byte cipher ID 359 * Cipher OCTET_STRING, -- the 3 byte cipher ID
234 * Session_ID OCTET_STRING, -- the Session ID 360 * Session_ID OCTET_STRING, -- the Session ID
235 * Master_key OCTET_STRING, -- the master key 361 * Master_key OCTET_STRING, -- the master key
362 * KRB5_principal OCTET_STRING -- optional Kerberos principal
236 * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument 363 * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument
237 * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time 364 * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time
238 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds 365 * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds
@@ -263,6 +390,11 @@ typedef struct ssl_session_st
263 unsigned int sid_ctx_length; 390 unsigned int sid_ctx_length;
264 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; 391 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
265 392
393#ifndef OPENSSL_NO_KRB5
394 unsigned int krb5_client_princ_len;
395 unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];
396#endif /* OPENSSL_NO_KRB5 */
397
266 int not_resumable; 398 int not_resumable;
267 399
268 /* The cert is the certificate used to establish this connection */ 400 /* The cert is the certificate used to establish this connection */
@@ -306,21 +438,29 @@ typedef struct ssl_session_st
306#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L 438#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L
307#define SSL_OP_TLS_D5_BUG 0x00000100L 439#define SSL_OP_TLS_D5_BUG 0x00000100L
308#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L 440#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L
309#define SSL_OP_TLS_ROLLBACK_BUG 0x00000400L
310 441
311/* If set, always create a new key when using tmp_dh parameters */ 442/* If set, always create a new key when using tmp_dh parameters */
312#define SSL_OP_SINGLE_DH_USE 0x00100000L 443#define SSL_OP_SINGLE_DH_USE 0x00100000L
313/* Set to also use the tmp_rsa key when doing RSA operations. */ 444/* Set to always use the tmp_rsa key when doing RSA operations,
445 * even when this violates protocol specs */
314#define SSL_OP_EPHEMERAL_RSA 0x00200000L 446#define SSL_OP_EPHEMERAL_RSA 0x00200000L
447/* Set on servers to choose the cipher according to the server's
448 * preferences */
449#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L
450/* If set, a server will allow a client to issue a SSLv3.0 version number
451 * as latest version supported in the premaster secret, even when TLSv1.0
452 * (version 3.1) was announced in the client hello. Normally this is
453 * forbidden to prevent version rollback attacks. */
454#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L
455/* As server, disallow session resumption on renegotiation */
456#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x01000000L
315 457
316/* The next flag deliberately changes the ciphertest, this is a check 458/* The next flag deliberately changes the ciphertest, this is a check
317 * for the PKCS#1 attack */ 459 * for the PKCS#1 attack */
318#define SSL_OP_PKCS1_CHECK_1 0x08000000L 460#define SSL_OP_PKCS1_CHECK_1 0x08000000L
319#define SSL_OP_PKCS1_CHECK_2 0x10000000L 461#define SSL_OP_PKCS1_CHECK_2 0x10000000L
320#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L 462#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L
321/* SSL_OP_NON_EXPORT_FIRST looks utterly broken .. */ 463#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L
322#define SSL_OP_NON_EXPORT_FIRST 0x40000000L
323#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L
324#define SSL_OP_ALL 0x000FFFFFL 464#define SSL_OP_ALL 0x000FFFFFL
325 465
326#define SSL_OP_NO_SSLv2 0x01000000L 466#define SSL_OP_NO_SSLv2 0x01000000L
@@ -343,30 +483,60 @@ typedef struct ssl_session_st
343 * they cannot be used to clear bits. */ 483 * they cannot be used to clear bits. */
344 484
345#define SSL_CTX_set_options(ctx,op) \ 485#define SSL_CTX_set_options(ctx,op) \
346 SSL_CTX_ctrl(ctx,SSL_CTRL_OPTIONS,op,NULL) 486 SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
347#define SSL_CTX_get_options(ctx) \ 487#define SSL_CTX_get_options(ctx) \
348 SSL_CTX_ctrl(ctx,SSL_CTRL_OPTIONS,0,NULL) 488 SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)
349#define SSL_set_options(ssl,op) \ 489#define SSL_set_options(ssl,op) \
350 SSL_ctrl(ssl,SSL_CTRL_OPTIONS,op,NULL) 490 SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)
351#define SSL_get_options(ssl) \ 491#define SSL_get_options(ssl) \
352 SSL_ctrl(ssl,SSL_CTRL_OPTIONS,0,NULL) 492 SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)
353 493
354#define SSL_CTX_set_mode(ctx,op) \ 494#define SSL_CTX_set_mode(ctx,op) \
355 SSL_CTX_ctrl(ctx,SSL_CTRL_MODE,op,NULL) 495 SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
356#define SSL_CTX_get_mode(ctx) \ 496#define SSL_CTX_get_mode(ctx) \
357 SSL_CTX_ctrl(ctx,SSL_CTRL_MODE,0,NULL) 497 SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
358#define SSL_set_mode(ssl,op) \ 498#define SSL_set_mode(ssl,op) \
359 SSL_ctrl(ssl,SSL_CTRL_MODE,op,NULL) 499 SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
360#define SSL_get_mode(ssl) \ 500#define SSL_get_mode(ssl) \
361 SSL_ctrl(ssl,SSL_CTRL_MODE,0,NULL) 501 SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
502
503
504void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
505void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
506#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
507#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
508
509
510
511#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)
512#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */
513#else
514#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */
515#endif
362 516
363#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) 517#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)
364 518
519/* This callback type is used inside SSL_CTX, SSL, and in the functions that set
520 * them. It is used to override the generation of SSL/TLS session IDs in a
521 * server. Return value should be zero on an error, non-zero to proceed. Also,
522 * callbacks should themselves check if the id they generate is unique otherwise
523 * the SSL handshake will fail with an error - callbacks can do this using the
524 * 'ssl' value they're passed by;
525 * SSL_has_matching_session_id(ssl, id, *id_len)
526 * The length value passed in is set at the maximum size the session ID can be.
527 * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback
528 * can alter this length to be less if desired, but under SSLv2 session IDs are
529 * supposed to be fixed at 16 bytes so the id will be padded after the callback
530 * returns in this case. It is also an error for the callback to set the size to
531 * zero. */
532typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
533 unsigned int *id_len);
534
365typedef struct ssl_comp_st 535typedef struct ssl_comp_st
366 { 536 {
367 int id; 537 int id;
368 char *name; 538 char *name;
369#ifndef NO_COMP 539#ifndef OPENSSL_NO_COMP
370 COMP_METHOD *method; 540 COMP_METHOD *method;
371#else 541#else
372 char *method; 542 char *method;
@@ -378,8 +548,6 @@ DECLARE_STACK_OF(SSL_COMP)
378struct ssl_ctx_st 548struct ssl_ctx_st
379 { 549 {
380 SSL_METHOD *method; 550 SSL_METHOD *method;
381 unsigned long options;
382 unsigned long mode;
383 551
384 STACK_OF(SSL_CIPHER) *cipher_list; 552 STACK_OF(SSL_CIPHER) *cipher_list;
385 /* same as above but sorted for lookup */ 553 /* same as above but sorted for lookup */
@@ -417,6 +585,7 @@ struct ssl_ctx_st
417 void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); 585 void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess);
418 SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, 586 SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
419 unsigned char *data,int len,int *copy); 587 unsigned char *data,int len,int *copy);
588
420 struct 589 struct
421 { 590 {
422 int sess_connect; /* SSL new conn - started */ 591 int sess_connect; /* SSL new conn - started */
@@ -439,37 +608,20 @@ struct ssl_ctx_st
439 608
440 int references; 609 int references;
441 610
442/**/ void (*info_callback)();
443
444 /* if defined, these override the X509_verify_cert() calls */ 611 /* if defined, these override the X509_verify_cert() calls */
445/**/ int (*app_verify_callback)(); 612 int (*app_verify_callback)(X509_STORE_CTX *, void *);
446/**/ char *app_verify_arg; /* never used; should be void * */ 613 void *app_verify_arg;
447 614 /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored
448 /* default values to use in SSL structures */ 615 * ('app_verify_callback' was called with just one argument) */
449/**/ struct cert_st /* CERT */ *cert;
450/**/ int read_ahead;
451/**/ int verify_mode;
452/**/ int verify_depth;
453/**/ unsigned int sid_ctx_length;
454/**/ unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
455/**/ int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx);
456
457 int purpose; /* Purpose setting */
458 int trust; /* Trust setting */
459 616
460 /* Default password callback. */ 617 /* Default password callback. */
461/**/ pem_password_cb *default_passwd_callback; 618 pem_password_cb *default_passwd_callback;
462 619
463 /* Default password callback user data. */ 620 /* Default password callback user data. */
464/**/ void *default_passwd_callback_userdata; 621 void *default_passwd_callback_userdata;
465 622
466 /* get client cert callback */ 623 /* get client cert callback */
467/**/ int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */); 624 int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
468
469 /* what we put in client cert requests */
470 STACK_OF(X509_NAME) *client_CA;
471
472/**/ int quiet_shutdown;
473 625
474 CRYPTO_EX_DATA ex_data; 626 CRYPTO_EX_DATA ex_data;
475 627
@@ -478,7 +630,43 @@ struct ssl_ctx_st
478 const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ 630 const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */
479 631
480 STACK_OF(X509) *extra_certs; 632 STACK_OF(X509) *extra_certs;
481 STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ 633 STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */
634
635
636 /* Default values used when no per-SSL value is defined follow */
637
638 void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */
639
640 /* what we put in client cert requests */
641 STACK_OF(X509_NAME) *client_CA;
642
643
644 /* Default values to use in SSL structures follow (these are copied by SSL_new) */
645
646 unsigned long options;
647 unsigned long mode;
648 long max_cert_list;
649
650 struct cert_st /* CERT */ *cert;
651 int read_ahead;
652
653 /* callback that allows applications to peek at protocol messages */
654 void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
655 void *msg_callback_arg;
656
657 int verify_mode;
658 int verify_depth;
659 unsigned int sid_ctx_length;
660 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
661 int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */
662
663 /* Default generate session ID callback. */
664 GEN_SESSION_CB generate_session_id;
665
666 int purpose; /* Purpose setting */
667 int trust; /* Trust setting */
668
669 int quiet_shutdown;
482 }; 670 };
483 671
484#define SSL_SESS_CACHE_OFF 0x0000 672#define SSL_SESS_CACHE_OFF 0x0000
@@ -553,7 +741,7 @@ struct ssl_st
553 * same. This is so data can be read and written to different 741 * same. This is so data can be read and written to different
554 * handlers */ 742 * handlers */
555 743
556#ifndef NO_BIO 744#ifndef OPENSSL_NO_BIO
557 BIO *rbio; /* used by SSL_read */ 745 BIO *rbio; /* used by SSL_read */
558 BIO *wbio; /* used by SSL_write */ 746 BIO *wbio; /* used by SSL_write */
559 BIO *bbio; /* used during session-id reuse to concatenate 747 BIO *bbio; /* used during session-id reuse to concatenate
@@ -583,7 +771,12 @@ struct ssl_st
583 771
584 int server; /* are we the server side? - mostly used by SSL_clear*/ 772 int server; /* are we the server side? - mostly used by SSL_clear*/
585 773
586 int new_session;/* 1 if we are to use a new session */ 774 int new_session;/* 1 if we are to use a new session.
775 * 2 if we are a server and are inside a handshake
776 * (i.e. not just sending a HelloRequest)
777 * NB: For servers, the 'new' session may actually be a previously
778 * cached session or even the previous session unless
779 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
587 int quiet_shutdown;/* don't send shutdown packets */ 780 int quiet_shutdown;/* don't send shutdown packets */
588 int shutdown; /* we have shut things down, 0x01 sent, 0x02 781 int shutdown; /* we have shut things down, 0x01 sent, 0x02
589 * for received */ 782 * for received */
@@ -591,6 +784,7 @@ struct ssl_st
591 int rstate; /* where we are when reading */ 784 int rstate; /* where we are when reading */
592 785
593 BUF_MEM *init_buf; /* buffer used during init */ 786 BUF_MEM *init_buf; /* buffer used during init */
787 void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */
594 int init_num; /* amount read/written */ 788 int init_num; /* amount read/written */
595 int init_off; /* amount read/written */ 789 int init_off; /* amount read/written */
596 790
@@ -603,6 +797,11 @@ struct ssl_st
603 797
604 int read_ahead; /* Read as many input bytes as possible 798 int read_ahead; /* Read as many input bytes as possible
605 * (for non-blocking reads) */ 799 * (for non-blocking reads) */
800
801 /* callback that allows applications to peek at protocol messages */
802 void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
803 void *msg_callback_arg;
804
606 int hit; /* reusing a previous session */ 805 int hit; /* reusing a previous session */
607 806
608 int purpose; /* Purpose setting */ 807 int purpose; /* Purpose setting */
@@ -617,7 +816,7 @@ struct ssl_st
617 816
618 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ 817 EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */
619 const EVP_MD *read_hash; /* used for mac generation */ 818 const EVP_MD *read_hash; /* used for mac generation */
620#ifndef NO_COMP 819#ifndef OPENSSL_NO_COMP
621 COMP_CTX *expand; /* uncompress */ 820 COMP_CTX *expand; /* uncompress */
622#else 821#else
623 char *expand; 822 char *expand;
@@ -625,7 +824,7 @@ struct ssl_st
625 824
626 EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ 825 EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
627 const EVP_MD *write_hash; /* used for mac generation */ 826 const EVP_MD *write_hash; /* used for mac generation */
628#ifndef NO_COMP 827#ifndef OPENSSL_NO_COMP
629 COMP_CTX *compress; /* compression */ 828 COMP_CTX *compress; /* compression */
630#else 829#else
631 char *compress; 830 char *compress;
@@ -645,16 +844,24 @@ struct ssl_st
645 /* This can also be in the session once a session is established */ 844 /* This can also be in the session once a session is established */
646 SSL_SESSION *session; 845 SSL_SESSION *session;
647 846
847 /* Default generate session ID callback. */
848 GEN_SESSION_CB generate_session_id;
849
648 /* Used in SSL2 and SSL3 */ 850 /* Used in SSL2 and SSL3 */
649 int verify_mode; /* 0 don't care about verify failure. 851 int verify_mode; /* 0 don't care about verify failure.
650 * 1 fail if verify fails */ 852 * 1 fail if verify fails */
651 int verify_depth; 853 int verify_depth;
652 int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ 854 int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */
653 void (*info_callback)(); /* optional informational callback */ 855
856 void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */
654 857
655 int error; /* error bytes to be written */ 858 int error; /* error bytes to be written */
656 int error_code; /* actual code */ 859 int error_code; /* actual code */
657 860
861#ifndef OPENSSL_NO_KRB5
862 KSSL_CTX *kssl_ctx; /* Kerberos 5 context */
863#endif /* OPENSSL_NO_KRB5 */
864
658 SSL_CTX *ctx; 865 SSL_CTX *ctx;
659 /* set this flag to 1 and a sleep(1) is put into all SSL_read() 866 /* set this flag to 1 and a sleep(1) is put into all SSL_read()
660 * and SSL_write() calls, good for nbio debuging :-) */ 867 * and SSL_write() calls, good for nbio debuging :-) */
@@ -670,6 +877,7 @@ struct ssl_st
670 int references; 877 int references;
671 unsigned long options; /* protocol behaviour */ 878 unsigned long options; /* protocol behaviour */
672 unsigned long mode; /* API behaviour */ 879 unsigned long mode; /* API behaviour */
880 long max_cert_list;
673 int first_packet; 881 int first_packet;
674 int client_version; /* what was passed, used for 882 int client_version; /* what was passed, used for
675 * SSLv3/TLS rollback check */ 883 * SSLv3/TLS rollback check */
@@ -831,13 +1039,14 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
831#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ 1039#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */
832#define SSL_ERROR_ZERO_RETURN 6 1040#define SSL_ERROR_ZERO_RETURN 6
833#define SSL_ERROR_WANT_CONNECT 7 1041#define SSL_ERROR_WANT_CONNECT 7
1042#define SSL_ERROR_WANT_ACCEPT 8
834 1043
835#define SSL_CTRL_NEED_TMP_RSA 1 1044#define SSL_CTRL_NEED_TMP_RSA 1
836#define SSL_CTRL_SET_TMP_RSA 2 1045#define SSL_CTRL_SET_TMP_RSA 2
837#define SSL_CTRL_SET_TMP_DH 3 1046#define SSL_CTRL_SET_TMP_DH 3
838#define SSL_CTRL_SET_TMP_RSA_CB 4 1047#define SSL_CTRL_SET_TMP_RSA_CB 4
839#define SSL_CTRL_SET_TMP_DH_CB 5 1048#define SSL_CTRL_SET_TMP_DH_CB 5
840/* Add these ones */ 1049
841#define SSL_CTRL_GET_SESSION_REUSED 6 1050#define SSL_CTRL_GET_SESSION_REUSED 6
842#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7 1051#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7
843#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8 1052#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8
@@ -846,6 +1055,9 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
846#define SSL_CTRL_GET_FLAGS 11 1055#define SSL_CTRL_GET_FLAGS 11
847#define SSL_CTRL_EXTRA_CHAIN_CERT 12 1056#define SSL_CTRL_EXTRA_CHAIN_CERT 12
848 1057
1058#define SSL_CTRL_SET_MSG_CALLBACK 13
1059#define SSL_CTRL_SET_MSG_CALLBACK_ARG 14
1060
849/* Stats */ 1061/* Stats */
850#define SSL_CTRL_SESS_NUMBER 20 1062#define SSL_CTRL_SESS_NUMBER 20
851#define SSL_CTRL_SESS_CONNECT 21 1063#define SSL_CTRL_SESS_CONNECT 21
@@ -860,7 +1072,7 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
860#define SSL_CTRL_SESS_TIMEOUTS 30 1072#define SSL_CTRL_SESS_TIMEOUTS 30
861#define SSL_CTRL_SESS_CACHE_FULL 31 1073#define SSL_CTRL_SESS_CACHE_FULL 31
862#define SSL_CTRL_OPTIONS 32 1074#define SSL_CTRL_OPTIONS 32
863#define SSL_CTRL_MODE 33 1075#define SSL_CTRL_MODE 33
864 1076
865#define SSL_CTRL_GET_READ_AHEAD 40 1077#define SSL_CTRL_GET_READ_AHEAD 40
866#define SSL_CTRL_SET_READ_AHEAD 41 1078#define SSL_CTRL_SET_READ_AHEAD 41
@@ -869,6 +1081,9 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
869#define SSL_CTRL_SET_SESS_CACHE_MODE 44 1081#define SSL_CTRL_SET_SESS_CACHE_MODE 44
870#define SSL_CTRL_GET_SESS_CACHE_MODE 45 1082#define SSL_CTRL_GET_SESS_CACHE_MODE 45
871 1083
1084#define SSL_CTRL_GET_MAX_CERT_LIST 50
1085#define SSL_CTRL_SET_MAX_CERT_LIST 51
1086
872#define SSL_session_reused(ssl) \ 1087#define SSL_session_reused(ssl) \
873 SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) 1088 SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)
874#define SSL_num_renegotiations(ssl) \ 1089#define SSL_num_renegotiations(ssl) \
@@ -895,23 +1110,7 @@ size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count);
895#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ 1110#define SSL_CTX_add_extra_chain_cert(ctx,x509) \
896 SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) 1111 SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
897 1112
898/* VMS uses only 31 characters for symbols. */ 1113#ifndef OPENSSL_NO_BIO
899#ifdef VMS
900#undef SSL_CTX_set_cert_verify_callback
901#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
902#undef SSL_CTX_use_certificate_chain_file
903#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
904#undef SSL_CTX_set_default_verify_paths
905#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
906#undef SSL_get_ex_data_X509_STORE_CTX_idx
907#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_data_X509_STOR_CTX_i
908#undef SSL_add_file_cert_subjects_to_stack
909#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_sub_to_stack
910#undef SSL_add_dir_cert_subjects_to_stack
911#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_sub_to_stack
912#endif
913
914#ifndef NO_BIO
915BIO_METHOD *BIO_f_ssl(void); 1114BIO_METHOD *BIO_f_ssl(void);
916BIO *BIO_new_ssl(SSL_CTX *ctx,int client); 1115BIO *BIO_new_ssl(SSL_CTX *ctx,int client);
917BIO *BIO_new_ssl_connect(SSL_CTX *ctx); 1116BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
@@ -939,16 +1138,18 @@ char * SSL_CIPHER_get_version(SSL_CIPHER *c);
939const char * SSL_CIPHER_get_name(SSL_CIPHER *c); 1138const char * SSL_CIPHER_get_name(SSL_CIPHER *c);
940 1139
941int SSL_get_fd(SSL *s); 1140int SSL_get_fd(SSL *s);
1141int SSL_get_rfd(SSL *s);
1142int SSL_get_wfd(SSL *s);
942const char * SSL_get_cipher_list(SSL *s,int n); 1143const char * SSL_get_cipher_list(SSL *s,int n);
943char * SSL_get_shared_ciphers(SSL *s, char *buf, int len); 1144char * SSL_get_shared_ciphers(SSL *s, char *buf, int len);
944int SSL_get_read_ahead(SSL * s); 1145int SSL_get_read_ahead(SSL * s);
945int SSL_pending(SSL *s); 1146int SSL_pending(SSL *s);
946#ifndef NO_SOCK 1147#ifndef OPENSSL_NO_SOCK
947int SSL_set_fd(SSL *s, int fd); 1148int SSL_set_fd(SSL *s, int fd);
948int SSL_set_rfd(SSL *s, int fd); 1149int SSL_set_rfd(SSL *s, int fd);
949int SSL_set_wfd(SSL *s, int fd); 1150int SSL_set_wfd(SSL *s, int fd);
950#endif 1151#endif
951#ifndef NO_BIO 1152#ifndef OPENSSL_NO_BIO
952void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); 1153void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);
953BIO * SSL_get_rbio(SSL *s); 1154BIO * SSL_get_rbio(SSL *s);
954BIO * SSL_get_wbio(SSL *s); 1155BIO * SSL_get_wbio(SSL *s);
@@ -961,7 +1162,7 @@ int (*SSL_get_verify_callback(SSL *s))(int,X509_STORE_CTX *);
961void SSL_set_verify(SSL *s, int mode, 1162void SSL_set_verify(SSL *s, int mode,
962 int (*callback)(int ok,X509_STORE_CTX *ctx)); 1163 int (*callback)(int ok,X509_STORE_CTX *ctx));
963void SSL_set_verify_depth(SSL *s, int depth); 1164void SSL_set_verify_depth(SSL *s, int depth);
964#ifndef NO_RSA 1165#ifndef OPENSSL_NO_RSA
965int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); 1166int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
966#endif 1167#endif
967int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); 1168int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
@@ -970,7 +1171,7 @@ int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len);
970int SSL_use_certificate(SSL *ssl, X509 *x); 1171int SSL_use_certificate(SSL *ssl, X509 *x);
971int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len); 1172int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len);
972 1173
973#ifndef NO_STDIO 1174#ifndef OPENSSL_NO_STDIO
974int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); 1175int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
975int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); 1176int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
976int SSL_use_certificate_file(SSL *ssl, const char *file, int type); 1177int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
@@ -981,16 +1182,22 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM t
981STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); 1182STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
982int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1183int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
983 const char *file); 1184 const char *file);
1185#ifndef OPENSSL_SYS_WIN32
1186#ifndef OPENSSL_SYS_VMS
1187#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */
984int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, 1188int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
985 const char *dir); 1189 const char *dir);
986#endif 1190#endif
1191#endif
1192#endif
1193
1194#endif
987 1195
988void ERR_load_SSL_strings(void );
989void SSL_load_error_strings(void ); 1196void SSL_load_error_strings(void );
990char * SSL_state_string(SSL *s); 1197const char *SSL_state_string(const SSL *s);
991char * SSL_rstate_string(SSL *s); 1198const char *SSL_rstate_string(const SSL *s);
992char * SSL_state_string_long(SSL *s); 1199const char *SSL_state_string_long(const SSL *s);
993char * SSL_rstate_string_long(SSL *s); 1200const char *SSL_rstate_string_long(const SSL *s);
994long SSL_SESSION_get_time(SSL_SESSION *s); 1201long SSL_SESSION_get_time(SSL_SESSION *s);
995long SSL_SESSION_set_time(SSL_SESSION *s, long t); 1202long SSL_SESSION_set_time(SSL_SESSION *s, long t);
996long SSL_SESSION_get_timeout(SSL_SESSION *s); 1203long SSL_SESSION_get_timeout(SSL_SESSION *s);
@@ -1000,10 +1207,10 @@ void SSL_copy_session_id(SSL *to,SSL *from);
1000SSL_SESSION *SSL_SESSION_new(void); 1207SSL_SESSION *SSL_SESSION_new(void);
1001unsigned long SSL_SESSION_hash(SSL_SESSION *a); 1208unsigned long SSL_SESSION_hash(SSL_SESSION *a);
1002int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b); 1209int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b);
1003#ifndef NO_FP_API 1210#ifndef OPENSSL_NO_FP_API
1004int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses); 1211int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses);
1005#endif 1212#endif
1006#ifndef NO_BIO 1213#ifndef OPENSSL_NO_BIO
1007int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses); 1214int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses);
1008#endif 1215#endif
1009void SSL_SESSION_free(SSL_SESSION *ses); 1216void SSL_SESSION_free(SSL_SESSION *ses);
@@ -1011,6 +1218,10 @@ int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp);
1011int SSL_set_session(SSL *to, SSL_SESSION *session); 1218int SSL_set_session(SSL *to, SSL_SESSION *session);
1012int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); 1219int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);
1013int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); 1220int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c);
1221int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);
1222int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);
1223int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
1224 unsigned int id_len);
1014SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length); 1225SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length);
1015 1226
1016#ifdef HEADER_X509_H 1227#ifdef HEADER_X509_H
@@ -1019,18 +1230,14 @@ X509 * SSL_get_peer_certificate(SSL *s);
1019 1230
1020STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s); 1231STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s);
1021 1232
1022#ifdef VMS
1023#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
1024#endif
1025
1026int SSL_CTX_get_verify_mode(SSL_CTX *ctx); 1233int SSL_CTX_get_verify_mode(SSL_CTX *ctx);
1027int SSL_CTX_get_verify_depth(SSL_CTX *ctx); 1234int SSL_CTX_get_verify_depth(SSL_CTX *ctx);
1028int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *); 1235int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *);
1029void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, 1236void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,
1030 int (*callback)(int, X509_STORE_CTX *)); 1237 int (*callback)(int, X509_STORE_CTX *));
1031void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); 1238void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth);
1032void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(),char *arg); 1239void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg);
1033#ifndef NO_RSA 1240#ifndef OPENSSL_NO_RSA
1034int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); 1241int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
1035#endif 1242#endif
1036int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); 1243int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len);
@@ -1064,9 +1271,9 @@ int SSL_connect(SSL *ssl);
1064int SSL_read(SSL *ssl,void *buf,int num); 1271int SSL_read(SSL *ssl,void *buf,int num);
1065int SSL_peek(SSL *ssl,void *buf,int num); 1272int SSL_peek(SSL *ssl,void *buf,int num);
1066int SSL_write(SSL *ssl,const void *buf,int num); 1273int SSL_write(SSL *ssl,const void *buf,int num);
1067long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); 1274long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
1068long SSL_callback_ctrl(SSL *, int, void (*)()); 1275long SSL_callback_ctrl(SSL *, int, void (*)());
1069long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); 1276long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg);
1070long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)()); 1277long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)());
1071 1278
1072int SSL_get_error(SSL *s,int ret_code); 1279int SSL_get_error(SSL *s,int ret_code);
@@ -1095,14 +1302,15 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s);
1095 1302
1096int SSL_do_handshake(SSL *s); 1303int SSL_do_handshake(SSL *s);
1097int SSL_renegotiate(SSL *s); 1304int SSL_renegotiate(SSL *s);
1305int SSL_renegotiate_pending(SSL *s);
1098int SSL_shutdown(SSL *s); 1306int SSL_shutdown(SSL *s);
1099 1307
1100SSL_METHOD *SSL_get_ssl_method(SSL *s); 1308SSL_METHOD *SSL_get_ssl_method(SSL *s);
1101int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); 1309int SSL_set_ssl_method(SSL *s,SSL_METHOD *method);
1102char *SSL_alert_type_string_long(int value); 1310const char *SSL_alert_type_string_long(int value);
1103char *SSL_alert_type_string(int value); 1311const char *SSL_alert_type_string(int value);
1104char *SSL_alert_desc_string_long(int value); 1312const char *SSL_alert_desc_string_long(int value);
1105char *SSL_alert_desc_string(int value); 1313const char *SSL_alert_desc_string(int value);
1106 1314
1107void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list); 1315void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list);
1108void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list); 1316void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list);
@@ -1140,8 +1348,9 @@ int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1140SSL_SESSION *SSL_get_session(SSL *ssl); 1348SSL_SESSION *SSL_get_session(SSL *ssl);
1141SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ 1349SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
1142SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); 1350SSL_CTX *SSL_get_SSL_CTX(SSL *ssl);
1143void SSL_set_info_callback(SSL *ssl,void (*cb)()); 1351void SSL_set_info_callback(SSL *ssl,
1144void (*SSL_get_info_callback(SSL *ssl))(); 1352 void (*cb)(const SSL *ssl,int type,int val));
1353void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val);
1145int SSL_state(SSL *ssl); 1354int SSL_state(SSL *ssl);
1146 1355
1147void SSL_set_verify_result(SSL *ssl,long v); 1356void SSL_set_verify_result(SSL *ssl,long v);
@@ -1179,9 +1388,17 @@ int SSL_get_ex_data_X509_STORE_CTX_idx(void );
1179 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) 1388 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)
1180#define SSL_CTX_set_read_ahead(ctx,m) \ 1389#define SSL_CTX_set_read_ahead(ctx,m) \
1181 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) 1390 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)
1391#define SSL_CTX_get_max_cert_list(ctx) \
1392 SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
1393#define SSL_CTX_set_max_cert_list(ctx,m) \
1394 SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
1395#define SSL_get_max_cert_list(ssl) \
1396 SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
1397#define SSL_set_max_cert_list(ssl,m) \
1398 SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
1182 1399
1183 /* NB: the keylength is only applicable when is_export is true */ 1400 /* NB: the keylength is only applicable when is_export is true */
1184#ifndef NO_RSA 1401#ifndef OPENSSL_NO_RSA
1185void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, 1402void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
1186 RSA *(*cb)(SSL *ssl,int is_export, 1403 RSA *(*cb)(SSL *ssl,int is_export,
1187 int keylength)); 1404 int keylength));
@@ -1190,7 +1407,7 @@ void SSL_set_tmp_rsa_callback(SSL *ssl,
1190 RSA *(*cb)(SSL *ssl,int is_export, 1407 RSA *(*cb)(SSL *ssl,int is_export,
1191 int keylength)); 1408 int keylength));
1192#endif 1409#endif
1193#ifndef NO_DH 1410#ifndef OPENSSL_NO_DH
1194void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, 1411void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
1195 DH *(*dh)(SSL *ssl,int is_export, 1412 DH *(*dh)(SSL *ssl,int is_export,
1196 int keylength)); 1413 int keylength));
@@ -1199,7 +1416,7 @@ void SSL_set_tmp_dh_callback(SSL *ssl,
1199 int keylength)); 1416 int keylength));
1200#endif 1417#endif
1201 1418
1202#ifndef NO_COMP 1419#ifndef OPENSSL_NO_COMP
1203int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); 1420int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm);
1204#else 1421#else
1205int SSL_COMP_add_compression_method(int id,char *cm); 1422int SSL_COMP_add_compression_method(int id,char *cm);
@@ -1254,6 +1471,7 @@ void ERR_load_SSL_strings(void);
1254#define SSL_F_SSL3_CTRL 213 1471#define SSL_F_SSL3_CTRL 213
1255#define SSL_F_SSL3_CTX_CTRL 133 1472#define SSL_F_SSL3_CTX_CTRL 133
1256#define SSL_F_SSL3_ENC 134 1473#define SSL_F_SSL3_ENC 134
1474#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238
1257#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 1475#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135
1258#define SSL_F_SSL3_GET_CERT_VERIFY 136 1476#define SSL_F_SSL3_GET_CERT_VERIFY 136
1259#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 1477#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137
@@ -1403,6 +1621,7 @@ void ERR_load_SSL_strings(void);
1403#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 1621#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145
1404#define SSL_R_DATA_LENGTH_TOO_LONG 146 1622#define SSL_R_DATA_LENGTH_TOO_LONG 146
1405#define SSL_R_DECRYPTION_FAILED 147 1623#define SSL_R_DECRYPTION_FAILED 147
1624#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 1109
1406#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 1625#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148
1407#define SSL_R_DIGEST_CHECK_FAILED 149 1626#define SSL_R_DIGEST_CHECK_FAILED 149
1408#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 1627#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150
@@ -1413,15 +1632,27 @@ void ERR_load_SSL_strings(void);
1413#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 1632#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154
1414#define SSL_R_HTTPS_PROXY_REQUEST 155 1633#define SSL_R_HTTPS_PROXY_REQUEST 155
1415#define SSL_R_HTTP_REQUEST 156 1634#define SSL_R_HTTP_REQUEST 156
1416#define SSL_R_INTERNAL_ERROR 157 1635#define SSL_R_ILLEGAL_PADDING 1110
1417#define SSL_R_INVALID_CHALLENGE_LENGTH 158 1636#define SSL_R_INVALID_CHALLENGE_LENGTH 158
1418#define SSL_R_INVALID_COMMAND 280 1637#define SSL_R_INVALID_COMMAND 280
1419#define SSL_R_INVALID_PURPOSE 278 1638#define SSL_R_INVALID_PURPOSE 278
1420#define SSL_R_INVALID_TRUST 279 1639#define SSL_R_INVALID_TRUST 279
1640#define SSL_R_KRB5 1104
1641#define SSL_R_KRB5_C_CC_PRINC 1094
1642#define SSL_R_KRB5_C_GET_CRED 1095
1643#define SSL_R_KRB5_C_INIT 1096
1644#define SSL_R_KRB5_C_MK_REQ 1097
1645#define SSL_R_KRB5_S_BAD_TICKET 1098
1646#define SSL_R_KRB5_S_INIT 1099
1647#define SSL_R_KRB5_S_RD_REQ 1108
1648#define SSL_R_KRB5_S_TKT_EXPIRED 1105
1649#define SSL_R_KRB5_S_TKT_NYV 1106
1650#define SSL_R_KRB5_S_TKT_SKEW 1107
1421#define SSL_R_LENGTH_MISMATCH 159 1651#define SSL_R_LENGTH_MISMATCH 159
1422#define SSL_R_LENGTH_TOO_SHORT 160 1652#define SSL_R_LENGTH_TOO_SHORT 160
1423#define SSL_R_LIBRARY_BUG 274 1653#define SSL_R_LIBRARY_BUG 274
1424#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 1654#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161
1655#define SSL_R_MESSAGE_TOO_LONG 1111
1425#define SSL_R_MISSING_DH_DSA_CERT 162 1656#define SSL_R_MISSING_DH_DSA_CERT 162
1426#define SSL_R_MISSING_DH_KEY 163 1657#define SSL_R_MISSING_DH_KEY 163
1427#define SSL_R_MISSING_DH_RSA_CERT 164 1658#define SSL_R_MISSING_DH_RSA_CERT 164
@@ -1505,7 +1736,10 @@ void ERR_load_SSL_strings(void);
1505#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 1736#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228
1506#define SSL_R_SSL_HANDSHAKE_FAILURE 229 1737#define SSL_R_SSL_HANDSHAKE_FAILURE 229
1507#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 1738#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230
1739#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 1102
1740#define SSL_R_SSL_SESSION_ID_CONFLICT 1103
1508#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 1741#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273
1742#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 1101
1509#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 1743#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231
1510#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 1744#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
1511#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 1745#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050
diff --git a/src/lib/libssl/ssl/Makefile b/src/lib/libssl/ssl/Makefile
index 09b63a4e34..0fd5407dca 100644
--- a/src/lib/libssl/ssl/Makefile
+++ b/src/lib/libssl/ssl/Makefile
@@ -1,7 +1,7 @@
1 1
2LIB= ssl 2LIB= ssl
3 3
4SSLEAYDIST= openssl 4SSLEAYDIST= src
5 5
6LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl 6LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl
7LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto 7LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
diff --git a/src/lib/libssl/ssl2.h b/src/lib/libssl/ssl2.h
index f8b56afb6b..99a52ea0dd 100644
--- a/src/lib/libssl/ssl2.h
+++ b/src/lib/libssl/ssl2.h
@@ -133,7 +133,7 @@ extern "C" {
133 133
134/* Upper/Lower Bounds */ 134/* Upper/Lower Bounds */
135#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 135#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256
136#ifdef MPE 136#ifdef OPENSSL_SYS_MPE
137#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u 137#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u
138#else 138#else
139#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ 139#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */
@@ -189,7 +189,6 @@ typedef struct ssl2_state_st
189 unsigned char *ract_data; 189 unsigned char *ract_data;
190 unsigned char *wact_data; 190 unsigned char *wact_data;
191 unsigned char *mac_data; 191 unsigned char *mac_data;
192 unsigned char *pad_data;
193 192
194 unsigned char *read_key; 193 unsigned char *read_key;
195 unsigned char *write_key; 194 unsigned char *write_key;
@@ -209,11 +208,11 @@ typedef struct ssl2_state_st
209 unsigned int conn_id_length; 208 unsigned int conn_id_length;
210 unsigned int cert_type; 209 unsigned int cert_type;
211 unsigned int cert_length; 210 unsigned int cert_length;
212 int csl; 211 unsigned int csl;
213 int clear; 212 unsigned int clear;
214 unsigned int enc; 213 unsigned int enc;
215 unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; 214 unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
216 int cipher_spec_length; 215 unsigned int cipher_spec_length;
217 unsigned int session_id_length; 216 unsigned int session_id_length;
218 unsigned int clen; 217 unsigned int clen;
219 unsigned int rlen; 218 unsigned int rlen;
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h
index 7ee1feaa67..8fd6951d77 100644
--- a/src/lib/libssl/ssl3.h
+++ b/src/lib/libssl/ssl3.h
@@ -55,11 +55,64 @@
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#ifndef HEADER_SSL3_H 112#ifndef HEADER_SSL3_H
60#define HEADER_SSL3_H 113#define HEADER_SSL3_H
61 114
62#ifndef NO_COMP 115#ifndef OPENSSL_NO_COMP
63#include <openssl/comp.h> 116#include <openssl/comp.h>
64#endif 117#endif
65#include <openssl/buffer.h> 118#include <openssl/buffer.h>
@@ -105,6 +158,22 @@ extern "C" {
105#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D 158#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D
106#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E 159#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E
107 160
161/* VRS Additional Kerberos5 entries
162 */
163#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021
164#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022
165#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023
166#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024
167#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025
168#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026
169
170#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA"
171#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5"
172#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA"
173#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5"
174#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA"
175#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5"
176
108#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" 177#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
109#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" 178#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
110#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" 179#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5"
@@ -149,7 +218,8 @@ extern "C" {
149#define SSL3_RT_HEADER_LENGTH 5 218#define SSL3_RT_HEADER_LENGTH 5
150 219
151/* Due to MS stuffing up, this can change.... */ 220/* Due to MS stuffing up, this can change.... */
152#if defined(WIN16) || (defined(MSDOS) && !defined(WIN32)) 221#if defined(OPENSSL_SYS_WIN16) || \
222 (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32))
153#define SSL3_RT_MAX_EXTRA (14000) 223#define SSL3_RT_MAX_EXTRA (14000)
154#else 224#else
155#define SSL3_RT_MAX_EXTRA (16384) 225#define SSL3_RT_MAX_EXTRA (16384)
@@ -201,10 +271,11 @@ typedef struct ssl3_record_st
201 271
202typedef struct ssl3_buffer_st 272typedef struct ssl3_buffer_st
203 { 273 {
204 unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes (more if 274 unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes,
205 * SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER is set) */ 275 * see ssl3_setup_buffers() */
206 int offset; /* where to 'copy from' */ 276 size_t len; /* buffer size */
207 int left; /* how many bytes left */ 277 int offset; /* where to 'copy from' */
278 int left; /* how many bytes left */
208 } SSL3_BUFFER; 279 } SSL3_BUFFER;
209 280
210#define SSL3_CT_RSA_SIGN 1 281#define SSL3_CT_RSA_SIGN 1
@@ -234,6 +305,10 @@ typedef struct ssl3_state_st
234 unsigned char server_random[SSL3_RANDOM_SIZE]; 305 unsigned char server_random[SSL3_RANDOM_SIZE];
235 unsigned char client_random[SSL3_RANDOM_SIZE]; 306 unsigned char client_random[SSL3_RANDOM_SIZE];
236 307
308 /* flags for countermeasure against known-IV weakness */
309 int need_empty_fragments;
310 int empty_fragment_done;
311
237 SSL3_BUFFER rbuf; /* read IO goes into here */ 312 SSL3_BUFFER rbuf; /* read IO goes into here */
238 SSL3_BUFFER wbuf; /* write IO goes into here */ 313 SSL3_BUFFER wbuf; /* write IO goes into here */
239 314
@@ -292,7 +367,7 @@ typedef struct ssl3_state_st
292 367
293 /* used to hold the new cipher we are going to use */ 368 /* used to hold the new cipher we are going to use */
294 SSL_CIPHER *new_cipher; 369 SSL_CIPHER *new_cipher;
295#ifndef NO_DH 370#ifndef OPENSSL_NO_DH
296 DH *dh; 371 DH *dh;
297#endif 372#endif
298 /* used when SSL_ST_FLUSH_DATA is entered */ 373 /* used when SSL_ST_FLUSH_DATA is entered */
@@ -313,7 +388,7 @@ typedef struct ssl3_state_st
313 388
314 const EVP_CIPHER *new_sym_enc; 389 const EVP_CIPHER *new_sym_enc;
315 const EVP_MD *new_hash; 390 const EVP_MD *new_hash;
316#ifndef NO_COMP 391#ifndef OPENSSL_NO_COMP
317 const SSL_COMP *new_compression; 392 const SSL_COMP *new_compression;
318#else 393#else
319 char *new_compression; 394 char *new_compression;
diff --git a/src/lib/libssl/ssl_algs.c b/src/lib/libssl/ssl_algs.c
index dde8918fe0..3d1299ee7b 100644
--- a/src/lib/libssl/ssl_algs.c
+++ b/src/lib/libssl/ssl_algs.c
@@ -63,40 +63,44 @@
63 63
64int SSL_library_init(void) 64int SSL_library_init(void)
65 { 65 {
66#ifndef NO_DES 66
67#ifndef OPENSSL_NO_DES
67 EVP_add_cipher(EVP_des_cbc()); 68 EVP_add_cipher(EVP_des_cbc());
68 EVP_add_cipher(EVP_des_ede3_cbc()); 69 EVP_add_cipher(EVP_des_ede3_cbc());
69#endif 70#endif
70#ifndef NO_IDEA 71#ifndef OPENSSL_NO_IDEA
71 EVP_add_cipher(EVP_idea_cbc()); 72 EVP_add_cipher(EVP_idea_cbc());
72#endif 73#endif
73#ifndef NO_RC4 74#ifndef OPENSSL_NO_RC4
74 EVP_add_cipher(EVP_rc4()); 75 EVP_add_cipher(EVP_rc4());
75#endif 76#endif
76#ifndef NO_RC2 77#ifndef OPENSSL_NO_RC2
77 EVP_add_cipher(EVP_rc2_cbc()); 78 EVP_add_cipher(EVP_rc2_cbc());
78#endif 79#endif
79 80#ifndef OPENSSL_NO_AES
80#ifndef NO_MD2 81 EVP_add_cipher(EVP_aes_128_cbc());
82 EVP_add_cipher(EVP_aes_192_cbc());
83 EVP_add_cipher(EVP_aes_256_cbc());
84#endif
85#ifndef OPENSSL_NO_MD2
81 EVP_add_digest(EVP_md2()); 86 EVP_add_digest(EVP_md2());
82#endif 87#endif
83#ifndef NO_MD5 88#ifndef OPENSSL_NO_MD5
84 EVP_add_digest(EVP_md5()); 89 EVP_add_digest(EVP_md5());
85 EVP_add_digest_alias(SN_md5,"ssl2-md5"); 90 EVP_add_digest_alias(SN_md5,"ssl2-md5");
86 EVP_add_digest_alias(SN_md5,"ssl3-md5"); 91 EVP_add_digest_alias(SN_md5,"ssl3-md5");
87#endif 92#endif
88#ifndef NO_SHA 93#ifndef OPENSSL_NO_SHA
89 EVP_add_digest(EVP_sha1()); /* RSA with sha1 */ 94 EVP_add_digest(EVP_sha1()); /* RSA with sha1 */
90 EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); 95 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
91 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); 96 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
92#endif 97#endif
93#if !defined(NO_SHA) && !defined(NO_DSA) 98#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)
94 EVP_add_digest(EVP_dss1()); /* DSA with sha1 */ 99 EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
95 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); 100 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
96 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); 101 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
97 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); 102 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
98#endif 103#endif
99
100 /* If you want support for phased out ciphers, add the following */ 104 /* If you want support for phased out ciphers, add the following */
101#if 0 105#if 0
102 EVP_add_digest(EVP_sha()); 106 EVP_add_digest(EVP_sha());
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c
index fa6456e4f5..c5eeeb6bc5 100644
--- a/src/lib/libssl/ssl_asn1.c
+++ b/src/lib/libssl/ssl_asn1.c
@@ -72,6 +72,9 @@ typedef struct ssl_session_asn1_st
72 ASN1_OCTET_STRING session_id; 72 ASN1_OCTET_STRING session_id;
73 ASN1_OCTET_STRING session_id_context; 73 ASN1_OCTET_STRING session_id_context;
74 ASN1_OCTET_STRING key_arg; 74 ASN1_OCTET_STRING key_arg;
75#ifndef OPENSSL_NO_KRB5
76 ASN1_OCTET_STRING krb5_princ;
77#endif /* OPENSSL_NO_KRB5 */
75 ASN1_INTEGER time; 78 ASN1_INTEGER time;
76 ASN1_INTEGER timeout; 79 ASN1_INTEGER timeout;
77 ASN1_INTEGER verify_result; 80 ASN1_INTEGER verify_result;
@@ -142,6 +145,15 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
142 a.key_arg.type=V_ASN1_OCTET_STRING; 145 a.key_arg.type=V_ASN1_OCTET_STRING;
143 a.key_arg.data=in->key_arg; 146 a.key_arg.data=in->key_arg;
144 147
148#ifndef OPENSSL_NO_KRB5
149 if (in->krb5_client_princ_len)
150 {
151 a.krb5_princ.length=in->krb5_client_princ_len;
152 a.krb5_princ.type=V_ASN1_OCTET_STRING;
153 a.krb5_princ.data=in->krb5_client_princ;
154 }
155#endif /* OPENSSL_NO_KRB5 */
156
145 if (in->time != 0L) 157 if (in->time != 0L)
146 { 158 {
147 a.time.length=LSIZE2; 159 a.time.length=LSIZE2;
@@ -166,11 +178,16 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
166 ASN1_INTEGER_set(&a.verify_result,in->verify_result); 178 ASN1_INTEGER_set(&a.verify_result,in->verify_result);
167 } 179 }
168 180
181
169 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); 182 M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER);
170 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); 183 M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER);
171 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); 184 M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING);
172 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); 185 M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING);
173 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); 186 M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING);
187#ifndef OPENSSL_NO_KRB5
188 if (in->krb5_client_princ_len)
189 M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING);
190#endif /* OPENSSL_NO_KRB5 */
174 if (in->key_arg_length > 0) 191 if (in->key_arg_length > 0)
175 M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING); 192 M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING);
176 if (in->time != 0L) 193 if (in->time != 0L)
@@ -190,6 +207,10 @@ int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp)
190 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); 207 M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING);
191 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); 208 M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING);
192 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); 209 M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING);
210#ifndef OPENSSL_NO_KRB5
211 if (in->krb5_client_princ_len)
212 M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING);
213#endif /* OPENSSL_NO_KRB5 */
193 if (in->key_arg_length > 0) 214 if (in->key_arg_length > 0)
194 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); 215 M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0);
195 if (in->time != 0L) 216 if (in->time != 0L)
@@ -285,6 +306,25 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp,
285 memcpy(ret->master_key,os.data,ret->master_key_length); 306 memcpy(ret->master_key,os.data,ret->master_key_length);
286 307
287 os.length=0; 308 os.length=0;
309
310#ifndef OPENSSL_NO_KRB5
311 os.length=0;
312 M_ASN1_D2I_get_opt(osp,d2i_ASN1_OCTET_STRING,V_ASN1_OCTET_STRING);
313 if (os.data)
314 {
315 if (os.length > SSL_MAX_KRB5_PRINCIPAL_LENGTH)
316 ret->krb5_client_princ_len=0;
317 else
318 ret->krb5_client_princ_len=os.length;
319 memcpy(ret->krb5_client_princ,os.data,ret->krb5_client_princ_len);
320 OPENSSL_free(os.data);
321 os.data = NULL;
322 os.length = 0;
323 }
324 else
325 ret->krb5_client_princ_len=0;
326#endif /* OPENSSL_NO_KRB5 */
327
288 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); 328 M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING);
289 if (os.length > SSL_MAX_KEY_ARG_LENGTH) 329 if (os.length > SSL_MAX_KEY_ARG_LENGTH)
290 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; 330 ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH;
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c
index 27e7fcc60a..79e89fe14a 100644
--- a/src/lib/libssl/ssl_cert.c
+++ b/src/lib/libssl/ssl_cert.c
@@ -106,16 +106,19 @@
106 106
107#include <stdio.h> 107#include <stdio.h>
108 108
109#include "openssl/e_os.h" 109#include "e_os.h"
110
111#ifndef NO_SYS_TYPES_H 110#ifndef NO_SYS_TYPES_H
112# include <sys/types.h> 111# include <sys/types.h>
113#endif 112#endif
114 113
115#if !defined(WIN32) && !defined(VSM) && !defined(NeXT) && !defined(MAC_OS_pre_X) 114#if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(NeXT) && !defined(MAC_OS_pre_X)
116#include <dirent.h> 115#include <dirent.h>
117#endif 116#endif
118 117
118#if defined(WIN32)
119#include <windows.h>
120#endif
121
119#ifdef NeXT 122#ifdef NeXT
120#include <sys/dir.h> 123#include <sys/dir.h>
121#define dirent direct 124#define dirent direct
@@ -129,14 +132,23 @@
129 132
130int SSL_get_ex_data_X509_STORE_CTX_idx(void) 133int SSL_get_ex_data_X509_STORE_CTX_idx(void)
131 { 134 {
132 static int ssl_x509_store_ctx_idx= -1; 135 static volatile int ssl_x509_store_ctx_idx= -1;
133 136
134 if (ssl_x509_store_ctx_idx < 0) 137 if (ssl_x509_store_ctx_idx < 0)
135 { 138 {
136 ssl_x509_store_ctx_idx=X509_STORE_CTX_get_ex_new_index( 139 /* any write lock will do; usually this branch
137 0,"SSL for verify callback",NULL,NULL,NULL); 140 * will only be taken once anyway */
141 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
142
143 if (ssl_x509_store_ctx_idx < 0)
144 {
145 ssl_x509_store_ctx_idx=X509_STORE_CTX_get_ex_new_index(
146 0,"SSL for verify callback",NULL,NULL,NULL);
147 }
148
149 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
138 } 150 }
139 return(ssl_x509_store_ctx_idx); 151 return ssl_x509_store_ctx_idx;
140 } 152 }
141 153
142CERT *ssl_cert_new(void) 154CERT *ssl_cert_new(void)
@@ -179,16 +191,16 @@ CERT *ssl_cert_dup(CERT *cert)
179 ret->mask = cert->mask; 191 ret->mask = cert->mask;
180 ret->export_mask = cert->export_mask; 192 ret->export_mask = cert->export_mask;
181 193
182#ifndef NO_RSA 194#ifndef OPENSSL_NO_RSA
183 if (cert->rsa_tmp != NULL) 195 if (cert->rsa_tmp != NULL)
184 { 196 {
197 RSA_up_ref(cert->rsa_tmp);
185 ret->rsa_tmp = cert->rsa_tmp; 198 ret->rsa_tmp = cert->rsa_tmp;
186 CRYPTO_add(&ret->rsa_tmp->references, 1, CRYPTO_LOCK_RSA);
187 } 199 }
188 ret->rsa_tmp_cb = cert->rsa_tmp_cb; 200 ret->rsa_tmp_cb = cert->rsa_tmp_cb;
189#endif 201#endif
190 202
191#ifndef NO_DH 203#ifndef OPENSSL_NO_DH
192 if (cert->dh_tmp != NULL) 204 if (cert->dh_tmp != NULL)
193 { 205 {
194 /* DH parameters don't have a reference count */ 206 /* DH parameters don't have a reference count */
@@ -271,14 +283,14 @@ CERT *ssl_cert_dup(CERT *cert)
271 283
272 return(ret); 284 return(ret);
273 285
274#ifndef NO_DH /* avoid 'unreferenced label' warning if NO_DH is defined */ 286#ifndef OPENSSL_NO_DH /* avoid 'unreferenced label' warning if OPENSSL_NO_DH is defined */
275err: 287err:
276#endif 288#endif
277#ifndef NO_RSA 289#ifndef OPENSSL_NO_RSA
278 if (ret->rsa_tmp != NULL) 290 if (ret->rsa_tmp != NULL)
279 RSA_free(ret->rsa_tmp); 291 RSA_free(ret->rsa_tmp);
280#endif 292#endif
281#ifndef NO_DH 293#ifndef OPENSSL_NO_DH
282 if (ret->dh_tmp != NULL) 294 if (ret->dh_tmp != NULL)
283 DH_free(ret->dh_tmp); 295 DH_free(ret->dh_tmp);
284#endif 296#endif
@@ -315,10 +327,10 @@ void ssl_cert_free(CERT *c)
315 } 327 }
316#endif 328#endif
317 329
318#ifndef NO_RSA 330#ifndef OPENSSL_NO_RSA
319 if (c->rsa_tmp) RSA_free(c->rsa_tmp); 331 if (c->rsa_tmp) RSA_free(c->rsa_tmp);
320#endif 332#endif
321#ifndef NO_DH 333#ifndef OPENSSL_NO_DH
322 if (c->dh_tmp) DH_free(c->dh_tmp); 334 if (c->dh_tmp) DH_free(c->dh_tmp);
323#endif 335#endif
324 336
@@ -419,11 +431,11 @@ void ssl_sess_cert_free(SESS_CERT *sc)
419#endif 431#endif
420 } 432 }
421 433
422#ifndef NO_RSA 434#ifndef OPENSSL_NO_RSA
423 if (sc->peer_rsa_tmp != NULL) 435 if (sc->peer_rsa_tmp != NULL)
424 RSA_free(sc->peer_rsa_tmp); 436 RSA_free(sc->peer_rsa_tmp);
425#endif 437#endif
426#ifndef NO_DH 438#ifndef OPENSSL_NO_DH
427 if (sc->peer_dh_tmp != NULL) 439 if (sc->peer_dh_tmp != NULL)
428 DH_free(sc->peer_dh_tmp); 440 DH_free(sc->peer_dh_tmp);
429#endif 441#endif
@@ -447,25 +459,38 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk)
447 return(0); 459 return(0);
448 460
449 x=sk_X509_value(sk,0); 461 x=sk_X509_value(sk,0);
450 X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk); 462 if(!X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk))
463 {
464 SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,ERR_R_X509_LIB);
465 return(0);
466 }
451 if (SSL_get_verify_depth(s) >= 0) 467 if (SSL_get_verify_depth(s) >= 0)
452 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s)); 468 X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s));
453 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s); 469 X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s);
470
454 /* We need to set the verify purpose. The purpose can be determined by 471 /* We need to set the verify purpose. The purpose can be determined by
455 * the context: if its a server it will verify SSL client certificates 472 * the context: if its a server it will verify SSL client certificates
456 * or vice versa. 473 * or vice versa.
457 */ 474 */
458 475 if (s->server)
459 if(s->server) i = X509_PURPOSE_SSL_CLIENT; 476 i = X509_PURPOSE_SSL_CLIENT;
460 else i = X509_PURPOSE_SSL_SERVER; 477 else
478 i = X509_PURPOSE_SSL_SERVER;
461 479
462 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust); 480 X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust);
463 481
482 if (s->verify_callback)
483 X509_STORE_CTX_set_verify_cb(&ctx, s->verify_callback);
484
464 if (s->ctx->app_verify_callback != NULL) 485 if (s->ctx->app_verify_callback != NULL)
486#if 1 /* new with OpenSSL 0.9.7 */
487 i=s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg);
488#else
465 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */ 489 i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */
490#endif
466 else 491 else
467 { 492 {
468#ifndef NO_X509_VERIFY 493#ifndef OPENSSL_NO_X509_VERIFY
469 i=X509_verify_cert(&ctx); 494 i=X509_verify_cert(&ctx);
470#else 495#else
471 i=0; 496 i=0;
@@ -575,7 +600,7 @@ static int xname_cmp(const X509_NAME * const *a, const X509_NAME * const *b)
575 return(X509_NAME_cmp(*a,*b)); 600 return(X509_NAME_cmp(*a,*b));
576 } 601 }
577 602
578#ifndef NO_STDIO 603#ifndef OPENSSL_NO_STDIO
579/*! 604/*!
580 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed; 605 * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed;
581 * it doesn't really have anything to do with clients (except that a common use 606 * it doesn't really have anything to do with clients (except that a common use
@@ -705,9 +730,9 @@ err:
705 * certs may have been added to \c stack. 730 * certs may have been added to \c stack.
706 */ 731 */
707 732
708#ifndef WIN32 733#ifndef OPENSSL_SYS_WIN32
709#ifndef VMS /* XXXX This may be fixed in the future */ 734#ifndef OPENSSL_SYS_VMS /* XXXX This may be fixed in the future */
710#ifndef MAC_OS_pre_X 735#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! */
711 736
712int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, 737int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
713 const char *dir) 738 const char *dir)
@@ -748,10 +773,61 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
748 ret = 1; 773 ret = 1;
749 774
750err: 775err:
776 if (d) closedir(d);
751 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); 777 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
752 return ret; 778 return ret;
753 } 779 }
754 780
755#endif 781#endif
756#endif 782#endif
783
784#else
785
786int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
787 const char *dir)
788 {
789 WIN32_FIND_DATA FindFileData;
790 HANDLE hFind;
791 int ret = 0;
792
793 CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
794
795 hFind = FindFirstFile(dir, &FindFileData);
796 /* Note that a side effect is that the CAs will be sorted by name */
797 if(hFind == INVALID_HANDLE_VALUE)
798 {
799 SYSerr(SYS_F_OPENDIR, get_last_sys_error());
800 ERR_add_error_data(3, "opendir('", dir, "')");
801 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);
802 goto err_noclose;
803 }
804
805 do
806 {
807 char buf[1024];
808 int r;
809
810 if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf)
811 {
812 SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);
813 goto err;
814 }
815
816 r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,FindFileData.cFileName);
817 if (r <= 0 || r >= sizeof buf)
818 goto err;
819 if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
820 goto err;
821 }
822 while (FindNextFile(hFind, &FindFileData) != FALSE);
823 ret = 1;
824
825err:
826 FindClose(hFind);
827err_noclose:
828 if (d) closedir(d);
829 CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
830 return ret;
831 }
832
757#endif 833#endif
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c
index f63163f26c..cdd8dde128 100644
--- a/src/lib/libssl/ssl_ciph.c
+++ b/src/lib/libssl/ssl_ciph.c
@@ -68,7 +68,9 @@
68#define SSL_ENC_IDEA_IDX 4 68#define SSL_ENC_IDEA_IDX 4
69#define SSL_ENC_eFZA_IDX 5 69#define SSL_ENC_eFZA_IDX 5
70#define SSL_ENC_NULL_IDX 6 70#define SSL_ENC_NULL_IDX 6
71#define SSL_ENC_NUM_IDX 7 71#define SSL_ENC_AES128_IDX 7
72#define SSL_ENC_AES256_IDX 8
73#define SSL_ENC_NUM_IDX 9
72 74
73static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ 75static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={
74 NULL,NULL,NULL,NULL,NULL,NULL, 76 NULL,NULL,NULL,NULL,NULL,NULL,
@@ -98,8 +100,10 @@ typedef struct cipher_order_st
98 } CIPHER_ORDER; 100 } CIPHER_ORDER;
99 101
100static const SSL_CIPHER cipher_aliases[]={ 102static const SSL_CIPHER cipher_aliases[]={
101 /* Don't include eNULL unless specifically enabled */ 103 /* Don't include eNULL unless specifically enabled.
102 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */ 104 * Similarly, don't include AES in ALL because these ciphers are not yet official. */
105 {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL & ~SSL_AES, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */
106 {0,SSL_TXT_kKRB5,0,SSL_kKRB5,0,0,0,0,SSL_MKEY_MASK,0}, /* VRS Kerberos5 */
103 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0}, 107 {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0},
104 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0}, 108 {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0},
105 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0}, 109 {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0},
@@ -108,6 +112,7 @@ static const SSL_CIPHER cipher_aliases[]={
108 {0,SSL_TXT_DH, 0,SSL_DH, 0,0,0,0,SSL_MKEY_MASK,0}, 112 {0,SSL_TXT_DH, 0,SSL_DH, 0,0,0,0,SSL_MKEY_MASK,0},
109 {0,SSL_TXT_EDH, 0,SSL_EDH, 0,0,0,0,SSL_MKEY_MASK|SSL_AUTH_MASK,0}, 113 {0,SSL_TXT_EDH, 0,SSL_EDH, 0,0,0,0,SSL_MKEY_MASK|SSL_AUTH_MASK,0},
110 114
115 {0,SSL_TXT_aKRB5,0,SSL_aKRB5,0,0,0,0,SSL_AUTH_MASK,0}, /* VRS Kerberos5 */
111 {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,0,0,0,SSL_AUTH_MASK,0}, 116 {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,0,0,0,SSL_AUTH_MASK,0},
112 {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,0,0,0,SSL_AUTH_MASK,0}, 117 {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,0,0,0,SSL_AUTH_MASK,0},
113 {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,0,0,0,SSL_AUTH_MASK,0}, 118 {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,0,0,0,SSL_AUTH_MASK,0},
@@ -122,12 +127,14 @@ static const SSL_CIPHER cipher_aliases[]={
122 {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,0,0,0,SSL_ENC_MASK,0}, 127 {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,0,0,0,SSL_ENC_MASK,0},
123 {0,SSL_TXT_eNULL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0}, 128 {0,SSL_TXT_eNULL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0},
124 {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,0,0,0,SSL_ENC_MASK,0}, 129 {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,0,0,0,SSL_ENC_MASK,0},
130 {0,SSL_TXT_AES, 0,SSL_AES, 0,0,0,0,SSL_ENC_MASK,0},
125 131
126 {0,SSL_TXT_MD5, 0,SSL_MD5, 0,0,0,0,SSL_MAC_MASK,0}, 132 {0,SSL_TXT_MD5, 0,SSL_MD5, 0,0,0,0,SSL_MAC_MASK,0},
127 {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,0,0,0,SSL_MAC_MASK,0}, 133 {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,0,0,0,SSL_MAC_MASK,0},
128 {0,SSL_TXT_SHA, 0,SSL_SHA, 0,0,0,0,SSL_MAC_MASK,0}, 134 {0,SSL_TXT_SHA, 0,SSL_SHA, 0,0,0,0,SSL_MAC_MASK,0},
129 135
130 {0,SSL_TXT_NULL,0,SSL_NULL, 0,0,0,0,SSL_ENC_MASK,0}, 136 {0,SSL_TXT_NULL,0,SSL_NULL, 0,0,0,0,SSL_ENC_MASK,0},
137 {0,SSL_TXT_KRB5,0,SSL_KRB5, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
131 {0,SSL_TXT_RSA, 0,SSL_RSA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, 138 {0,SSL_TXT_RSA, 0,SSL_RSA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
132 {0,SSL_TXT_ADH, 0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, 139 {0,SSL_TXT_ADH, 0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0},
133 {0,SSL_TXT_FZA, 0,SSL_FZA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK,0}, 140 {0,SSL_TXT_FZA, 0,SSL_FZA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK,0},
@@ -160,6 +167,10 @@ static void load_ciphers(void)
160 EVP_get_cipherbyname(SN_rc2_cbc); 167 EVP_get_cipherbyname(SN_rc2_cbc);
161 ssl_cipher_methods[SSL_ENC_IDEA_IDX]= 168 ssl_cipher_methods[SSL_ENC_IDEA_IDX]=
162 EVP_get_cipherbyname(SN_idea_cbc); 169 EVP_get_cipherbyname(SN_idea_cbc);
170 ssl_cipher_methods[SSL_ENC_AES128_IDX]=
171 EVP_get_cipherbyname(SN_aes_128_cbc);
172 ssl_cipher_methods[SSL_ENC_AES256_IDX]=
173 EVP_get_cipherbyname(SN_aes_256_cbc);
163 174
164 ssl_digest_methods[SSL_MD_MD5_IDX]= 175 ssl_digest_methods[SSL_MD_MD5_IDX]=
165 EVP_get_digestbyname(SN_md5); 176 EVP_get_digestbyname(SN_md5);
@@ -220,6 +231,14 @@ int ssl_cipher_get_evp(SSL_SESSION *s, const EVP_CIPHER **enc,
220 case SSL_eNULL: 231 case SSL_eNULL:
221 i=SSL_ENC_NULL_IDX; 232 i=SSL_ENC_NULL_IDX;
222 break; 233 break;
234 case SSL_AES:
235 switch(c->alg_bits)
236 {
237 case 128: i=SSL_ENC_AES128_IDX; break;
238 case 256: i=SSL_ENC_AES256_IDX; break;
239 default: i=-1; break;
240 }
241 break;
223 default: 242 default:
224 i= -1; 243 i= -1;
225 break; 244 break;
@@ -282,15 +301,18 @@ static unsigned long ssl_cipher_get_disabled(void)
282 unsigned long mask; 301 unsigned long mask;
283 302
284 mask = SSL_kFZA; 303 mask = SSL_kFZA;
285#ifdef NO_RSA 304#ifdef OPENSSL_NO_RSA
286 mask |= SSL_aRSA|SSL_kRSA; 305 mask |= SSL_aRSA|SSL_kRSA;
287#endif 306#endif
288#ifdef NO_DSA 307#ifdef OPENSSL_NO_DSA
289 mask |= SSL_aDSS; 308 mask |= SSL_aDSS;
290#endif 309#endif
291#ifdef NO_DH 310#ifdef OPENSSL_NO_DH
292 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; 311 mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH;
293#endif 312#endif
313#ifdef OPENSSL_NO_KRB5
314 mask |= SSL_kKRB5|SSL_aKRB5;
315#endif
294 316
295#ifdef SSL_FORBID_ENULL 317#ifdef SSL_FORBID_ENULL
296 mask |= SSL_eNULL; 318 mask |= SSL_eNULL;
@@ -302,6 +324,7 @@ static unsigned long ssl_cipher_get_disabled(void)
302 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0; 324 mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0;
303 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0; 325 mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0;
304 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0; 326 mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0;
327 mask |= (ssl_cipher_methods[SSL_ENC_AES128_IDX] == NULL) ? SSL_AES:0;
305 328
306 mask |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 :0; 329 mask |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 :0;
307 mask |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1:0; 330 mask |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1:0;
@@ -336,6 +359,9 @@ static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method,
336 list[list_num].prev = NULL; 359 list[list_num].prev = NULL;
337 list[list_num].active = 0; 360 list[list_num].active = 0;
338 list_num++; 361 list_num++;
362#ifdef KSSL_DEBUG
363 printf("\t%d: %s %lx %lx\n",i,c->name,c->id,c->algorithms);
364#endif /* KSSL_DEBUG */
339 /* 365 /*
340 if (!sk_push(ca_list,(char *)c)) goto err; 366 if (!sk_push(ca_list,(char *)c)) goto err;
341 */ 367 */
@@ -738,6 +764,9 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
738 * it is used for allocation. 764 * it is used for allocation.
739 */ 765 */
740 num_of_ciphers = ssl_method->num_ciphers(); 766 num_of_ciphers = ssl_method->num_ciphers();
767#ifdef KSSL_DEBUG
768 printf("ssl_create_cipher_list() for %d ciphers\n", num_of_ciphers);
769#endif /* KSSL_DEBUG */
741 list = (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers); 770 list = (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers);
742 if (list == NULL) 771 if (list == NULL)
743 { 772 {
@@ -872,8 +901,12 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
872 char *ver,*exp; 901 char *ver,*exp;
873 char *kx,*au,*enc,*mac; 902 char *kx,*au,*enc,*mac;
874 unsigned long alg,alg2,alg_s; 903 unsigned long alg,alg2,alg_s;
904#ifdef KSSL_DEBUG
905 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s AL=%lx\n";
906#else
875 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; 907 static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n";
876 908#endif /* KSSL_DEBUG */
909
877 alg=cipher->algorithms; 910 alg=cipher->algorithms;
878 alg_s=cipher->algo_strength; 911 alg_s=cipher->algo_strength;
879 alg2=cipher->algorithm2; 912 alg2=cipher->algorithm2;
@@ -901,6 +934,10 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
901 case SSL_kDHd: 934 case SSL_kDHd:
902 kx="DH/DSS"; 935 kx="DH/DSS";
903 break; 936 break;
937 case SSL_kKRB5: /* VRS */
938 case SSL_KRB5: /* VRS */
939 kx="KRB5";
940 break;
904 case SSL_kFZA: 941 case SSL_kFZA:
905 kx="Fortezza"; 942 kx="Fortezza";
906 break; 943 break;
@@ -922,6 +959,10 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
922 case SSL_aDH: 959 case SSL_aDH:
923 au="DH"; 960 au="DH";
924 break; 961 break;
962 case SSL_aKRB5: /* VRS */
963 case SSL_KRB5: /* VRS */
964 au="KRB5";
965 break;
925 case SSL_aFZA: 966 case SSL_aFZA:
926 case SSL_aNULL: 967 case SSL_aNULL:
927 au="None"; 968 au="None";
@@ -955,6 +996,15 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
955 case SSL_eNULL: 996 case SSL_eNULL:
956 enc="None"; 997 enc="None";
957 break; 998 break;
999 case SSL_AES:
1000 switch(cipher->strength_bits)
1001 {
1002 case 128: enc="AESdraft(128)"; break;
1003 case 192: enc="AESdraft(192)"; break;
1004 case 256: enc="AESdraft(256)"; break;
1005 default: enc="AESdraft(?""?""?)"; break;
1006 }
1007 break;
958 default: 1008 default:
959 enc="unknown"; 1009 enc="unknown";
960 break; 1010 break;
@@ -982,7 +1032,11 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
982 else if (len < 128) 1032 else if (len < 128)
983 return("Buffer too small"); 1033 return("Buffer too small");
984 1034
1035#ifdef KSSL_DEBUG
1036 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp,alg);
1037#else
985 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp); 1038 BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp);
1039#endif /* KSSL_DEBUG */
986 return(buf); 1040 return(buf);
987 } 1041 }
988 1042
@@ -1053,6 +1107,10 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
1053 SSL_COMP *comp; 1107 SSL_COMP *comp;
1054 STACK_OF(SSL_COMP) *sk; 1108 STACK_OF(SSL_COMP) *sk;
1055 1109
1110 if (cm == NULL || cm->type == NID_undef)
1111 return 1;
1112
1113 MemCheck_off();
1056 comp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP)); 1114 comp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
1057 comp->id=id; 1115 comp->id=id;
1058 comp->method=cm; 1116 comp->method=cm;
@@ -1062,10 +1120,13 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
1062 sk=ssl_comp_methods; 1120 sk=ssl_comp_methods;
1063 if ((sk == NULL) || !sk_SSL_COMP_push(sk,comp)) 1121 if ((sk == NULL) || !sk_SSL_COMP_push(sk,comp))
1064 { 1122 {
1123 MemCheck_on();
1065 SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE); 1124 SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE);
1066 return(0); 1125 return(0);
1067 } 1126 }
1068 else 1127 else
1128 {
1129 MemCheck_on();
1069 return(1); 1130 return(1);
1131 }
1070 } 1132 }
1071
diff --git a/src/lib/libssl/ssl_err.c b/src/lib/libssl/ssl_err.c
index 1ae3333407..c32c4ef6e9 100644
--- a/src/lib/libssl/ssl_err.c
+++ b/src/lib/libssl/ssl_err.c
@@ -63,7 +63,7 @@
63#include <openssl/ssl.h> 63#include <openssl/ssl.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA SSL_str_functs[]= 67static ERR_STRING_DATA SSL_str_functs[]=
68 { 68 {
69{ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"}, 69{ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"},
@@ -106,6 +106,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
106{ERR_PACK(0,SSL_F_SSL3_CTRL,0), "SSL3_CTRL"}, 106{ERR_PACK(0,SSL_F_SSL3_CTRL,0), "SSL3_CTRL"},
107{ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"}, 107{ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"},
108{ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"}, 108{ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"},
109{ERR_PACK(0,SSL_F_SSL3_GENERATE_KEY_BLOCK,0), "SSL3_GENERATE_KEY_BLOCK"},
109{ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"}, 110{ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"},
110{ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"}, 111{ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"},
111{ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"}, 112{ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"},
@@ -258,6 +259,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
258{SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"}, 259{SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"},
259{SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"}, 260{SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"},
260{SSL_R_DECRYPTION_FAILED ,"decryption failed"}, 261{SSL_R_DECRYPTION_FAILED ,"decryption failed"},
262{SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC,"decryption failed or bad record mac"},
261{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, 263{SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"},
262{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, 264{SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"},
263{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, 265{SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"},
@@ -268,15 +270,27 @@ static ERR_STRING_DATA SSL_str_reasons[]=
268{SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"}, 270{SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"},
269{SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"}, 271{SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"},
270{SSL_R_HTTP_REQUEST ,"http request"}, 272{SSL_R_HTTP_REQUEST ,"http request"},
271{SSL_R_INTERNAL_ERROR ,"internal error"}, 273{SSL_R_ILLEGAL_PADDING ,"illegal padding"},
272{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, 274{SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"},
273{SSL_R_INVALID_COMMAND ,"invalid command"}, 275{SSL_R_INVALID_COMMAND ,"invalid command"},
274{SSL_R_INVALID_PURPOSE ,"invalid purpose"}, 276{SSL_R_INVALID_PURPOSE ,"invalid purpose"},
275{SSL_R_INVALID_TRUST ,"invalid trust"}, 277{SSL_R_INVALID_TRUST ,"invalid trust"},
278{SSL_R_KRB5 ,"krb5"},
279{SSL_R_KRB5_C_CC_PRINC ,"krb5 client cc principal (no tkt?)"},
280{SSL_R_KRB5_C_GET_CRED ,"krb5 client get cred"},
281{SSL_R_KRB5_C_INIT ,"krb5 client init"},
282{SSL_R_KRB5_C_MK_REQ ,"krb5 client mk_req (expired tkt?)"},
283{SSL_R_KRB5_S_BAD_TICKET ,"krb5 server bad ticket"},
284{SSL_R_KRB5_S_INIT ,"krb5 server init"},
285{SSL_R_KRB5_S_RD_REQ ,"krb5 server rd_req (keytab perms?)"},
286{SSL_R_KRB5_S_TKT_EXPIRED ,"krb5 server tkt expired"},
287{SSL_R_KRB5_S_TKT_NYV ,"krb5 server tkt not yet valid"},
288{SSL_R_KRB5_S_TKT_SKEW ,"krb5 server tkt skew"},
276{SSL_R_LENGTH_MISMATCH ,"length mismatch"}, 289{SSL_R_LENGTH_MISMATCH ,"length mismatch"},
277{SSL_R_LENGTH_TOO_SHORT ,"length too short"}, 290{SSL_R_LENGTH_TOO_SHORT ,"length too short"},
278{SSL_R_LIBRARY_BUG ,"library bug"}, 291{SSL_R_LIBRARY_BUG ,"library bug"},
279{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, 292{SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"},
293{SSL_R_MESSAGE_TOO_LONG ,"message too long"},
280{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, 294{SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"},
281{SSL_R_MISSING_DH_KEY ,"missing dh key"}, 295{SSL_R_MISSING_DH_KEY ,"missing dh key"},
282{SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"}, 296{SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"},
@@ -360,7 +374,10 @@ static ERR_STRING_DATA SSL_str_reasons[]=
360{SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"}, 374{SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"},
361{SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"}, 375{SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"},
362{SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"}, 376{SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"},
377{SSL_R_SSL_SESSION_ID_CALLBACK_FAILED ,"ssl session id callback failed"},
378{SSL_R_SSL_SESSION_ID_CONFLICT ,"ssl session id conflict"},
363{SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG ,"ssl session id context too long"}, 379{SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG ,"ssl session id context too long"},
380{SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH ,"ssl session id has bad length"},
364{SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"}, 381{SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"},
365{SSL_R_TLSV1_ALERT_ACCESS_DENIED ,"tlsv1 alert access denied"}, 382{SSL_R_TLSV1_ALERT_ACCESS_DENIED ,"tlsv1 alert access denied"},
366{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"}, 383{SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"},
@@ -426,7 +443,7 @@ void ERR_load_SSL_strings(void)
426 if (init) 443 if (init)
427 { 444 {
428 init=0; 445 init=0;
429#ifndef NO_ERR 446#ifndef OPENSSL_NO_ERR
430 ERR_load_strings(ERR_LIB_SSL,SSL_str_functs); 447 ERR_load_strings(ERR_LIB_SSL,SSL_str_functs);
431 ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons); 448 ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons);
432#endif 449#endif
diff --git a/src/lib/libssl/ssl_err2.c b/src/lib/libssl/ssl_err2.c
index cc089a612b..ea95a5f983 100644
--- a/src/lib/libssl/ssl_err2.c
+++ b/src/lib/libssl/ssl_err2.c
@@ -62,7 +62,7 @@
62 62
63void SSL_load_error_strings(void) 63void SSL_load_error_strings(void)
64 { 64 {
65#ifndef NO_ERR 65#ifndef OPENSSL_NO_ERR
66 ERR_load_crypto_strings(); 66 ERR_load_crypto_strings();
67 ERR_load_SSL_strings(); 67 ERR_load_SSL_strings();
68#endif 68#endif
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 1fe85b6cb7..df307a80c5 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -57,22 +57,73 @@
57 * copied and put under another distribution licence 57 * copied and put under another distribution licence
58 * [including the GNU Public Licence.] 58 * [including the GNU Public Licence.]
59 */ 59 */
60/* ====================================================================
61 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 *
67 * 1. Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 *
70 * 2. Redistributions in binary form must reproduce the above copyright
71 * notice, this list of conditions and the following disclaimer in
72 * the documentation and/or other materials provided with the
73 * distribution.
74 *
75 * 3. All advertising materials mentioning features or use of this
76 * software must display the following acknowledgment:
77 * "This product includes software developed by the OpenSSL Project
78 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
79 *
80 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
81 * endorse or promote products derived from this software without
82 * prior written permission. For written permission, please contact
83 * openssl-core@openssl.org.
84 *
85 * 5. Products derived from this software may not be called "OpenSSL"
86 * nor may "OpenSSL" appear in their names without prior written
87 * permission of the OpenSSL Project.
88 *
89 * 6. Redistributions of any form whatsoever must retain the following
90 * acknowledgment:
91 * "This product includes software developed by the OpenSSL Project
92 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
93 *
94 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
95 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
97 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
98 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
99 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
100 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
101 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
102 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
103 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
104 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
105 * OF THE POSSIBILITY OF SUCH DAMAGE.
106 * ====================================================================
107 *
108 * This product includes cryptographic software written by Eric Young
109 * (eay@cryptsoft.com). This product includes software written by Tim
110 * Hudson (tjh@cryptsoft.com).
111 *
112 */
60 113
61 114
62#include <assert.h> 115#ifdef REF_CHECK
116# include <assert.h>
117#endif
63#include <stdio.h> 118#include <stdio.h>
64#include <openssl/objects.h> 119#include <openssl/objects.h>
65#include <openssl/lhash.h> 120#include <openssl/lhash.h>
66#include <openssl/x509v3.h> 121#include <openssl/x509v3.h>
67#include "ssl_locl.h" 122#include "ssl_locl.h"
123#include "kssl_lcl.h"
68 124
69const char *SSL_version_str=OPENSSL_VERSION_TEXT; 125const char *SSL_version_str=OPENSSL_VERSION_TEXT;
70 126
71static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_meth=NULL;
72static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_ctx_meth=NULL;
73static int ssl_meth_num=0;
74static int ssl_ctx_meth_num=0;
75
76OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={ 127OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
77 /* evil casts, but these functions are only called if there's a library bug */ 128 /* evil casts, but these functions are only called if there's a library bug */
78 (int (*)(SSL *,int))ssl_undefined_function, 129 (int (*)(SSL *,int))ssl_undefined_function,
@@ -85,7 +136,6 @@ OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={
85 136
86int SSL_clear(SSL *s) 137int SSL_clear(SSL *s)
87 { 138 {
88 int state;
89 139
90 if (s->method == NULL) 140 if (s->method == NULL)
91 { 141 {
@@ -93,6 +143,12 @@ int SSL_clear(SSL *s)
93 return(0); 143 return(0);
94 } 144 }
95 145
146 if (ssl_clear_bad_session(s))
147 {
148 SSL_SESSION_free(s->session);
149 s->session=NULL;
150 }
151
96 s->error=0; 152 s->error=0;
97 s->hit=0; 153 s->hit=0;
98 s->shutdown=0; 154 s->shutdown=0;
@@ -105,12 +161,11 @@ int SSL_clear(SSL *s)
105#else 161#else
106 if (s->new_session) 162 if (s->new_session)
107 { 163 {
108 SSLerr(SSL_F_SSL_CLEAR,SSL_R_INTERNAL_ERROR); 164 SSLerr(SSL_F_SSL_CLEAR,ERR_R_INTERNAL_ERROR);
109 return 0; 165 return 0;
110 } 166 }
111#endif 167#endif
112 168
113 state=s->state; /* Keep to check if we throw away the session-id */
114 s->type=0; 169 s->type=0;
115 170
116 s->state=SSL_ST_BEFORE|((s->server)?SSL_ST_ACCEPT:SSL_ST_CONNECT); 171 s->state=SSL_ST_BEFORE|((s->server)?SSL_ST_ACCEPT:SSL_ST_CONNECT);
@@ -131,18 +186,12 @@ int SSL_clear(SSL *s)
131 186
132 ssl_clear_cipher_ctx(s); 187 ssl_clear_cipher_ctx(s);
133 188
134 if (ssl_clear_bad_session(s))
135 {
136 SSL_SESSION_free(s->session);
137 s->session=NULL;
138 }
139
140 s->first_packet=0; 189 s->first_packet=0;
141 190
142#if 1 191#if 1
143 /* Check to see if we were changed into a different method, if 192 /* Check to see if we were changed into a different method, if
144 * so, revert back if we are not doing session-id reuse. */ 193 * so, revert back if we are not doing session-id reuse. */
145 if ((s->session == NULL) && (s->method != s->ctx->method)) 194 if (!s->in_handshake && (s->session == NULL) && (s->method != s->ctx->method))
146 { 195 {
147 s->method->ssl_free(s); 196 s->method->ssl_free(s);
148 s->method=s->ctx->method; 197 s->method=s->ctx->method;
@@ -191,6 +240,14 @@ SSL *SSL_new(SSL_CTX *ctx)
191 if (s == NULL) goto err; 240 if (s == NULL) goto err;
192 memset(s,0,sizeof(SSL)); 241 memset(s,0,sizeof(SSL));
193 242
243#ifndef OPENSSL_NO_KRB5
244 s->kssl_ctx = kssl_ctx_new();
245#endif /* OPENSSL_NO_KRB5 */
246
247 s->options=ctx->options;
248 s->mode=ctx->mode;
249 s->max_cert_list=ctx->max_cert_list;
250
194 if (ctx->cert != NULL) 251 if (ctx->cert != NULL)
195 { 252 {
196 /* Earlier library versions used to copy the pointer to 253 /* Earlier library versions used to copy the pointer to
@@ -209,13 +266,20 @@ SSL *SSL_new(SSL_CTX *ctx)
209 } 266 }
210 else 267 else
211 s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */ 268 s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */
212 s->sid_ctx_length=ctx->sid_ctx_length; 269
213 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); 270 s->read_ahead=ctx->read_ahead;
271 s->msg_callback=ctx->msg_callback;
272 s->msg_callback_arg=ctx->msg_callback_arg;
214 s->verify_mode=ctx->verify_mode; 273 s->verify_mode=ctx->verify_mode;
215 s->verify_depth=ctx->verify_depth; 274 s->verify_depth=ctx->verify_depth;
275 s->sid_ctx_length=ctx->sid_ctx_length;
276 memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx));
216 s->verify_callback=ctx->default_verify_callback; 277 s->verify_callback=ctx->default_verify_callback;
278 s->generate_session_id=ctx->generate_session_id;
217 s->purpose = ctx->purpose; 279 s->purpose = ctx->purpose;
218 s->trust = ctx->trust; 280 s->trust = ctx->trust;
281 s->quiet_shutdown=ctx->quiet_shutdown;
282
219 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); 283 CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
220 s->ctx=ctx; 284 s->ctx=ctx;
221 285
@@ -226,15 +290,12 @@ SSL *SSL_new(SSL_CTX *ctx)
226 if (!s->method->ssl_new(s)) 290 if (!s->method->ssl_new(s))
227 goto err; 291 goto err;
228 292
229 s->quiet_shutdown=ctx->quiet_shutdown;
230 s->references=1; 293 s->references=1;
231 s->server=(ctx->method->ssl_accept == ssl_undefined_function)?0:1; 294 s->server=(ctx->method->ssl_accept == ssl_undefined_function)?0:1;
232 s->options=ctx->options; 295
233 s->mode=ctx->mode;
234 s->read_ahead=ctx->read_ahead; /* used to happen in SSL_clear */
235 SSL_clear(s); 296 SSL_clear(s);
236 297
237 CRYPTO_new_ex_data(ssl_meth,s,&s->ex_data); 298 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
238 299
239 return(s); 300 return(s);
240err: 301err:
@@ -278,45 +339,71 @@ int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx,
278 return 1; 339 return 1;
279 } 340 }
280 341
281int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) 342int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb)
282{ 343 {
283 if(X509_PURPOSE_get_by_id(purpose) == -1) { 344 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
284 SSLerr(SSL_F_SSL_CTX_SET_PURPOSE, SSL_R_INVALID_PURPOSE); 345 ctx->generate_session_id = cb;
285 return 0; 346 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
347 return 1;
286 } 348 }
287 s->purpose = purpose; 349
350int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB cb)
351 {
352 CRYPTO_w_lock(CRYPTO_LOCK_SSL);
353 ssl->generate_session_id = cb;
354 CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
288 return 1; 355 return 1;
289} 356 }
357
358int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
359 unsigned int id_len)
360 {
361 /* A quick examination of SSL_SESSION_hash and SSL_SESSION_cmp shows how
362 * we can "construct" a session to give us the desired check - ie. to
363 * find if there's a session in the hash table that would conflict with
364 * any new session built out of this id/id_len and the ssl_version in
365 * use by this SSL. */
366 SSL_SESSION r, *p;
367 r.ssl_version = ssl->version;
368 r.session_id_length = id_len;
369 memcpy(r.session_id, id, id_len);
370 /* NB: SSLv2 always uses a fixed 16-byte session ID, so even if a
371 * callback is calling us to check the uniqueness of a shorter ID, it
372 * must be compared as a padded-out ID because that is what it will be
373 * converted to when the callback has finished choosing it. */
374 if((r.ssl_version == SSL2_VERSION) &&
375 (id_len < SSL2_SSL_SESSION_ID_LENGTH))
376 {
377 memset(r.session_id + id_len, 0,
378 SSL2_SSL_SESSION_ID_LENGTH - id_len);
379 r.session_id_length = SSL2_SSL_SESSION_ID_LENGTH;
380 }
381
382 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
383 p = (SSL_SESSION *)lh_retrieve(ssl->ctx->sessions, &r);
384 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
385 return (p != NULL);
386 }
387
388int SSL_CTX_set_purpose(SSL_CTX *s, int purpose)
389 {
390 return X509_PURPOSE_set(&s->purpose, purpose);
391 }
290 392
291int SSL_set_purpose(SSL *s, int purpose) 393int SSL_set_purpose(SSL *s, int purpose)
292{ 394 {
293 if(X509_PURPOSE_get_by_id(purpose) == -1) { 395 return X509_PURPOSE_set(&s->purpose, purpose);
294 SSLerr(SSL_F_SSL_SET_PURPOSE, SSL_R_INVALID_PURPOSE);
295 return 0;
296 } 396 }
297 s->purpose = purpose; 397
298 return 1;
299}
300
301int SSL_CTX_set_trust(SSL_CTX *s, int trust) 398int SSL_CTX_set_trust(SSL_CTX *s, int trust)
302{ 399 {
303 if(X509_TRUST_get_by_id(trust) == -1) { 400 return X509_TRUST_set(&s->trust, trust);
304 SSLerr(SSL_F_SSL_CTX_SET_TRUST, SSL_R_INVALID_TRUST);
305 return 0;
306 } 401 }
307 s->trust = trust;
308 return 1;
309}
310 402
311int SSL_set_trust(SSL *s, int trust) 403int SSL_set_trust(SSL *s, int trust)
312{ 404 {
313 if(X509_TRUST_get_by_id(trust) == -1) { 405 return X509_TRUST_set(&s->trust, trust);
314 SSLerr(SSL_F_SSL_SET_TRUST, SSL_R_INVALID_TRUST);
315 return 0;
316 } 406 }
317 s->trust = trust;
318 return 1;
319}
320 407
321void SSL_free(SSL *s) 408void SSL_free(SSL *s)
322 { 409 {
@@ -338,7 +425,7 @@ void SSL_free(SSL *s)
338 } 425 }
339#endif 426#endif
340 427
341 CRYPTO_free_ex_data(ssl_meth,(char *)s,&s->ex_data); 428 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
342 429
343 if (s->bbio != NULL) 430 if (s->bbio != NULL)
344 { 431 {
@@ -411,6 +498,11 @@ BIO *SSL_get_wbio(SSL *s)
411 498
412int SSL_get_fd(SSL *s) 499int SSL_get_fd(SSL *s)
413 { 500 {
501 return(SSL_get_rfd(s));
502 }
503
504int SSL_get_rfd(SSL *s)
505 {
414 int ret= -1; 506 int ret= -1;
415 BIO *b,*r; 507 BIO *b,*r;
416 508
@@ -421,7 +513,19 @@ int SSL_get_fd(SSL *s)
421 return(ret); 513 return(ret);
422 } 514 }
423 515
424#ifndef NO_SOCK 516int SSL_get_wfd(SSL *s)
517 {
518 int ret= -1;
519 BIO *b,*r;
520
521 b=SSL_get_wbio(s);
522 r=BIO_find_type(b,BIO_TYPE_DESCRIPTOR);
523 if (r != NULL)
524 BIO_get_fd(r,&ret);
525 return(ret);
526 }
527
528#ifndef OPENSSL_NO_SOCK
425int SSL_set_fd(SSL *s,int fd) 529int SSL_set_fd(SSL *s,int fd)
426 { 530 {
427 int ret=0; 531 int ret=0;
@@ -576,6 +680,13 @@ int SSL_get_read_ahead(SSL *s)
576 680
577int SSL_pending(SSL *s) 681int SSL_pending(SSL *s)
578 { 682 {
683 /* SSL_pending cannot work properly if read-ahead is enabled
684 * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)),
685 * and it is impossible to fix since SSL_pending cannot report
686 * errors that may be observed while scanning the new data.
687 * (Note that SSL_pending() is often used as a boolean value,
688 * so we'd better not return -1.)
689 */
579 return(s->method->ssl_pending(s)); 690 return(s->method->ssl_pending(s));
580 } 691 }
581 692
@@ -778,11 +889,21 @@ int SSL_shutdown(SSL *s)
778 889
779int SSL_renegotiate(SSL *s) 890int SSL_renegotiate(SSL *s)
780 { 891 {
781 s->new_session=1; 892 if (s->new_session == 0)
893 {
894 s->new_session=1;
895 }
782 return(s->method->ssl_renegotiate(s)); 896 return(s->method->ssl_renegotiate(s));
783 } 897 }
784 898
785long SSL_ctrl(SSL *s,int cmd,long larg,char *parg) 899int SSL_renegotiate_pending(SSL *s)
900 {
901 /* becomes true when negotiation is requested;
902 * false again once a handshake has finished */
903 return (s->new_session != 0);
904 }
905
906long SSL_ctrl(SSL *s,int cmd,long larg,void *parg)
786 { 907 {
787 long l; 908 long l;
788 909
@@ -794,10 +915,21 @@ long SSL_ctrl(SSL *s,int cmd,long larg,char *parg)
794 l=s->read_ahead; 915 l=s->read_ahead;
795 s->read_ahead=larg; 916 s->read_ahead=larg;
796 return(l); 917 return(l);
918
919 case SSL_CTRL_SET_MSG_CALLBACK_ARG:
920 s->msg_callback_arg = parg;
921 return 1;
922
797 case SSL_CTRL_OPTIONS: 923 case SSL_CTRL_OPTIONS:
798 return(s->options|=larg); 924 return(s->options|=larg);
799 case SSL_CTRL_MODE: 925 case SSL_CTRL_MODE:
800 return(s->mode|=larg); 926 return(s->mode|=larg);
927 case SSL_CTRL_GET_MAX_CERT_LIST:
928 return(s->max_cert_list);
929 case SSL_CTRL_SET_MAX_CERT_LIST:
930 l=s->max_cert_list;
931 s->max_cert_list=larg;
932 return(l);
801 default: 933 default:
802 return(s->method->ssl_ctrl(s,cmd,larg,parg)); 934 return(s->method->ssl_ctrl(s,cmd,larg,parg));
803 } 935 }
@@ -807,6 +939,10 @@ long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)())
807 { 939 {
808 switch(cmd) 940 switch(cmd)
809 { 941 {
942 case SSL_CTRL_SET_MSG_CALLBACK:
943 s->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp);
944 return 1;
945
810 default: 946 default:
811 return(s->method->ssl_callback_ctrl(s,cmd,fp)); 947 return(s->method->ssl_callback_ctrl(s,cmd,fp));
812 } 948 }
@@ -817,7 +953,7 @@ struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx)
817 return ctx->sessions; 953 return ctx->sessions;
818 } 954 }
819 955
820long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) 956long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,void *parg)
821 { 957 {
822 long l; 958 long l;
823 959
@@ -829,6 +965,17 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg)
829 l=ctx->read_ahead; 965 l=ctx->read_ahead;
830 ctx->read_ahead=larg; 966 ctx->read_ahead=larg;
831 return(l); 967 return(l);
968
969 case SSL_CTRL_SET_MSG_CALLBACK_ARG:
970 ctx->msg_callback_arg = parg;
971 return 1;
972
973 case SSL_CTRL_GET_MAX_CERT_LIST:
974 return(ctx->max_cert_list);
975 case SSL_CTRL_SET_MAX_CERT_LIST:
976 l=ctx->max_cert_list;
977 ctx->max_cert_list=larg;
978 return(l);
832 979
833 case SSL_CTRL_SET_SESS_CACHE_SIZE: 980 case SSL_CTRL_SET_SESS_CACHE_SIZE:
834 l=ctx->session_cache_size; 981 l=ctx->session_cache_size;
@@ -880,6 +1027,10 @@ long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)())
880 { 1027 {
881 switch(cmd) 1028 switch(cmd)
882 { 1029 {
1030 case SSL_CTRL_SET_MSG_CALLBACK:
1031 ctx->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp);
1032 return 1;
1033
883 default: 1034 default:
884 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp)); 1035 return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp));
885 } 1036 }
@@ -1018,6 +1169,9 @@ int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p)
1018 int i,j=0; 1169 int i,j=0;
1019 SSL_CIPHER *c; 1170 SSL_CIPHER *c;
1020 unsigned char *q; 1171 unsigned char *q;
1172#ifndef OPENSSL_NO_KRB5
1173 int nokrb5 = !kssl_tgt_is_available(s->kssl_ctx);
1174#endif /* OPENSSL_NO_KRB5 */
1021 1175
1022 if (sk == NULL) return(0); 1176 if (sk == NULL) return(0);
1023 q=p; 1177 q=p;
@@ -1025,6 +1179,10 @@ int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p)
1025 for (i=0; i<sk_SSL_CIPHER_num(sk); i++) 1179 for (i=0; i<sk_SSL_CIPHER_num(sk); i++)
1026 { 1180 {
1027 c=sk_SSL_CIPHER_value(sk,i); 1181 c=sk_SSL_CIPHER_value(sk,i);
1182#ifndef OPENSSL_NO_KRB5
1183 if ((c->algorithms & SSL_KRB5) && nokrb5)
1184 continue;
1185#endif /* OPENSSL_NO_KRB5 */
1028 j=ssl_put_cipher_by_char(s,c,p); 1186 j=ssl_put_cipher_by_char(s,c,p);
1029 p+=j; 1187 p+=j;
1030 } 1188 }
@@ -1087,6 +1245,11 @@ unsigned long SSL_SESSION_hash(SSL_SESSION *a)
1087 return(l); 1245 return(l);
1088 } 1246 }
1089 1247
1248/* NB: If this function (or indeed the hash function which uses a sort of
1249 * coarser function than this one) is changed, ensure
1250 * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being
1251 * able to construct an SSL_SESSION that will collide with any existing session
1252 * with a matching session ID. */
1090int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b) 1253int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
1091 { 1254 {
1092 if (a->ssl_version != b->ssl_version) 1255 if (a->ssl_version != b->ssl_version)
@@ -1096,6 +1259,13 @@ int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
1096 return(memcmp(a->session_id,b->session_id,a->session_id_length)); 1259 return(memcmp(a->session_id,b->session_id,a->session_id_length));
1097 } 1260 }
1098 1261
1262/* These wrapper functions should remain rather than redeclaring
1263 * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each
1264 * variable. The reason is that the functions aren't static, they're exposed via
1265 * ssl.h. */
1266static IMPLEMENT_LHASH_HASH_FN(SSL_SESSION_hash, SSL_SESSION *)
1267static IMPLEMENT_LHASH_COMP_FN(SSL_SESSION_cmp, SSL_SESSION *)
1268
1099SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) 1269SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1100 { 1270 {
1101 SSL_CTX *ret=NULL; 1271 SSL_CTX *ret=NULL;
@@ -1128,9 +1298,10 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1128 /* We take the system default */ 1298 /* We take the system default */
1129 ret->session_timeout=meth->get_timeout(); 1299 ret->session_timeout=meth->get_timeout();
1130 1300
1131 ret->new_session_cb=NULL; 1301 ret->new_session_cb=0;
1132 ret->remove_session_cb=NULL; 1302 ret->remove_session_cb=0;
1133 ret->get_session_cb=NULL; 1303 ret->get_session_cb=0;
1304 ret->generate_session_id=0;
1134 1305
1135 memset((char *)&ret->stats,0,sizeof(ret->stats)); 1306 memset((char *)&ret->stats,0,sizeof(ret->stats));
1136 1307
@@ -1145,21 +1316,26 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1145 1316
1146 ret->info_callback=NULL; 1317 ret->info_callback=NULL;
1147 1318
1148 ret->app_verify_callback=NULL; 1319 ret->app_verify_callback=0;
1149 ret->app_verify_arg=NULL; 1320 ret->app_verify_arg=NULL;
1150 1321
1322 ret->max_cert_list=SSL_MAX_CERT_LIST_DEFAULT;
1151 ret->read_ahead=0; 1323 ret->read_ahead=0;
1324 ret->msg_callback=0;
1325 ret->msg_callback_arg=NULL;
1152 ret->verify_mode=SSL_VERIFY_NONE; 1326 ret->verify_mode=SSL_VERIFY_NONE;
1153 ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ 1327 ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */
1328 ret->sid_ctx_length=0;
1154 ret->default_verify_callback=NULL; 1329 ret->default_verify_callback=NULL;
1155 if ((ret->cert=ssl_cert_new()) == NULL) 1330 if ((ret->cert=ssl_cert_new()) == NULL)
1156 goto err; 1331 goto err;
1157 1332
1158 ret->default_passwd_callback=NULL; 1333 ret->default_passwd_callback=0;
1159 ret->default_passwd_callback_userdata=NULL; 1334 ret->default_passwd_callback_userdata=NULL;
1160 ret->client_cert_cb=NULL; 1335 ret->client_cert_cb=0;
1161 1336
1162 ret->sessions=lh_new(SSL_SESSION_hash,SSL_SESSION_cmp); 1337 ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash),
1338 LHASH_COMP_FN(SSL_SESSION_cmp));
1163 if (ret->sessions == NULL) goto err; 1339 if (ret->sessions == NULL) goto err;
1164 ret->cert_store=X509_STORE_new(); 1340 ret->cert_store=X509_STORE_new();
1165 if (ret->cert_store == NULL) goto err; 1341 if (ret->cert_store == NULL) goto err;
@@ -1193,7 +1369,7 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1193 if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL) 1369 if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL)
1194 goto err; 1370 goto err;
1195 1371
1196 CRYPTO_new_ex_data(ssl_ctx_meth,(char *)ret,&ret->ex_data); 1372 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data);
1197 1373
1198 ret->extra_certs=NULL; 1374 ret->extra_certs=NULL;
1199 ret->comp_methods=SSL_COMP_get_compression_methods(); 1375 ret->comp_methods=SSL_COMP_get_compression_methods();
@@ -1206,8 +1382,10 @@ err2:
1206 return(NULL); 1382 return(NULL);
1207 } 1383 }
1208 1384
1385#if 0
1209static void SSL_COMP_free(SSL_COMP *comp) 1386static void SSL_COMP_free(SSL_COMP *comp)
1210 { OPENSSL_free(comp); } 1387 { OPENSSL_free(comp); }
1388#endif
1211 1389
1212void SSL_CTX_free(SSL_CTX *a) 1390void SSL_CTX_free(SSL_CTX *a)
1213 { 1391 {
@@ -1227,7 +1405,7 @@ void SSL_CTX_free(SSL_CTX *a)
1227 abort(); /* ok */ 1405 abort(); /* ok */
1228 } 1406 }
1229#endif 1407#endif
1230 CRYPTO_free_ex_data(ssl_ctx_meth,(char *)a,&a->ex_data); 1408 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);
1231 1409
1232 if (a->sessions != NULL) 1410 if (a->sessions != NULL)
1233 { 1411 {
@@ -1246,8 +1424,12 @@ void SSL_CTX_free(SSL_CTX *a)
1246 sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free); 1424 sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free);
1247 if (a->extra_certs != NULL) 1425 if (a->extra_certs != NULL)
1248 sk_X509_pop_free(a->extra_certs,X509_free); 1426 sk_X509_pop_free(a->extra_certs,X509_free);
1427#if 0 /* This should never be done, since it removes a global database */
1249 if (a->comp_methods != NULL) 1428 if (a->comp_methods != NULL)
1250 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free); 1429 sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);
1430#else
1431 a->comp_methods = NULL;
1432#endif
1251 OPENSSL_free(a); 1433 OPENSSL_free(a);
1252 } 1434 }
1253 1435
@@ -1261,23 +1443,16 @@ void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx,void *u)
1261 ctx->default_passwd_callback_userdata=u; 1443 ctx->default_passwd_callback_userdata=u;
1262 } 1444 }
1263 1445
1264void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,int (*cb)(),char *arg) 1446void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg)
1265 { 1447 {
1266 /* now
1267 * int (*cb)(X509_STORE_CTX *),
1268 * but should be
1269 * int (*cb)(X509_STORE_CTX *, void *arg)
1270 */
1271 ctx->app_verify_callback=cb; 1448 ctx->app_verify_callback=cb;
1272 ctx->app_verify_arg=arg; /* never used */ 1449 ctx->app_verify_arg=arg;
1273 } 1450 }
1274 1451
1275void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *)) 1452void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *))
1276 { 1453 {
1277 ctx->verify_mode=mode; 1454 ctx->verify_mode=mode;
1278 ctx->default_verify_callback=cb; 1455 ctx->default_verify_callback=cb;
1279 /* This needs cleaning up EAY EAY EAY */
1280 X509_STORE_set_verify_cb_func(ctx->cert_store,cb);
1281 } 1456 }
1282 1457
1283void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) 1458void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth)
@@ -1297,14 +1472,14 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1297 1472
1298 kl=SSL_C_EXPORT_PKEYLENGTH(cipher); 1473 kl=SSL_C_EXPORT_PKEYLENGTH(cipher);
1299 1474
1300#ifndef NO_RSA 1475#ifndef OPENSSL_NO_RSA
1301 rsa_tmp=(c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL); 1476 rsa_tmp=(c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL);
1302 rsa_tmp_export=(c->rsa_tmp_cb != NULL || 1477 rsa_tmp_export=(c->rsa_tmp_cb != NULL ||
1303 (rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl)); 1478 (rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl));
1304#else 1479#else
1305 rsa_tmp=rsa_tmp_export=0; 1480 rsa_tmp=rsa_tmp_export=0;
1306#endif 1481#endif
1307#ifndef NO_DH 1482#ifndef OPENSSL_NO_DH
1308 dh_tmp=(c->dh_tmp != NULL || c->dh_tmp_cb != NULL); 1483 dh_tmp=(c->dh_tmp != NULL || c->dh_tmp_cb != NULL);
1309 dh_tmp_export=(c->dh_tmp_cb != NULL || 1484 dh_tmp_export=(c->dh_tmp_cb != NULL ||
1310 (dh_tmp && DH_size(c->dh_tmp)*8 <= kl)); 1485 (dh_tmp && DH_size(c->dh_tmp)*8 <= kl));
@@ -1378,6 +1553,11 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
1378 mask|=SSL_aNULL; 1553 mask|=SSL_aNULL;
1379 emask|=SSL_aNULL; 1554 emask|=SSL_aNULL;
1380 1555
1556#ifndef OPENSSL_NO_KRB5
1557 mask|=SSL_kKRB5|SSL_aKRB5;
1558 emask|=SSL_kKRB5|SSL_aKRB5;
1559#endif
1560
1381 c->mask=mask; 1561 c->mask=mask;
1382 c->export_mask=emask; 1562 c->export_mask=emask;
1383 c->valid=1; 1563 c->valid=1;
@@ -1410,9 +1590,14 @@ X509 *ssl_get_server_send_cert(SSL *s)
1410 else 1590 else
1411 i=SSL_PKEY_RSA_ENC; 1591 i=SSL_PKEY_RSA_ENC;
1412 } 1592 }
1593 else if (kalg & SSL_aKRB5)
1594 {
1595 /* VRS something else here? */
1596 return(NULL);
1597 }
1413 else /* if (kalg & SSL_aNULL) */ 1598 else /* if (kalg & SSL_aNULL) */
1414 { 1599 {
1415 SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,SSL_R_INTERNAL_ERROR); 1600 SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,ERR_R_INTERNAL_ERROR);
1416 return(NULL); 1601 return(NULL);
1417 } 1602 }
1418 if (c->pkeys[i].x509 == NULL) return(NULL); 1603 if (c->pkeys[i].x509 == NULL) return(NULL);
@@ -1441,7 +1626,7 @@ EVP_PKEY *ssl_get_sign_pkey(SSL *s,SSL_CIPHER *cipher)
1441 } 1626 }
1442 else /* if (alg & SSL_aNULL) */ 1627 else /* if (alg & SSL_aNULL) */
1443 { 1628 {
1444 SSLerr(SSL_F_SSL_GET_SIGN_PKEY,SSL_R_INTERNAL_ERROR); 1629 SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR);
1445 return(NULL); 1630 return(NULL);
1446 } 1631 }
1447 } 1632 }
@@ -1454,9 +1639,10 @@ void ssl_update_cache(SSL *s,int mode)
1454 * and it would be rather hard to do anyway :-) */ 1639 * and it would be rather hard to do anyway :-) */
1455 if (s->session->session_id_length == 0) return; 1640 if (s->session->session_id_length == 0) return;
1456 1641
1457 if ((s->ctx->session_cache_mode & mode) 1642 i=s->ctx->session_cache_mode;
1458 && (!s->hit) 1643 if ((i & mode) && (!s->hit)
1459 && SSL_CTX_add_session(s->ctx,s->session) 1644 && ((i & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)
1645 || SSL_CTX_add_session(s->ctx,s->session))
1460 && (s->ctx->new_session_cb != NULL)) 1646 && (s->ctx->new_session_cb != NULL))
1461 { 1647 {
1462 CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION); 1648 CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION);
@@ -1465,7 +1651,6 @@ void ssl_update_cache(SSL *s,int mode)
1465 } 1651 }
1466 1652
1467 /* auto flush every 255 connections */ 1653 /* auto flush every 255 connections */
1468 i=s->ctx->session_cache_mode;
1469 if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) && 1654 if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) &&
1470 ((i & mode) == mode)) 1655 ((i & mode) == mode))
1471 { 1656 {
@@ -1549,6 +1734,8 @@ int SSL_get_error(SSL *s,int i)
1549 reason=BIO_get_retry_reason(bio); 1734 reason=BIO_get_retry_reason(bio);
1550 if (reason == BIO_RR_CONNECT) 1735 if (reason == BIO_RR_CONNECT)
1551 return(SSL_ERROR_WANT_CONNECT); 1736 return(SSL_ERROR_WANT_CONNECT);
1737 else if (reason == BIO_RR_ACCEPT)
1738 return(SSL_ERROR_WANT_ACCEPT);
1552 else 1739 else
1553 return(SSL_ERROR_SYSCALL); /* unknown */ 1740 return(SSL_ERROR_SYSCALL); /* unknown */
1554 } 1741 }
@@ -1567,6 +1754,8 @@ int SSL_get_error(SSL *s,int i)
1567 reason=BIO_get_retry_reason(bio); 1754 reason=BIO_get_retry_reason(bio);
1568 if (reason == BIO_RR_CONNECT) 1755 if (reason == BIO_RR_CONNECT)
1569 return(SSL_ERROR_WANT_CONNECT); 1756 return(SSL_ERROR_WANT_CONNECT);
1757 else if (reason == BIO_RR_ACCEPT)
1758 return(SSL_ERROR_WANT_ACCEPT);
1570 else 1759 else
1571 return(SSL_ERROR_SYSCALL); 1760 return(SSL_ERROR_SYSCALL);
1572 } 1761 }
@@ -1667,7 +1856,11 @@ SSL *SSL_dup(SSL *s)
1667 1856
1668 if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL) 1857 if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL)
1669 return(NULL); 1858 return(NULL);
1670 1859
1860 ret->version = s->version;
1861 ret->type = s->type;
1862 ret->method = s->method;
1863
1671 if (s->session != NULL) 1864 if (s->session != NULL)
1672 { 1865 {
1673 /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ 1866 /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */
@@ -1698,18 +1891,23 @@ SSL *SSL_dup(SSL *s)
1698 s->sid_ctx, s->sid_ctx_length); 1891 s->sid_ctx, s->sid_ctx_length);
1699 } 1892 }
1700 1893
1894 ret->options=s->options;
1895 ret->mode=s->mode;
1896 SSL_set_max_cert_list(ret,SSL_get_max_cert_list(s));
1701 SSL_set_read_ahead(ret,SSL_get_read_ahead(s)); 1897 SSL_set_read_ahead(ret,SSL_get_read_ahead(s));
1898 ret->msg_callback = s->msg_callback;
1899 ret->msg_callback_arg = s->msg_callback_arg;
1702 SSL_set_verify(ret,SSL_get_verify_mode(s), 1900 SSL_set_verify(ret,SSL_get_verify_mode(s),
1703 SSL_get_verify_callback(s)); 1901 SSL_get_verify_callback(s));
1704 SSL_set_verify_depth(ret,SSL_get_verify_depth(s)); 1902 SSL_set_verify_depth(ret,SSL_get_verify_depth(s));
1903 ret->generate_session_id = s->generate_session_id;
1705 1904
1706 SSL_set_info_callback(ret,SSL_get_info_callback(s)); 1905 SSL_set_info_callback(ret,SSL_get_info_callback(s));
1707 1906
1708 ret->debug=s->debug; 1907 ret->debug=s->debug;
1709 ret->options=s->options;
1710 1908
1711 /* copy app data, a little dangerous perhaps */ 1909 /* copy app data, a little dangerous perhaps */
1712 if (!CRYPTO_dup_ex_data(ssl_meth,&ret->ex_data,&s->ex_data)) 1910 if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, &ret->ex_data, &s->ex_data))
1713 goto err; 1911 goto err;
1714 1912
1715 /* setup rbio, and wbio */ 1913 /* setup rbio, and wbio */
@@ -1728,6 +1926,19 @@ SSL *SSL_dup(SSL *s)
1728 else 1926 else
1729 ret->wbio=ret->rbio; 1927 ret->wbio=ret->rbio;
1730 } 1928 }
1929 ret->rwstate = s->rwstate;
1930 ret->in_handshake = s->in_handshake;
1931 ret->handshake_func = s->handshake_func;
1932 ret->server = s->server;
1933 ret->new_session = s->new_session;
1934 ret->quiet_shutdown = s->quiet_shutdown;
1935 ret->shutdown=s->shutdown;
1936 ret->state=s->state; /* SSL_dup does not really work at any state, though */
1937 ret->rstate=s->rstate;
1938 ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */
1939 ret->hit=s->hit;
1940 ret->purpose=s->purpose;
1941 ret->trust=s->trust;
1731 1942
1732 /* dup the cipher_list and cipher_list_by_id stacks */ 1943 /* dup the cipher_list and cipher_list_by_id stacks */
1733 if (s->cipher_list != NULL) 1944 if (s->cipher_list != NULL)
@@ -1756,11 +1967,6 @@ SSL *SSL_dup(SSL *s)
1756 } 1967 }
1757 } 1968 }
1758 1969
1759 ret->shutdown=s->shutdown;
1760 ret->state=s->state;
1761 ret->handshake_func=s->handshake_func;
1762 ret->server=s->server;
1763
1764 if (0) 1970 if (0)
1765 { 1971 {
1766err: 1972err:
@@ -1913,7 +2119,7 @@ SSL_CTX *SSL_get_SSL_CTX(SSL *ssl)
1913 return(ssl->ctx); 2119 return(ssl->ctx);
1914 } 2120 }
1915 2121
1916#ifndef NO_STDIO 2122#ifndef OPENSSL_NO_STDIO
1917int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) 2123int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
1918 { 2124 {
1919 return(X509_STORE_set_default_paths(ctx->cert_store)); 2125 return(X509_STORE_set_default_paths(ctx->cert_store));
@@ -1926,14 +2132,15 @@ int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
1926 } 2132 }
1927#endif 2133#endif
1928 2134
1929void SSL_set_info_callback(SSL *ssl,void (*cb)()) 2135void SSL_set_info_callback(SSL *ssl,
2136 void (*cb)(const SSL *ssl,int type,int val))
1930 { 2137 {
1931 ssl->info_callback=cb; 2138 ssl->info_callback=cb;
1932 } 2139 }
1933 2140
1934void (*SSL_get_info_callback(SSL *ssl))(void) 2141void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val)
1935 { 2142 {
1936 return((void (*)())ssl->info_callback); 2143 return ssl->info_callback;
1937 } 2144 }
1938 2145
1939int SSL_state(SSL *ssl) 2146int SSL_state(SSL *ssl)
@@ -1954,9 +2161,8 @@ long SSL_get_verify_result(SSL *ssl)
1954int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, 2161int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1955 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) 2162 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1956 { 2163 {
1957 ssl_meth_num++; 2164 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, argl, argp,
1958 return(CRYPTO_get_ex_new_index(ssl_meth_num-1, 2165 new_func, dup_func, free_func);
1959 &ssl_meth,argl,argp,new_func,dup_func,free_func));
1960 } 2166 }
1961 2167
1962int SSL_set_ex_data(SSL *s,int idx,void *arg) 2168int SSL_set_ex_data(SSL *s,int idx,void *arg)
@@ -1972,9 +2178,8 @@ void *SSL_get_ex_data(SSL *s,int idx)
1972int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, 2178int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
1973 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) 2179 CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
1974 { 2180 {
1975 ssl_ctx_meth_num++; 2181 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, argl, argp,
1976 return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1, 2182 new_func, dup_func, free_func);
1977 &ssl_ctx_meth,argl,argp,new_func,dup_func,free_func));
1978 } 2183 }
1979 2184
1980int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg) 2185int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg)
@@ -2015,7 +2220,7 @@ int SSL_want(SSL *s)
2015 * \param cb the callback 2220 * \param cb the callback
2016 */ 2221 */
2017 2222
2018#ifndef NO_RSA 2223#ifndef OPENSSL_NO_RSA
2019void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, 2224void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl,
2020 int is_export, 2225 int is_export,
2021 int keylength)) 2226 int keylength))
@@ -2052,21 +2257,33 @@ RSA *cb(SSL *ssl,int is_export,int keylength)
2052 * \param dh the callback 2257 * \param dh the callback
2053 */ 2258 */
2054 2259
2055#ifndef NO_DH 2260#ifndef OPENSSL_NO_DH
2056void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, 2261void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export,
2057 int keylength)) 2262 int keylength))
2058 { 2263 {
2059 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); 2264 SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2060 } 2265 }
2061 2266
2062void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, 2267void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export,
2063 int keylength)) 2268 int keylength))
2064 { 2269 {
2065 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); 2270 SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh);
2066 } 2271 }
2067#endif 2272#endif
2068 2273
2069#if defined(_WINDLL) && defined(WIN16) 2274
2275void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))
2276 {
2277 SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb);
2278 }
2279void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))
2280 {
2281 SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb);
2282 }
2283
2284
2285
2286#if defined(_WINDLL) && defined(OPENSSL_SYS_WIN16)
2070#include "../crypto/bio/bss_file.c" 2287#include "../crypto/bio/bss_file.c"
2071#endif 2288#endif
2072 2289
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 516d3cc5ae..5208c4c42a 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -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
@@ -116,7 +116,7 @@
116#include <string.h> 116#include <string.h>
117#include <errno.h> 117#include <errno.h>
118 118
119#include "openssl/e_os.h" 119#include <e_os.h>
120 120
121#include <openssl/buffer.h> 121#include <openssl/buffer.h>
122#include <openssl/comp.h> 122#include <openssl/comp.h>
@@ -127,6 +127,12 @@
127#include <openssl/x509.h> 127#include <openssl/x509.h>
128#include <openssl/err.h> 128#include <openssl/err.h>
129#include <openssl/ssl.h> 129#include <openssl/ssl.h>
130#include <openssl/symhacks.h>
131
132#ifdef OPENSSL_BUILD_SHLIBSSL
133# undef OPENSSL_EXTERN
134# define OPENSSL_EXTERN OPENSSL_EXPORT
135#endif
130 136
131#define PKCS1_CHECK 137#define PKCS1_CHECK
132 138
@@ -221,48 +227,52 @@
221 * that the different entities within are mutually exclusive: 227 * that the different entities within are mutually exclusive:
222 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. 228 * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
223 */ 229 */
224#define SSL_MKEY_MASK 0x0000001FL 230#define SSL_MKEY_MASK 0x0000003FL
225#define SSL_kRSA 0x00000001L /* RSA key exchange */ 231#define SSL_kRSA 0x00000001L /* RSA key exchange */
226#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ 232#define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */
227#define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */ 233#define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */
228#define SSL_kFZA 0x00000008L 234#define SSL_kFZA 0x00000008L
229#define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */ 235#define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */
236#define SSL_kKRB5 0x00000020L /* Kerberos5 key exchange */
230#define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL)) 237#define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL))
231 238
232#define SSL_AUTH_MASK 0x000003e0L 239#define SSL_AUTH_MASK 0x00000FC0L
233#define SSL_aRSA 0x00000020L /* Authenticate with RSA */ 240#define SSL_aRSA 0x00000040L /* Authenticate with RSA */
234#define SSL_aDSS 0x00000040L /* Authenticate with DSS */ 241#define SSL_aDSS 0x00000080L /* Authenticate with DSS */
235#define SSL_DSS SSL_aDSS 242#define SSL_DSS SSL_aDSS
236#define SSL_aFZA 0x00000080L 243#define SSL_aFZA 0x00000100L
237#define SSL_aNULL 0x00000100L /* no Authenticate, ADH */ 244#define SSL_aNULL 0x00000200L /* no Authenticate, ADH */
238#define SSL_aDH 0x00000200L /* no Authenticate, ADH */ 245#define SSL_aDH 0x00000400L /* no Authenticate, ADH */
246#define SSL_aKRB5 0x00000800L /* Authenticate with KRB5 */
239 247
240#define SSL_NULL (SSL_eNULL) 248#define SSL_NULL (SSL_eNULL)
241#define SSL_ADH (SSL_kEDH|SSL_aNULL) 249#define SSL_ADH (SSL_kEDH|SSL_aNULL)
242#define SSL_RSA (SSL_kRSA|SSL_aRSA) 250#define SSL_RSA (SSL_kRSA|SSL_aRSA)
243#define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH) 251#define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH)
244#define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA) 252#define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA)
245 253#define SSL_KRB5 (SSL_kKRB5|SSL_aKRB5)
246#define SSL_ENC_MASK 0x0001Fc00L 254
247#define SSL_DES 0x00000400L 255#define SSL_ENC_MASK 0x0087F000L
248#define SSL_3DES 0x00000800L 256#define SSL_DES 0x00001000L
249#define SSL_RC4 0x00001000L 257#define SSL_3DES 0x00002000L
250#define SSL_RC2 0x00002000L 258#define SSL_RC4 0x00004000L
251#define SSL_IDEA 0x00004000L 259#define SSL_RC2 0x00008000L
252#define SSL_eFZA 0x00008000L 260#define SSL_IDEA 0x00010000L
253#define SSL_eNULL 0x00010000L 261#define SSL_eFZA 0x00020000L
254 262#define SSL_eNULL 0x00040000L
255#define SSL_MAC_MASK 0x00060000L 263#define SSL_AES 0x00800000L
256#define SSL_MD5 0x00020000L 264
257#define SSL_SHA1 0x00040000L 265#define SSL_MAC_MASK 0x00180000L
266#define SSL_MD5 0x00080000L
267#define SSL_SHA1 0x00100000L
258#define SSL_SHA (SSL_SHA1) 268#define SSL_SHA (SSL_SHA1)
259 269
260#define SSL_SSL_MASK 0x00180000L 270#define SSL_SSL_MASK 0x00600000L
261#define SSL_SSLV2 0x00080000L 271#define SSL_SSLV2 0x00200000L
262#define SSL_SSLV3 0x00100000L 272#define SSL_SSLV3 0x00400000L
263#define SSL_TLSV1 SSL_SSLV3 /* for now */ 273#define SSL_TLSV1 SSL_SSLV3 /* for now */
264 274
265/* we have used 001fffff - 11 bits left to go */ 275/* we have used 007fffff - 9 bits left to go */
266 276
267/* 277/*
268 * Export and cipher strength information. For each cipher we have to decide 278 * Export and cipher strength information. For each cipher we have to decide
@@ -367,11 +377,11 @@ typedef struct cert_st
367 int valid; 377 int valid;
368 unsigned long mask; 378 unsigned long mask;
369 unsigned long export_mask; 379 unsigned long export_mask;
370#ifndef NO_RSA 380#ifndef OPENSSL_NO_RSA
371 RSA *rsa_tmp; 381 RSA *rsa_tmp;
372 RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize); 382 RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize);
373#endif 383#endif
374#ifndef NO_DH 384#ifndef OPENSSL_NO_DH
375 DH *dh_tmp; 385 DH *dh_tmp;
376 DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize); 386 DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize);
377#endif 387#endif
@@ -394,10 +404,10 @@ typedef struct sess_cert_st
394 /* Obviously we don't have the private keys of these, 404 /* Obviously we don't have the private keys of these,
395 * so maybe we shouldn't even use the CERT_PKEY type here. */ 405 * so maybe we shouldn't even use the CERT_PKEY type here. */
396 406
397#ifndef NO_RSA 407#ifndef OPENSSL_NO_RSA
398 RSA *peer_rsa_tmp; /* not used for SSL 2 */ 408 RSA *peer_rsa_tmp; /* not used for SSL 2 */
399#endif 409#endif
400#ifndef NO_DH 410#ifndef OPENSSL_NO_DH
401 DH *peer_dh_tmp; /* not used for SSL 2 */ 411 DH *peer_dh_tmp; /* not used for SSL 2 */
402#endif 412#endif
403 413
@@ -454,9 +464,9 @@ OPENSSL_EXTERN SSL3_ENC_METHOD ssl3_undef_enc_method;
454OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[]; 464OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[];
455OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[]; 465OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[];
456 466
457#ifdef VMS 467#ifdef OPENSSL_SYS_VMS
458#undef SSL_COMP_get_compression_methods 468#undef SSL_COMP_get_compression_methods
459#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods 469#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
460#endif 470#endif
461 471
462 472
@@ -520,8 +530,8 @@ int ssl2_peek(SSL *s, void *buf, int len);
520int ssl2_write(SSL *s, const void *buf, int len); 530int ssl2_write(SSL *s, const void *buf, int len);
521int ssl2_shutdown(SSL *s); 531int ssl2_shutdown(SSL *s);
522void ssl2_clear(SSL *s); 532void ssl2_clear(SSL *s);
523long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg); 533long ssl2_ctrl(SSL *s,int cmd, long larg, void *parg);
524long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 534long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
525long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)()); 535long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)());
526long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); 536long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
527int ssl2_pending(SSL *s); 537int ssl2_pending(SSL *s);
@@ -556,8 +566,8 @@ void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
556int ssl3_enc(SSL *s, int send_data); 566int ssl3_enc(SSL *s, int send_data);
557int ssl3_mac(SSL *ssl, unsigned char *md, int send_data); 567int ssl3_mac(SSL *ssl, unsigned char *md, int send_data);
558unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); 568unsigned long ssl3_output_cert_chain(SSL *s, X509 *x);
559SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *have, 569SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *clnt,
560 STACK_OF(SSL_CIPHER) *pref); 570 STACK_OF(SSL_CIPHER) *srvr);
561int ssl3_setup_buffers(SSL *s); 571int ssl3_setup_buffers(SSL *s);
562int ssl3_new(SSL *s); 572int ssl3_new(SSL *s);
563void ssl3_free(SSL *s); 573void ssl3_free(SSL *s);
@@ -568,8 +578,8 @@ int ssl3_peek(SSL *s, void *buf, int len);
568int ssl3_write(SSL *s, const void *buf, int len); 578int ssl3_write(SSL *s, const void *buf, int len);
569int ssl3_shutdown(SSL *s); 579int ssl3_shutdown(SSL *s);
570void ssl3_clear(SSL *s); 580void ssl3_clear(SSL *s);
571long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg); 581long ssl3_ctrl(SSL *s,int cmd, long larg, void *parg);
572long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); 582long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
573long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)()); 583long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)());
574long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); 584long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)());
575int ssl3_pending(SSL *s); 585int ssl3_pending(SSL *s);
@@ -582,7 +592,7 @@ int ssl23_write_bytes(SSL *s);
582int tls1_new(SSL *s); 592int tls1_new(SSL *s);
583void tls1_free(SSL *s); 593void tls1_free(SSL *s);
584void tls1_clear(SSL *s); 594void tls1_clear(SSL *s);
585long tls1_ctrl(SSL *s,int cmd, long larg, char *parg); 595long tls1_ctrl(SSL *s,int cmd, long larg, void *parg);
586long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)()); 596long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)());
587SSL_METHOD *tlsv1_base_method(void ); 597SSL_METHOD *tlsv1_base_method(void );
588 598
diff --git a/src/lib/libssl/ssl_rsa.c b/src/lib/libssl/ssl_rsa.c
index 6ec7a5cdb1..1cf8e20934 100644
--- a/src/lib/libssl/ssl_rsa.c
+++ b/src/lib/libssl/ssl_rsa.c
@@ -81,7 +81,7 @@ int SSL_use_certificate(SSL *ssl, X509 *x)
81 return(ssl_set_cert(ssl->cert,x)); 81 return(ssl_set_cert(ssl->cert,x));
82 } 82 }
83 83
84#ifndef NO_STDIO 84#ifndef OPENSSL_NO_STDIO
85int SSL_use_certificate_file(SSL *ssl, const char *file, int type) 85int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
86 { 86 {
87 int j; 87 int j;
@@ -148,7 +148,7 @@ int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len)
148 return(ret); 148 return(ret);
149 } 149 }
150 150
151#ifndef NO_RSA 151#ifndef OPENSSL_NO_RSA
152int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) 152int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
153 { 153 {
154 EVP_PKEY *pkey; 154 EVP_PKEY *pkey;
@@ -170,7 +170,7 @@ int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
170 return(0); 170 return(0);
171 } 171 }
172 172
173 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 173 RSA_up_ref(rsa);
174 EVP_PKEY_assign_RSA(pkey,rsa); 174 EVP_PKEY_assign_RSA(pkey,rsa);
175 175
176 ret=ssl_set_pkey(ssl->cert,pkey); 176 ret=ssl_set_pkey(ssl->cert,pkey);
@@ -198,7 +198,7 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
198 EVP_PKEY_free(pktmp); 198 EVP_PKEY_free(pktmp);
199 ERR_clear_error(); 199 ERR_clear_error();
200 200
201#ifndef NO_RSA 201#ifndef OPENSSL_NO_RSA
202 /* Don't check the public/private key, this is mostly 202 /* Don't check the public/private key, this is mostly
203 * for smart cards. */ 203 * for smart cards. */
204 if ((pkey->type == EVP_PKEY_RSA) && 204 if ((pkey->type == EVP_PKEY_RSA) &&
@@ -251,8 +251,8 @@ static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
251 return(1); 251 return(1);
252 } 252 }
253 253
254#ifndef NO_RSA 254#ifndef OPENSSL_NO_RSA
255#ifndef NO_STDIO 255#ifndef OPENSSL_NO_STDIO
256int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) 256int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
257 { 257 {
258 int j,ret=0; 258 int j,ret=0;
@@ -303,7 +303,7 @@ end:
303int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len) 303int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len)
304 { 304 {
305 int ret; 305 int ret;
306 unsigned char *p; 306 const unsigned char *p;
307 RSA *rsa; 307 RSA *rsa;
308 308
309 p=d; 309 p=d;
@@ -317,7 +317,7 @@ int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len)
317 RSA_free(rsa); 317 RSA_free(rsa);
318 return(ret); 318 return(ret);
319 } 319 }
320#endif /* !NO_RSA */ 320#endif /* !OPENSSL_NO_RSA */
321 321
322int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) 322int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
323 { 323 {
@@ -337,7 +337,7 @@ int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
337 return(ret); 337 return(ret);
338 } 338 }
339 339
340#ifndef NO_STDIO 340#ifndef OPENSSL_NO_STDIO
341int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) 341int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type)
342 { 342 {
343 int j,ret=0; 343 int j,ret=0;
@@ -438,7 +438,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
438 EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey); 438 EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey);
439 ERR_clear_error(); 439 ERR_clear_error();
440 440
441#ifndef NO_RSA 441#ifndef OPENSSL_NO_RSA
442 /* Don't check the public/private key, this is mostly 442 /* Don't check the public/private key, this is mostly
443 * for smart cards. */ 443 * for smart cards. */
444 if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) && 444 if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) &&
@@ -471,7 +471,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
471 } 471 }
472 else 472 else
473 ok=1; 473 ok=1;
474 } /* NO_RSA */ 474 } /* OPENSSL_NO_RSA */
475 } 475 }
476 else 476 else
477 ok=1; 477 ok=1;
@@ -493,7 +493,7 @@ static int ssl_set_cert(CERT *c, X509 *x)
493 return(1); 493 return(1);
494 } 494 }
495 495
496#ifndef NO_STDIO 496#ifndef OPENSSL_NO_STDIO
497int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) 497int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
498 { 498 {
499 int j; 499 int j;
@@ -560,7 +560,7 @@ int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d)
560 return(ret); 560 return(ret);
561 } 561 }
562 562
563#ifndef NO_RSA 563#ifndef OPENSSL_NO_RSA
564int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) 564int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
565 { 565 {
566 int ret; 566 int ret;
@@ -582,7 +582,7 @@ int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
582 return(0); 582 return(0);
583 } 583 }
584 584
585 CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); 585 RSA_up_ref(rsa);
586 EVP_PKEY_assign_RSA(pkey,rsa); 586 EVP_PKEY_assign_RSA(pkey,rsa);
587 587
588 ret=ssl_set_pkey(ctx->cert, pkey); 588 ret=ssl_set_pkey(ctx->cert, pkey);
@@ -590,7 +590,7 @@ int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
590 return(ret); 590 return(ret);
591 } 591 }
592 592
593#ifndef NO_STDIO 593#ifndef OPENSSL_NO_STDIO
594int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) 594int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type)
595 { 595 {
596 int j,ret=0; 596 int j,ret=0;
@@ -641,7 +641,7 @@ end:
641int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len) 641int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len)
642 { 642 {
643 int ret; 643 int ret;
644 unsigned char *p; 644 const unsigned char *p;
645 RSA *rsa; 645 RSA *rsa;
646 646
647 p=d; 647 p=d;
@@ -655,7 +655,7 @@ int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len)
655 RSA_free(rsa); 655 RSA_free(rsa);
656 return(ret); 656 return(ret);
657 } 657 }
658#endif /* !NO_RSA */ 658#endif /* !OPENSSL_NO_RSA */
659 659
660int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) 660int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
661 { 661 {
@@ -672,7 +672,7 @@ int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
672 return(ssl_set_pkey(ctx->cert,pkey)); 672 return(ssl_set_pkey(ctx->cert,pkey));
673 } 673 }
674 674
675#ifndef NO_STDIO 675#ifndef OPENSSL_NO_STDIO
676int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) 676int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type)
677 { 677 {
678 int j,ret=0; 678 int j,ret=0;
@@ -735,7 +735,7 @@ int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, unsigned char *d,
735 } 735 }
736 736
737 737
738#ifndef NO_STDIO 738#ifndef OPENSSL_NO_STDIO
739/* Read a file that contains our certificate in "PEM" format, 739/* Read a file that contains our certificate in "PEM" format,
740 * possibly followed by a sequence of CA certificates that should be 740 * possibly followed by a sequence of CA certificates that should be
741 * sent to the peer in the Certificate message. 741 * sent to the peer in the Certificate message.
@@ -800,9 +800,9 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
800 * by SSL_CTX_use_certificate). */ 800 * by SSL_CTX_use_certificate). */
801 } 801 }
802 /* When the while loop ends, it's usually just EOF. */ 802 /* When the while loop ends, it's usually just EOF. */
803 err = ERR_peek_error(); 803 err = ERR_peek_last_error();
804 if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE) 804 if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE)
805 (void) ERR_get_error(); 805 (void)ERR_get_error();
806 else 806 else
807 ret = 0; /* some real error */ 807 ret = 0; /* some real error */
808 } 808 }
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 7064262def..6424f775e2 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -64,8 +64,6 @@
64static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); 64static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s);
65static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s); 65static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s);
66static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck); 66static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck);
67static int ssl_session_num=0;
68static STACK_OF(CRYPTO_EX_DATA_FUNCS) *ssl_session_meth=NULL;
69 67
70SSL_SESSION *SSL_get_session(SSL *ssl) 68SSL_SESSION *SSL_get_session(SSL *ssl)
71/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */ 69/* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */
@@ -91,10 +89,8 @@ SSL_SESSION *SSL_get1_session(SSL *ssl)
91int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 89int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
92 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 90 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
93 { 91 {
94 ssl_session_num++; 92 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, argl, argp,
95 return(CRYPTO_get_ex_new_index(ssl_session_num-1, 93 new_func, dup_func, free_func);
96 &ssl_session_meth,
97 argl,argp,new_func,dup_func,free_func));
98 } 94 }
99 95
100int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg) 96int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg)
@@ -126,15 +122,49 @@ SSL_SESSION *SSL_SESSION_new(void)
126 ss->prev=NULL; 122 ss->prev=NULL;
127 ss->next=NULL; 123 ss->next=NULL;
128 ss->compress_meth=0; 124 ss->compress_meth=0;
129 CRYPTO_new_ex_data(ssl_session_meth,ss,&ss->ex_data); 125 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
130 return(ss); 126 return(ss);
131 } 127 }
132 128
129/* Even with SSLv2, we have 16 bytes (128 bits) of session ID space. SSLv3/TLSv1
130 * has 32 bytes (256 bits). As such, filling the ID with random gunk repeatedly
131 * until we have no conflict is going to complete in one iteration pretty much
132 * "most" of the time (btw: understatement). So, if it takes us 10 iterations
133 * and we still can't avoid a conflict - well that's a reasonable point to call
134 * it quits. Either the RAND code is broken or someone is trying to open roughly
135 * very close to 2^128 (or 2^256) SSL sessions to our server. How you might
136 * store that many sessions is perhaps a more interesting question ... */
137
138#define MAX_SESS_ID_ATTEMPTS 10
139static int def_generate_session_id(const SSL *ssl, unsigned char *id,
140 unsigned int *id_len)
141{
142 unsigned int retry = 0;
143 do
144 RAND_pseudo_bytes(id, *id_len);
145 while(SSL_has_matching_session_id(ssl, id, *id_len) &&
146 (++retry < MAX_SESS_ID_ATTEMPTS));
147 if(retry < MAX_SESS_ID_ATTEMPTS)
148 return 1;
149 /* else - woops a session_id match */
150 /* XXX We should also check the external cache --
151 * but the probability of a collision is negligible, and
152 * we could not prevent the concurrent creation of sessions
153 * with identical IDs since we currently don't have means
154 * to atomically check whether a session ID already exists
155 * and make a reservation for it if it does not
156 * (this problem applies to the internal cache as well).
157 */
158 return 0;
159}
160
133int ssl_get_new_session(SSL *s, int session) 161int ssl_get_new_session(SSL *s, int session)
134 { 162 {
135 /* This gets used by clients and servers. */ 163 /* This gets used by clients and servers. */
136 164
165 unsigned int tmp;
137 SSL_SESSION *ss=NULL; 166 SSL_SESSION *ss=NULL;
167 GEN_SESSION_CB cb = def_generate_session_id;
138 168
139 if ((ss=SSL_SESSION_new()) == NULL) return(0); 169 if ((ss=SSL_SESSION_new()) == NULL) return(0);
140 170
@@ -173,25 +203,46 @@ int ssl_get_new_session(SSL *s, int session)
173 SSL_SESSION_free(ss); 203 SSL_SESSION_free(ss);
174 return(0); 204 return(0);
175 } 205 }
176 206 /* Choose which callback will set the session ID */
177 for (;;) 207 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
208 if(s->generate_session_id)
209 cb = s->generate_session_id;
210 else if(s->ctx->generate_session_id)
211 cb = s->ctx->generate_session_id;
212 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
213 /* Choose a session ID */
214 tmp = ss->session_id_length;
215 if(!cb(s, ss->session_id, &tmp))
178 { 216 {
179 SSL_SESSION *r; 217 /* The callback failed */
180 218 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
181 RAND_pseudo_bytes(ss->session_id,ss->session_id_length); 219 SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);
182 CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); 220 SSL_SESSION_free(ss);
183 r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, ss); 221 return(0);
184 CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); 222 }
185 if (r == NULL) break; 223 /* Don't allow the callback to set the session length to zero.
186 /* else - woops a session_id match */ 224 * nor set it higher than it was. */
187 /* XXX We should also check the external cache -- 225 if(!tmp || (tmp > ss->session_id_length))
188 * but the probability of a collision is negligible, and 226 {
189 * we could not prevent the concurrent creation of sessions 227 /* The callback set an illegal length */
190 * with identical IDs since we currently don't have means 228 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
191 * to atomically check whether a session ID already exists 229 SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);
192 * and make a reservation for it if it does not 230 SSL_SESSION_free(ss);
193 * (this problem applies to the internal cache as well). 231 return(0);
194 */ 232 }
233 /* If the session length was shrunk and we're SSLv2, pad it */
234 if((tmp < ss->session_id_length) && (s->version == SSL2_VERSION))
235 memset(ss->session_id + tmp, 0, ss->session_id_length - tmp);
236 else
237 ss->session_id_length = tmp;
238 /* Finally, check for a conflict */
239 if(SSL_has_matching_session_id(s, ss->session_id,
240 ss->session_id_length))
241 {
242 SSLerr(SSL_F_SSL_GET_NEW_SESSION,
243 SSL_R_SSL_SESSION_ID_CONFLICT);
244 SSL_SESSION_free(ss);
245 return(0);
195 } 246 }
196 } 247 }
197 else 248 else
@@ -423,10 +474,10 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
423 if ((c != NULL) && (c->session_id_length != 0)) 474 if ((c != NULL) && (c->session_id_length != 0))
424 { 475 {
425 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 476 if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
426 r=(SSL_SESSION *)lh_delete(ctx->sessions,c); 477 if ((r = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c)
427 if (r != NULL)
428 { 478 {
429 ret=1; 479 ret=1;
480 r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
430 SSL_SESSION_list_remove(ctx,c); 481 SSL_SESSION_list_remove(ctx,c);
431 } 482 }
432 483
@@ -465,7 +516,7 @@ void SSL_SESSION_free(SSL_SESSION *ss)
465 } 516 }
466#endif 517#endif
467 518
468 CRYPTO_free_ex_data(ssl_session_meth,ss,&ss->ex_data); 519 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
469 520
470 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); 521 memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH);
471 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); 522 memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH);
@@ -503,6 +554,17 @@ int SSL_set_session(SSL *s, SSL_SESSION *session)
503 session->timeout=s->ctx->session_timeout; 554 session->timeout=s->ctx->session_timeout;
504 } 555 }
505 556
557#ifndef OPENSSL_NO_KRB5
558 if (s->kssl_ctx && !s->kssl_ctx->client_princ &&
559 session->krb5_client_princ_len > 0)
560 {
561 s->kssl_ctx->client_princ = (char *)malloc(session->krb5_client_princ_len + 1);
562 memcpy(s->kssl_ctx->client_princ,session->krb5_client_princ,
563 session->krb5_client_princ_len);
564 s->kssl_ctx->client_princ[session->krb5_client_princ_len] = '\0';
565 }
566#endif /* OPENSSL_NO_KRB5 */
567
506 /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/ 568 /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/
507 CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION); 569 CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION);
508 if (s->session != NULL) 570 if (s->session != NULL)
@@ -594,6 +656,8 @@ static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p)
594 } 656 }
595 } 657 }
596 658
659static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION *, TIMEOUT_PARAM *)
660
597void SSL_CTX_flush_sessions(SSL_CTX *s, long t) 661void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
598 { 662 {
599 unsigned long i; 663 unsigned long i;
@@ -606,7 +670,7 @@ void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
606 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); 670 CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
607 i=tp.cache->down_load; 671 i=tp.cache->down_load;
608 tp.cache->down_load=0; 672 tp.cache->down_load=0;
609 lh_doall_arg(tp.cache,(void (*)())timeout,&tp); 673 lh_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), &tp);
610 tp.cache->down_load=i; 674 tp.cache->down_load=i;
611 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 675 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
612 } 676 }
diff --git a/src/lib/libssl/ssl_stat.c b/src/lib/libssl/ssl_stat.c
index 8e12461f3b..b16d253081 100644
--- a/src/lib/libssl/ssl_stat.c
+++ b/src/lib/libssl/ssl_stat.c
@@ -59,9 +59,9 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "ssl_locl.h" 60#include "ssl_locl.h"
61 61
62char *SSL_state_string_long(SSL *s) 62const char *SSL_state_string_long(const SSL *s)
63 { 63 {
64 char *str; 64 const char *str;
65 65
66 switch (s->state) 66 switch (s->state)
67 { 67 {
@@ -74,7 +74,7 @@ case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break;
74case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; 74case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break;
75case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; 75case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break;
76case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; 76case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break;
77#ifndef NO_SSL2 77#ifndef OPENSSL_NO_SSL2
78case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; 78case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break;
79case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; 79case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break;
80case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; 80case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break;
@@ -115,7 +115,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificat
115case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; 115case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break;
116#endif 116#endif
117 117
118#ifndef NO_SSL3 118#ifndef OPENSSL_NO_SSL3
119/* SSLv3 additions */ 119/* SSLv3 additions */
120case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; 120case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break;
121case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; 121case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break;
@@ -136,7 +136,7 @@ case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break;
136case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; 136case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break;
137case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; 137case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break;
138case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; 138case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break;
139case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify A"; break; 139case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break;
140 140
141case SSL3_ST_CW_CHANGE_A: 141case SSL3_ST_CW_CHANGE_A:
142case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; 142case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break;
@@ -145,7 +145,7 @@ case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break;
145case SSL3_ST_CW_FINISHED_A: 145case SSL3_ST_CW_FINISHED_A:
146case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; 146case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break;
147case SSL3_ST_CW_FINISHED_B: 147case SSL3_ST_CW_FINISHED_B:
148case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished A"; break; 148case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break;
149case SSL3_ST_CR_CHANGE_A: 149case SSL3_ST_CR_CHANGE_A:
150case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; 150case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break;
151case SSL3_ST_CR_CHANGE_B: 151case SSL3_ST_CR_CHANGE_B:
@@ -182,7 +182,7 @@ case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break;
182case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; 182case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break;
183#endif 183#endif
184 184
185#if !defined(NO_SSL2) && !defined(NO_SSL3) 185#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
186/* SSLv2/v3 compatibility states */ 186/* SSLv2/v3 compatibility states */
187/* client */ 187/* client */
188case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; 188case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break;
@@ -199,9 +199,9 @@ default: str="unknown state"; break;
199 return(str); 199 return(str);
200 } 200 }
201 201
202char *SSL_rstate_string_long(SSL *s) 202const char *SSL_rstate_string_long(const SSL *s)
203 { 203 {
204 char *str; 204 const char *str;
205 205
206 switch (s->rstate) 206 switch (s->rstate)
207 { 207 {
@@ -213,9 +213,9 @@ char *SSL_rstate_string_long(SSL *s)
213 return(str); 213 return(str);
214 } 214 }
215 215
216char *SSL_state_string(SSL *s) 216const char *SSL_state_string(const SSL *s)
217 { 217 {
218 char *str; 218 const char *str;
219 219
220 switch (s->state) 220 switch (s->state)
221 { 221 {
@@ -223,7 +223,7 @@ case SSL_ST_BEFORE: str="PINIT "; break;
223case SSL_ST_ACCEPT: str="AINIT "; break; 223case SSL_ST_ACCEPT: str="AINIT "; break;
224case SSL_ST_CONNECT: str="CINIT "; break; 224case SSL_ST_CONNECT: str="CINIT "; break;
225case SSL_ST_OK: str="SSLOK "; break; 225case SSL_ST_OK: str="SSLOK "; break;
226#ifndef NO_SSL2 226#ifndef OPENSSL_NO_SSL2
227case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; 227case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break;
228case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; 228case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break;
229case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; 229case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break;
@@ -264,7 +264,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break;
264case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; 264case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break;
265#endif 265#endif
266 266
267#ifndef NO_SSL3 267#ifndef OPENSSL_NO_SSL3
268/* SSLv3 additions */ 268/* SSLv3 additions */
269case SSL3_ST_SW_FLUSH: 269case SSL3_ST_SW_FLUSH:
270case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; 270case SSL3_ST_CW_FLUSH: str="3FLUSH"; break;
@@ -330,7 +330,7 @@ case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break;
330case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; 330case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break;
331#endif 331#endif
332 332
333#if !defined(NO_SSL2) && !defined(NO_SSL3) 333#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
334/* SSLv2/v3 compatibility states */ 334/* SSLv2/v3 compatibility states */
335/* client */ 335/* client */
336case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; 336case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break;
@@ -347,7 +347,7 @@ default: str="UNKWN "; break;
347 return(str); 347 return(str);
348 } 348 }
349 349
350char *SSL_alert_type_string_long(int value) 350const char *SSL_alert_type_string_long(int value)
351 { 351 {
352 value>>=8; 352 value>>=8;
353 if (value == SSL3_AL_WARNING) 353 if (value == SSL3_AL_WARNING)
@@ -358,7 +358,7 @@ char *SSL_alert_type_string_long(int value)
358 return("unknown"); 358 return("unknown");
359 } 359 }
360 360
361char *SSL_alert_type_string(int value) 361const char *SSL_alert_type_string(int value)
362 { 362 {
363 value>>=8; 363 value>>=8;
364 if (value == SSL3_AL_WARNING) 364 if (value == SSL3_AL_WARNING)
@@ -369,9 +369,9 @@ char *SSL_alert_type_string(int value)
369 return("U"); 369 return("U");
370 } 370 }
371 371
372char *SSL_alert_desc_string(int value) 372const char *SSL_alert_desc_string(int value)
373 { 373 {
374 char *str; 374 const char *str;
375 375
376 switch (value & 0xff) 376 switch (value & 0xff)
377 { 377 {
@@ -387,14 +387,26 @@ char *SSL_alert_desc_string(int value)
387 case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; 387 case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break;
388 case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; 388 case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break;
389 case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; 389 case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break;
390 case TLS1_AD_DECRYPTION_FAILED: str="DC"; break;
391 case TLS1_AD_RECORD_OVERFLOW: str="RO"; break;
392 case TLS1_AD_UNKNOWN_CA: str="CA"; break;
393 case TLS1_AD_ACCESS_DENIED: str="AD"; break;
394 case TLS1_AD_DECODE_ERROR: str="DE"; break;
395 case TLS1_AD_DECRYPT_ERROR: str="CY"; break;
396 case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break;
397 case TLS1_AD_PROTOCOL_VERSION: str="PV"; break;
398 case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break;
399 case TLS1_AD_INTERNAL_ERROR: str="IE"; break;
400 case TLS1_AD_USER_CANCELLED: str="US"; break;
401 case TLS1_AD_NO_RENEGOTIATION: str="NR"; break;
390 default: str="UK"; break; 402 default: str="UK"; break;
391 } 403 }
392 return(str); 404 return(str);
393 } 405 }
394 406
395char *SSL_alert_desc_string_long(int value) 407const char *SSL_alert_desc_string_long(int value)
396 { 408 {
397 char *str; 409 const char *str;
398 410
399 switch (value & 0xff) 411 switch (value & 0xff)
400 { 412 {
@@ -434,14 +446,50 @@ char *SSL_alert_desc_string_long(int value)
434 case SSL3_AD_ILLEGAL_PARAMETER: 446 case SSL3_AD_ILLEGAL_PARAMETER:
435 str="illegal parameter"; 447 str="illegal parameter";
436 break; 448 break;
449 case TLS1_AD_DECRYPTION_FAILED:
450 str="decryption failed";
451 break;
452 case TLS1_AD_RECORD_OVERFLOW:
453 str="record overflow";
454 break;
455 case TLS1_AD_UNKNOWN_CA:
456 str="unknown CA";
457 break;
458 case TLS1_AD_ACCESS_DENIED:
459 str="access denied";
460 break;
461 case TLS1_AD_DECODE_ERROR:
462 str="decode error";
463 break;
464 case TLS1_AD_DECRYPT_ERROR:
465 str="decrypt error";
466 break;
467 case TLS1_AD_EXPORT_RESTRICTION:
468 str="export restriction";
469 break;
470 case TLS1_AD_PROTOCOL_VERSION:
471 str="protocol version";
472 break;
473 case TLS1_AD_INSUFFICIENT_SECURITY:
474 str="insufficient security";
475 break;
476 case TLS1_AD_INTERNAL_ERROR:
477 str="internal error";
478 break;
479 case TLS1_AD_USER_CANCELLED:
480 str="user canceled";
481 break;
482 case TLS1_AD_NO_RENEGOTIATION:
483 str="no renegotiation";
484 break;
437 default: str="unknown"; break; 485 default: str="unknown"; break;
438 } 486 }
439 return(str); 487 return(str);
440 } 488 }
441 489
442char *SSL_rstate_string(SSL *s) 490const char *SSL_rstate_string(const SSL *s)
443 { 491 {
444 char *str; 492 const char *str;
445 493
446 switch (s->rstate) 494 switch (s->rstate)
447 { 495 {
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c
index 6e33eec3e4..40b76b1b26 100644
--- a/src/lib/libssl/ssl_txt.c
+++ b/src/lib/libssl/ssl_txt.c
@@ -60,7 +60,7 @@
60#include <openssl/buffer.h> 60#include <openssl/buffer.h>
61#include "ssl_locl.h" 61#include "ssl_locl.h"
62 62
63#ifndef NO_FP_API 63#ifndef OPENSSL_NO_FP_API
64int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x) 64int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x)
65 { 65 {
66 BIO *b; 66 BIO *b;
@@ -139,6 +139,18 @@ int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)
139 { 139 {
140 if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err; 140 if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err;
141 } 141 }
142#ifndef OPENSSL_NO_KRB5
143 if (BIO_puts(bp,"\n Krb5 Principal: ") <= 0) goto err;
144 if (x->krb5_client_princ_len == 0)
145 {
146 if (BIO_puts(bp,"None") <= 0) goto err;
147 }
148 else
149 for (i=0; i<x->krb5_client_princ_len; i++)
150 {
151 if (BIO_printf(bp,"%02X",x->krb5_client_princ[i]) <= 0) goto err;
152 }
153#endif /* OPENSSL_NO_KRB5 */
142 if (x->compress_meth != 0) 154 if (x->compress_meth != 0)
143 { 155 {
144 SSL_COMP *comp; 156 SSL_COMP *comp;
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c
index a0758e9261..b80525f3ba 100644
--- a/src/lib/libssl/t1_enc.c
+++ b/src/lib/libssl/t1_enc.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-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 <openssl/comp.h> 113#include <openssl/comp.h>
61#include <openssl/md5.h>
62#include <openssl/sha.h>
63#include <openssl/evp.h> 114#include <openssl/evp.h>
64#include <openssl/hmac.h> 115#include <openssl/hmac.h>
65#include "ssl_locl.h" 116#include "ssl_locl.h"
117#include <openssl/md5.h>
66 118
67static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, 119static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
68 int sec_len, unsigned char *seed, int seed_len, 120 int sec_len, unsigned char *seed, int seed_len,
@@ -77,16 +129,20 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
77 129
78 chunk=EVP_MD_size(md); 130 chunk=EVP_MD_size(md);
79 131
80 HMAC_Init(&ctx,sec,sec_len,md); 132 HMAC_CTX_init(&ctx);
133 HMAC_CTX_init(&ctx_tmp);
134 HMAC_Init_ex(&ctx,sec,sec_len,md, NULL);
135 HMAC_Init_ex(&ctx_tmp,sec,sec_len,md, NULL);
81 HMAC_Update(&ctx,seed,seed_len); 136 HMAC_Update(&ctx,seed,seed_len);
82 HMAC_Final(&ctx,A1,&A1_len); 137 HMAC_Final(&ctx,A1,&A1_len);
83 138
84 n=0; 139 n=0;
85 for (;;) 140 for (;;)
86 { 141 {
87 HMAC_Init(&ctx,NULL,0,NULL); /* re-init */ 142 HMAC_Init_ex(&ctx,NULL,0,NULL,NULL); /* re-init */
143 HMAC_Init_ex(&ctx_tmp,NULL,0,NULL,NULL); /* re-init */
88 HMAC_Update(&ctx,A1,A1_len); 144 HMAC_Update(&ctx,A1,A1_len);
89 memcpy(&ctx_tmp,&ctx,sizeof(ctx)); /* Copy for A2 */ /* not needed for last one */ 145 HMAC_Update(&ctx_tmp,A1,A1_len);
90 HMAC_Update(&ctx,seed,seed_len); 146 HMAC_Update(&ctx,seed,seed_len);
91 147
92 if (olen > chunk) 148 if (olen > chunk)
@@ -103,8 +159,8 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
103 break; 159 break;
104 } 160 }
105 } 161 }
106 HMAC_cleanup(&ctx); 162 HMAC_CTX_cleanup(&ctx);
107 HMAC_cleanup(&ctx_tmp); 163 HMAC_CTX_cleanup(&ctx_tmp);
108 memset(A1,0,sizeof(A1)); 164 memset(A1,0,sizeof(A1));
109 } 165 }
110 166
@@ -148,6 +204,17 @@ static void tls1_generate_key_block(SSL *s, unsigned char *km,
148 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf), 204 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf),
149 s->session->master_key,s->session->master_key_length, 205 s->session->master_key,s->session->master_key_length,
150 km,tmp,num); 206 km,tmp,num);
207#ifdef KSSL_DEBUG
208 printf("tls1_generate_key_block() ==> %d byte master_key =\n\t",
209 s->session->master_key_length);
210 {
211 int i;
212 for (i=0; i < s->session->master_key_length; i++)
213 {
214 printf("%02X", s->session->master_key[i]);
215 }
216 printf("\n"); }
217#endif /* KSSL_DEBUG */
151 } 218 }
152 219
153int tls1_change_cipher_state(SSL *s, int which) 220int tls1_change_cipher_state(SSL *s, int which)
@@ -166,19 +233,35 @@ int tls1_change_cipher_state(SSL *s, int which)
166 const EVP_CIPHER *c; 233 const EVP_CIPHER *c;
167 const SSL_COMP *comp; 234 const SSL_COMP *comp;
168 const EVP_MD *m; 235 const EVP_MD *m;
169 int _exp,n,i,j,k,exp_label_len,cl; 236 int is_export,n,i,j,k,exp_label_len,cl;
237 int reuse_dd = 0;
170 238
171 _exp=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher); 239 is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
172 c=s->s3->tmp.new_sym_enc; 240 c=s->s3->tmp.new_sym_enc;
173 m=s->s3->tmp.new_hash; 241 m=s->s3->tmp.new_hash;
174 comp=s->s3->tmp.new_compression; 242 comp=s->s3->tmp.new_compression;
175 key_block=s->s3->tmp.key_block; 243 key_block=s->s3->tmp.key_block;
176 244
245#ifdef KSSL_DEBUG
246 printf("tls1_change_cipher_state(which= %d) w/\n", which);
247 printf("\talg= %ld, comp= %p\n", s->s3->tmp.new_cipher->algorithms,
248 comp);
249 printf("\tevp_cipher == %p ==? &d_cbc_ede_cipher3\n", c);
250 printf("\tevp_cipher: nid, blksz= %d, %d, keylen=%d, ivlen=%d\n",
251 c->nid,c->block_size,c->key_len,c->iv_len);
252 printf("\tkey_block: len= %d, data= ", s->s3->tmp.key_block_length);
253 {
254 int i;
255 for (i=0; i<s->s3->tmp.key_block_length; i++)
256 printf("%02x", key_block[i]); printf("\n");
257 }
258#endif /* KSSL_DEBUG */
259
177 if (which & SSL3_CC_READ) 260 if (which & SSL3_CC_READ)
178 { 261 {
179 if ((s->enc_read_ctx == NULL) && 262 if (s->enc_read_ctx != NULL)
180 ((s->enc_read_ctx=(EVP_CIPHER_CTX *) 263 reuse_dd = 1;
181 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 264 else if ((s->enc_read_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
182 goto err; 265 goto err;
183 dd= s->enc_read_ctx; 266 dd= s->enc_read_ctx;
184 s->read_hash=m; 267 s->read_hash=m;
@@ -206,6 +289,10 @@ int tls1_change_cipher_state(SSL *s, int which)
206 } 289 }
207 else 290 else
208 { 291 {
292 if (s->enc_write_ctx != NULL)
293 reuse_dd = 1;
294 else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
295 goto err;
209 if ((s->enc_write_ctx == NULL) && 296 if ((s->enc_write_ctx == NULL) &&
210 ((s->enc_write_ctx=(EVP_CIPHER_CTX *) 297 ((s->enc_write_ctx=(EVP_CIPHER_CTX *)
211 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) 298 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
@@ -230,13 +317,15 @@ int tls1_change_cipher_state(SSL *s, int which)
230 mac_secret= &(s->s3->write_mac_secret[0]); 317 mac_secret= &(s->s3->write_mac_secret[0]);
231 } 318 }
232 319
320 if (reuse_dd)
321 EVP_CIPHER_CTX_cleanup(dd);
233 EVP_CIPHER_CTX_init(dd); 322 EVP_CIPHER_CTX_init(dd);
234 323
235 p=s->s3->tmp.key_block; 324 p=s->s3->tmp.key_block;
236 i=EVP_MD_size(m); 325 i=EVP_MD_size(m);
237 cl=EVP_CIPHER_key_length(c); 326 cl=EVP_CIPHER_key_length(c);
238 j=_exp ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ? 327 j=is_export ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ?
239 cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl; 328 cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl;
240 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */ 329 /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */
241 k=EVP_CIPHER_iv_length(c); 330 k=EVP_CIPHER_iv_length(c);
242 er1= &(s->s3->client_random[0]); 331 er1= &(s->s3->client_random[0]);
@@ -264,7 +353,7 @@ int tls1_change_cipher_state(SSL *s, int which)
264 353
265 if (n > s->s3->tmp.key_block_length) 354 if (n > s->s3->tmp.key_block_length)
266 { 355 {
267 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,SSL_R_INTERNAL_ERROR); 356 SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_INTERNAL_ERROR);
268 goto err2; 357 goto err2;
269 } 358 }
270 359
@@ -273,7 +362,7 @@ int tls1_change_cipher_state(SSL *s, int which)
273printf("which = %04X\nmac key=",which); 362printf("which = %04X\nmac key=",which);
274{ int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); } 363{ int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); }
275#endif 364#endif
276 if (_exp) 365 if (is_export)
277 { 366 {
278 /* In here I set both the read and write key/iv to the 367 /* In here I set both the read and write key/iv to the
279 * same value since only the correct one will be used :-). 368 * same value since only the correct one will be used :-).
@@ -309,8 +398,18 @@ printf("which = %04X\nmac key=",which);
309 } 398 }
310 399
311 s->session->key_arg_length=0; 400 s->session->key_arg_length=0;
401#ifdef KSSL_DEBUG
402 {
403 int i;
404 printf("EVP_CipherInit_ex(dd,c,key=,iv=,which)\n");
405 printf("\tkey= "); for (i=0; i<c->key_len; i++) printf("%02x", key[i]);
406 printf("\n");
407 printf("\t iv= "); for (i=0; i<c->iv_len; i++) printf("%02x", iv[i]);
408 printf("\n");
409 }
410#endif /* KSSL_DEBUG */
312 411
313 EVP_CipherInit(dd,c,key,iv,(which & SSL3_CC_WRITE)); 412 EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE));
314#ifdef TLS_DEBUG 413#ifdef TLS_DEBUG
315printf("which = %04X\nkey=",which); 414printf("which = %04X\nkey=",which);
316{ int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); } 415{ int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); }
@@ -338,6 +437,10 @@ int tls1_setup_key_block(SSL *s)
338 int num; 437 int num;
339 SSL_COMP *comp; 438 SSL_COMP *comp;
340 439
440#ifdef KSSL_DEBUG
441 printf ("tls1_setup_key_block()\n");
442#endif /* KSSL_DEBUG */
443
341 if (s->s3->tmp.key_block_length != 0) 444 if (s->s3->tmp.key_block_length != 0)
342 return(1); 445 return(1);
343 446
@@ -380,6 +483,14 @@ printf("\nkey block\n");
380{ int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); } 483{ int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); }
381#endif 484#endif
382 485
486 /* enable vulnerability countermeasure for CBC ciphers with
487 * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */
488 s->s3->need_empty_fragments = 1;
489#ifndef NO_RC4
490 if ((s->session->cipher != NULL) && ((s->session->cipher->algorithms & SSL_ENC_MASK) == SSL_RC4))
491 s->s3->need_empty_fragments = 0;
492#endif
493
383 return(1); 494 return(1);
384err: 495err:
385 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE); 496 SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);
@@ -417,6 +528,10 @@ int tls1_enc(SSL *s, int send)
417 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx); 528 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx);
418 } 529 }
419 530
531#ifdef KSSL_DEBUG
532 printf("tls1_enc(%d)\n", send);
533#endif /* KSSL_DEBUG */
534
420 if ((s->session == NULL) || (ds == NULL) || 535 if ((s->session == NULL) || (ds == NULL) ||
421 (enc == NULL)) 536 (enc == NULL))
422 { 537 {
@@ -447,18 +562,45 @@ int tls1_enc(SSL *s, int send)
447 rec->length+=i; 562 rec->length+=i;
448 } 563 }
449 564
565#ifdef KSSL_DEBUG
566 {
567 unsigned long ui;
568 printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n",
569 ds,rec->data,rec->input,l);
570 printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n",
571 ds->buf_len, ds->cipher->key_len,
572 DES_KEY_SZ, DES_SCHEDULE_SZ,
573 ds->cipher->iv_len);
574 printf("\t\tIV: ");
575 for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]);
576 printf("\n");
577 printf("\trec->input=");
578 for (ui=0; ui<l; ui++) printf(" %02x", rec->input[ui]);
579 printf("\n");
580 }
581#endif /* KSSL_DEBUG */
582
450 if (!send) 583 if (!send)
451 { 584 {
452 if (l == 0 || l%bs != 0) 585 if (l == 0 || l%bs != 0)
453 { 586 {
454 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 587 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
455 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR); 588 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
456 return(0); 589 return 0;
457 } 590 }
458 } 591 }
459 592
460 EVP_Cipher(ds,rec->data,rec->input,l); 593 EVP_Cipher(ds,rec->data,rec->input,l);
461 594
595#ifdef KSSL_DEBUG
596 {
597 unsigned long i;
598 printf("\trec->data=");
599 for (i=0; i<l; i++)
600 printf(" %02x", rec->data[i]); printf("\n");
601 }
602#endif /* KSSL_DEBUG */
603
462 if ((bs != 1) && !send) 604 if ((bs != 1) && !send)
463 { 605 {
464 ii=i=rec->data[l-1]; /* padding_length */ 606 ii=i=rec->data[l-1]; /* padding_length */
@@ -476,17 +618,18 @@ int tls1_enc(SSL *s, int send)
476 * All of them must have value 'padding_length'. */ 618 * All of them must have value 'padding_length'. */
477 if (i > (int)rec->length) 619 if (i > (int)rec->length)
478 { 620 {
479 SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); 621 /* Incorrect padding. SSLerr() and ssl3_alert are done
480 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); 622 * by caller: we don't want to reveal whether this is
481 return(0); 623 * a decryption error or a MAC verification failure
624 * (see http://www.openssl.org/~bodo/tls-cbc.txt) */
625 return -1;
482 } 626 }
483 for (j=(int)(l-i); j<(int)l; j++) 627 for (j=(int)(l-i); j<(int)l; j++)
484 { 628 {
485 if (rec->data[j] != ii) 629 if (rec->data[j] != ii)
486 { 630 {
487 SSLerr(SSL_F_TLS1_ENC,SSL_R_DECRYPTION_FAILED); 631 /* Incorrect padding */
488 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); 632 return -1;
489 return(0);
490 } 633 }
491 } 634 }
492 rec->length-=i; 635 rec->length-=i;
@@ -500,8 +643,10 @@ int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in_ctx, unsigned char *out)
500 unsigned int ret; 643 unsigned int ret;
501 EVP_MD_CTX ctx; 644 EVP_MD_CTX ctx;
502 645
503 EVP_MD_CTX_copy(&ctx,in_ctx); 646 EVP_MD_CTX_init(&ctx);
504 EVP_DigestFinal(&ctx,out,&ret); 647 EVP_MD_CTX_copy_ex(&ctx,in_ctx);
648 EVP_DigestFinal_ex(&ctx,out,&ret);
649 EVP_MD_CTX_cleanup(&ctx);
505 return((int)ret); 650 return((int)ret);
506 } 651 }
507 652
@@ -517,17 +662,18 @@ int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
517 memcpy(q,str,slen); 662 memcpy(q,str,slen);
518 q+=slen; 663 q+=slen;
519 664
520 EVP_MD_CTX_copy(&ctx,in1_ctx); 665 EVP_MD_CTX_init(&ctx);
521 EVP_DigestFinal(&ctx,q,&i); 666 EVP_MD_CTX_copy_ex(&ctx,in1_ctx);
667 EVP_DigestFinal_ex(&ctx,q,&i);
522 q+=i; 668 q+=i;
523 EVP_MD_CTX_copy(&ctx,in2_ctx); 669 EVP_MD_CTX_copy_ex(&ctx,in2_ctx);
524 EVP_DigestFinal(&ctx,q,&i); 670 EVP_DigestFinal_ex(&ctx,q,&i);
525 q+=i; 671 q+=i;
526 672
527 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), 673 tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf),
528 s->session->master_key,s->session->master_key_length, 674 s->session->master_key,s->session->master_key_length,
529 out,buf2,12); 675 out,buf2,12);
530 memset(&ctx,0,sizeof(EVP_MD_CTX)); 676 EVP_MD_CTX_cleanup(&ctx);
531 677
532 return((int)12); 678 return((int)12);
533 } 679 }
@@ -566,11 +712,13 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
566 buf[4]=rec->length&0xff; 712 buf[4]=rec->length&0xff;
567 713
568 /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */ 714 /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */
569 HMAC_Init(&hmac,mac_sec,EVP_MD_size(hash),hash); 715 HMAC_CTX_init(&hmac);
716 HMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash,NULL);
570 HMAC_Update(&hmac,seq,8); 717 HMAC_Update(&hmac,seq,8);
571 HMAC_Update(&hmac,buf,5); 718 HMAC_Update(&hmac,buf,5);
572 HMAC_Update(&hmac,rec->input,rec->length); 719 HMAC_Update(&hmac,rec->input,rec->length);
573 HMAC_Final(&hmac,md,&md_size); 720 HMAC_Final(&hmac,md,&md_size);
721 HMAC_CTX_cleanup(&hmac);
574 722
575#ifdef TLS_DEBUG 723#ifdef TLS_DEBUG
576printf("sec="); 724printf("sec=");
@@ -601,6 +749,10 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
601 unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE]; 749 unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE];
602 unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH]; 750 unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH];
603 751
752#ifdef KSSL_DEBUG
753 printf ("tls1_generate_master_secret(%p,%p, %p, %d)\n", s,out, p,len);
754#endif /* KSSL_DEBUG */
755
604 /* Setup the stuff to munge */ 756 /* Setup the stuff to munge */
605 memcpy(buf,TLS_MD_MASTER_SECRET_CONST, 757 memcpy(buf,TLS_MD_MASTER_SECRET_CONST,
606 TLS_MD_MASTER_SECRET_CONST_SIZE); 758 TLS_MD_MASTER_SECRET_CONST_SIZE);
@@ -611,6 +763,9 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p,
611 tls1_PRF(s->ctx->md5,s->ctx->sha1, 763 tls1_PRF(s->ctx->md5,s->ctx->sha1,
612 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, 764 buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len,
613 s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); 765 s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE);
766#ifdef KSSL_DEBUG
767 printf ("tls1_generate_master_secret() complete\n");
768#endif /* KSSL_DEBUG */
614 return(SSL3_MASTER_SECRET_SIZE); 769 return(SSL3_MASTER_SECRET_SIZE);
615 } 770 }
616 771
diff --git a/src/lib/libssl/test/Makefile.ssl b/src/lib/libssl/test/Makefile.ssl
index 7384243cbd..a11e3dfcd7 100644
--- a/src/lib/libssl/test/Makefile.ssl
+++ b/src/lib/libssl/test/Makefile.ssl
@@ -5,14 +5,15 @@
5DIR= test 5DIR= test
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDES= -I../include 8INCLUDES= -I$(TOP) -I../include $(KRB5_INCLUDES)
9CFLAG= -g 9CFLAG= -g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP= /usr/local/ssl 12INSTALLTOP= /usr/local/ssl
13MAKEFILE= Makefile.ssl 13MAKEFILE= Makefile.ssl
14MAKE= make -f $(MAKEFILE) 14MAKE= make -f $(MAKEFILE)
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16PERL= perl 17PERL= perl
17 18
18PEX_LIBS= 19PEX_LIBS=
@@ -31,6 +32,7 @@ LIBCRYPTO= -L.. -lcrypto
31LIBSSL= -L.. -lssl 32LIBSSL= -L.. -lssl
32 33
33BNTEST= bntest 34BNTEST= bntest
35ECTEST= ectest
34EXPTEST= exptest 36EXPTEST= exptest
35IDEATEST= ideatest 37IDEATEST= ideatest
36SHATEST= shatest 38SHATEST= shatest
@@ -54,27 +56,33 @@ METHTEST= methtest
54SSLTEST= ssltest 56SSLTEST= ssltest
55RSATEST= rsa_test 57RSATEST= rsa_test
56ENGINETEST= enginetest 58ENGINETEST= enginetest
59EVPTEST= evp_test
57 60
58EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD4TEST) $(MD5TEST) $(HMACTEST) \ 61TESTS= alltests
62
63EXE= $(BNTEST) $(ECTEST) $(IDEATEST) $(MD2TEST) $(MD4TEST) $(MD5TEST) $(HMACTEST) \
59 $(RC2TEST) $(RC4TEST) $(RC5TEST) \ 64 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
60 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \ 65 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
61 $(RANDTEST) $(DHTEST) $(ENGINETEST) \ 66 $(RANDTEST) $(DHTEST) $(ENGINETEST) \
62 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) $(RSATEST) 67 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST) $(RSATEST) \
68 $(EVPTEST)
63 69
64# $(METHTEST) 70# $(METHTEST)
65 71
66OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD4TEST).o $(MD5TEST).o \ 72OBJ= $(BNTEST).o $(ECTEST).o $(IDEATEST).o $(MD2TEST).o $(MD4TEST).o $(MD5TEST).o \
67 $(HMACTEST).o \ 73 $(HMACTEST).o \
68 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \ 74 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
69 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \ 75 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
70 $(RANDTEST).o $(DHTEST).o $(ENGINETEST).o $(CASTTEST).o \ 76 $(RANDTEST).o $(DHTEST).o $(ENGINETEST).o $(CASTTEST).o \
71 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o $(RSATEST).o 77 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o $(RSATEST).o \
72SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \ 78 $(EVPTEST).o
79SRC= $(BNTEST).c $(ECTEST).c $(IDEATEST).c $(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \
73 $(HMACTEST).c \ 80 $(HMACTEST).c \
74 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \ 81 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
75 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \ 82 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
76 $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c $(CASTTEST).c \ 83 $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c $(CASTTEST).c \
77 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c $(RSATEST).c 84 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c $(RSATEST).c \
85 $(EVPTEST).c
78 86
79EXHEADER= 87EXHEADER=
80HEADER= $(EXHEADER) 88HEADER= $(EXHEADER)
@@ -82,7 +90,7 @@ HEADER= $(EXHEADER)
82ALL= $(GENERAL) $(SRC) $(HEADER) 90ALL= $(GENERAL) $(SRC) $(HEADER)
83 91
84top: 92top:
85 (cd ..; $(MAKE) DIRS=$(DIR) all) 93 (cd ..; $(MAKE) DIRS=$(DIR) TESTS=$(TESTS) all)
86 94
87all: exe 95all: exe
88 96
@@ -101,16 +109,25 @@ install:
101tags: 109tags:
102 ctags $(SRC) 110 ctags $(SRC)
103 111
104tests: exe apps \ 112tests: exe apps $(TESTS)
113
114apps:
115 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
116
117alltests:
118 (LIBPATH="`cd ..; pwd`"; LD_LIBRARY_PATH=$$LIBPATH; SHLIB_PATH=$$LIBPATH; \
119 export LD_LIBRARY_PATH SHLIB_PATH LIBPATH; \
120 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' alltests.chooser)
121alltests.chooser: \
105 test_des test_idea test_sha test_md4 test_md5 test_hmac \ 122 test_des test_idea test_sha test_md4 test_md5 test_hmac \
106 test_md2 test_mdc2 \ 123 test_md2 test_mdc2 \
107 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast \ 124 test_rmd test_rc2 test_rc4 test_rc5 test_bf test_cast test_rd \
108 test_rand test_bn test_enc test_x509 test_rsa test_crl test_sid \ 125 test_rand test_bn test_ec test_enc test_x509 test_rsa test_crl test_sid \
109 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \ 126 test_gen test_req test_pkcs7 test_verify test_dh test_dsa \
110 test_ss test_ca test_engine test_ssl 127 test_ss test_ca test_engine test_evp test_ssl
111 128
112apps: 129test_evp:
113 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all) 130 ./$(EVPTEST) evptests.txt
114 131
115test_des: 132test_des:
116 ./$(DESTEST) 133 ./$(DESTEST)
@@ -196,6 +213,10 @@ test_bn:
196 @echo 'test a^b%c implementations' 213 @echo 'test a^b%c implementations'
197 ./$(EXPTEST) 214 ./$(EXPTEST)
198 215
216test_ec:
217 @echo 'test elliptic curves'
218 ./$(ECTEST)
219
199test_verify: 220test_verify:
200 @echo "The following command should have some OK's and some failures" 221 @echo "The following command should have some OK's and some failures"
201 @echo "There are definitly a few expired certificates" 222 @echo "There are definitly a few expired certificates"
@@ -230,6 +251,10 @@ test_ca:
230 @echo "Generate and certify a test certificate via the 'ca' program" 251 @echo "Generate and certify a test certificate via the 'ca' program"
231 @sh ./testca 252 @sh ./testca
232 253
254test_rd: #$(RDTEST)
255# @echo "test Rijndael"
256# ./$(RDTEST)
257
233lint: 258lint:
234 lint -DLINT $(INCLUDES) $(SRC)>fluff 259 lint -DLINT $(INCLUDES) $(SRC)>fluff
235 260
@@ -241,7 +266,7 @@ dclean:
241 mv -f Makefile.new $(MAKEFILE) 266 mv -f Makefile.new $(MAKEFILE)
242 267
243clean: 268clean:
244 rm -f .rnd tmp.bntest tmp.bctest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log 269 rm -f .rnd tmp.bntest tmp.bctest *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss *.srl log
245 270
246$(DLIBSSL): 271$(DLIBSSL):
247 (cd ../ssl; $(MAKE)) 272 (cd ../ssl; $(MAKE))
@@ -255,6 +280,9 @@ $(RSATEST): $(RSATEST).o $(DLIBCRYPTO)
255$(BNTEST): $(BNTEST).o $(DLIBCRYPTO) 280$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
256 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 281 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257 282
283$(ECTEST): $(ECTEST).o $(DLIBCRYPTO)
284 $(CC) -o $(ECTEST) $(CFLAGS) $(ECTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
285
258$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO) 286$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 287 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260 288
@@ -316,126 +344,198 @@ $(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
316 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 344 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
317 345
318$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO) 346$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
319 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS) 347 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBKRB5) $(LIBCRYPTO) $(EX_LIBS)
320 348
321$(ENGINETEST): $(ENGINETEST).o $(DLIBCRYPTO) 349$(ENGINETEST): $(ENGINETEST).o $(DLIBCRYPTO)
322 $(CC) -o $(ENGINETEST) $(CFLAGS) $(ENGINETEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS) 350 $(CC) -o $(ENGINETEST) $(CFLAGS) $(ENGINETEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
323 351
352$(EVPTEST): $(EVPTEST).o $(DLIBCRYPTO)
353 $(CC) -o $(EVPTEST) $(CFLAGS) $(EVPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
354
355#$(RDTEST).o: $(RDTEST).c
356# $(CC) -c $(CFLAGS) -DINTERMEDIATE_VALUE_KAT -DTRACE_KAT_MCT $(RDTEST).c
357
358#$(RDTEST): $(RDTEST).o $(DLIBCRYPTO)
359# $(CC) -o $(RDTEST) $(CFLAGS) $(RDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
360
324# DO NOT DELETE THIS LINE -- make depend depends on it. 361# DO NOT DELETE THIS LINE -- make depend depends on it.
325 362
326bftest.o: ../include/openssl/blowfish.h 363bftest.o: ../include/openssl/blowfish.h ../include/openssl/e_os2.h
327bntest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 364bftest.o: ../include/openssl/opensslconf.h bftest.c
328bntest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 365bntest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
329bntest.o: ../include/openssl/buffer.h ../include/openssl/cast.h 366bntest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
330bntest.o: ../include/openssl/crypto.h ../include/openssl/des.h 367bntest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
331bntest.o: ../include/openssl/dh.h ../include/openssl/dsa.h 368bntest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
332bntest.o: ../include/openssl/e_os.h ../include/openssl/e_os2.h
333bntest.o: ../include/openssl/err.h ../include/openssl/evp.h 369bntest.o: ../include/openssl/err.h ../include/openssl/evp.h
334bntest.o: ../include/openssl/idea.h ../include/openssl/lhash.h 370bntest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
335bntest.o: ../include/openssl/md2.h ../include/openssl/md4.h 371bntest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
336bntest.o: ../include/openssl/md5.h ../include/openssl/mdc2.h 372bntest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
337bntest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
338bntest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
339bntest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h 373bntest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
340bntest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
341bntest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
342bntest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 374bntest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
343bntest.o: ../include/openssl/sha.h ../include/openssl/stack.h 375bntest.o: ../include/openssl/sha.h ../include/openssl/stack.h
344bntest.o: ../include/openssl/symhacks.h ../include/openssl/x509.h 376bntest.o: ../include/openssl/symhacks.h ../include/openssl/x509.h
345bntest.o: ../include/openssl/x509_vfy.h 377bntest.o: ../include/openssl/x509_vfy.h bntest.c
346casttest.o: ../include/openssl/cast.h 378casttest.o: ../include/openssl/cast.h casttest.c
347destest.o: ../include/openssl/des.h ../include/openssl/e_os2.h 379destest.o: ../include/openssl/crypto.h ../include/openssl/des.h
348destest.o: ../include/openssl/opensslconf.h 380destest.o: ../include/openssl/des_old.h ../include/openssl/e_os2.h
381destest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
382destest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
383destest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
384destest.o: ../include/openssl/ui_compat.h destest.c
349dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h 385dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h
350dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 386dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
351dhtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h 387dhtest.o: ../include/openssl/e_os2.h ../include/openssl/err.h
388dhtest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
389dhtest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
352dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h 390dhtest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
353dhtest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 391dhtest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h dhtest.c
354dsatest.o: ../include/openssl/bio.h ../include/openssl/bn.h 392dsatest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
355dsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h 393dsatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
356dsatest.o: ../include/openssl/dsa.h ../include/openssl/err.h 394dsatest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
357dsatest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 395dsatest.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
358dsatest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 396dsatest.o: ../include/openssl/err.h ../include/openssl/lhash.h
359dsatest.o: ../include/openssl/safestack.h ../include/openssl/stack.h 397dsatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
360dsatest.o: ../include/openssl/symhacks.h 398dsatest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
399dsatest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
400dsatest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
401dsatest.o: ../include/openssl/ui.h dsatest.c
402ectest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
403ectest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
404ectest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
405ectest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
406ectest.o: ../include/openssl/engine.h ../include/openssl/err.h
407ectest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
408ectest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
409ectest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
410ectest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
411ectest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h ectest.c
361enginetest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 412enginetest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
362enginetest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 413enginetest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
363enginetest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 414enginetest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
364enginetest.o: ../include/openssl/des.h ../include/openssl/dh.h
365enginetest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 415enginetest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
366enginetest.o: ../include/openssl/engine.h ../include/openssl/err.h 416enginetest.o: ../include/openssl/engine.h ../include/openssl/err.h
367enginetest.o: ../include/openssl/evp.h ../include/openssl/idea.h 417enginetest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
368enginetest.o: ../include/openssl/lhash.h ../include/openssl/md2.h 418enginetest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
369enginetest.o: ../include/openssl/md4.h ../include/openssl/md5.h 419enginetest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
370enginetest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 420enginetest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
371enginetest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h 421enginetest.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
372enginetest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 422enginetest.o: enginetest.c
373enginetest.o: ../include/openssl/rc2.h ../include/openssl/rc4.h 423evp_test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
374enginetest.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h 424evp_test.o: ../include/openssl/bn.h ../include/openssl/conf.h
375enginetest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 425evp_test.o: ../include/openssl/crypto.h ../include/openssl/dh.h
376enginetest.o: ../include/openssl/sha.h ../include/openssl/stack.h 426evp_test.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
377enginetest.o: ../include/openssl/symhacks.h 427evp_test.o: ../include/openssl/engine.h ../include/openssl/err.h
428evp_test.o: ../include/openssl/evp.h ../include/openssl/lhash.h
429evp_test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
430evp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
431evp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
432evp_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
433evp_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
434evp_test.o: ../include/openssl/ui.h evp_test.c
378exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h 435exptest.o: ../include/openssl/bio.h ../include/openssl/bn.h
379exptest.o: ../include/openssl/crypto.h ../include/openssl/err.h 436exptest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
380exptest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 437exptest.o: ../include/openssl/err.h ../include/openssl/lhash.h
381exptest.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 438exptest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
439exptest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
382exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h 440exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
383exptest.o: ../include/openssl/symhacks.h 441exptest.o: ../include/openssl/symhacks.h exptest.c
384hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 442hmactest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
385hmactest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 443hmactest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
386hmactest.o: ../include/openssl/cast.h ../include/openssl/crypto.h 444hmactest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
387hmactest.o: ../include/openssl/des.h ../include/openssl/dh.h 445hmactest.o: ../include/openssl/hmac.h ../include/openssl/md5.h
388hmactest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h 446hmactest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
389hmactest.o: ../include/openssl/evp.h ../include/openssl/hmac.h 447hmactest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
390hmactest.o: ../include/openssl/idea.h ../include/openssl/md2.h 448hmactest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
391hmactest.o: ../include/openssl/md4.h ../include/openssl/md5.h 449hmactest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h hmactest.c
392hmactest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
393hmactest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
394hmactest.o: ../include/openssl/opensslv.h ../include/openssl/rc2.h
395hmactest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
396hmactest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
397hmactest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
398hmactest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
399ideatest.o: ../include/openssl/idea.h ../include/openssl/opensslconf.h 450ideatest.o: ../include/openssl/idea.h ../include/openssl/opensslconf.h
400md2test.o: ../include/openssl/md2.h ../include/openssl/opensslconf.h 451ideatest.o: ideatest.c
401md4test.o: ../include/openssl/md4.h 452md2test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
402md5test.o: ../include/openssl/md5.h 453md2test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
403mdc2test.o: ../include/openssl/des.h ../include/openssl/e_os2.h 454md2test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
404mdc2test.o: ../include/openssl/mdc2.h ../include/openssl/opensslconf.h 455md2test.o: ../include/openssl/md2.h ../include/openssl/obj_mac.h
405randtest.o: ../include/openssl/rand.h 456md2test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
406rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h 457md2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
407rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h 458md2test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
408rc5test.o: ../include/openssl/rc5.h 459md2test.o: ../include/openssl/symhacks.h md2test.c
409rmdtest.o: ../include/openssl/ripemd.h 460md4test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
410rsa_test.o: ../include/openssl/bio.h ../include/openssl/bn.h 461md4test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
411rsa_test.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 462md4test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
412rsa_test.o: ../include/openssl/e_os2.h ../include/openssl/err.h 463md4test.o: ../include/openssl/md4.h ../include/openssl/obj_mac.h
413rsa_test.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 464md4test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
414rsa_test.o: ../include/openssl/opensslv.h ../include/openssl/rand.h 465md4test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
466md4test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
467md4test.o: ../include/openssl/symhacks.h md4test.c
468md5test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
469md5test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
470md5test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
471md5test.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
472md5test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
473md5test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
474md5test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
475md5test.o: ../include/openssl/symhacks.h md5test.c
476mdc2test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
477mdc2test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
478mdc2test.o: ../include/openssl/des.h ../include/openssl/des_old.h
479mdc2test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
480mdc2test.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
481mdc2test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
482mdc2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
483mdc2test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
484mdc2test.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
485mdc2test.o: ../include/openssl/ui_compat.h mdc2test.c
486randtest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h randtest.c
487rc2test.o: ../include/openssl/opensslconf.h ../include/openssl/rc2.h rc2test.c
488rc4test.o: ../include/openssl/opensslconf.h ../include/openssl/rc4.h rc4test.c
489rc5test.o: ../include/openssl/rc5.h rc5test.c
490rmdtest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
491rmdtest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
492rmdtest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
493rmdtest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
494rmdtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
495rmdtest.o: ../include/openssl/ossl_typ.h ../include/openssl/ripemd.h
496rmdtest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
497rmdtest.o: ../include/openssl/symhacks.h rmdtest.c
498rsa_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
499rsa_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
500rsa_test.o: ../include/openssl/dh.h ../include/openssl/dsa.h
501rsa_test.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
502rsa_test.o: ../include/openssl/err.h ../include/openssl/lhash.h
503rsa_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
504rsa_test.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
415rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h 505rsa_test.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
416rsa_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 506rsa_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
417sha1test.o: ../include/openssl/sha.h 507rsa_test.o: ../include/openssl/ui.h rsa_test.c
418shatest.o: ../include/openssl/sha.h 508sha1test.o: ../include/openssl/asn1.h ../include/openssl/bio.h
419ssltest.o: ../include/openssl/asn1.h ../include/openssl/bio.h 509sha1test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
420ssltest.o: ../include/openssl/blowfish.h ../include/openssl/bn.h 510sha1test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
421ssltest.o: ../include/openssl/buffer.h ../include/openssl/cast.h 511sha1test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
512sha1test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
513sha1test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
514sha1test.o: ../include/openssl/sha.h ../include/openssl/stack.h
515sha1test.o: ../include/openssl/symhacks.h sha1test.c
516shatest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
517shatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
518shatest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
519shatest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
520shatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
521shatest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
522shatest.o: ../include/openssl/sha.h ../include/openssl/stack.h
523shatest.o: ../include/openssl/symhacks.h shatest.c
524ssltest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
525ssltest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
422ssltest.o: ../include/openssl/comp.h ../include/openssl/crypto.h 526ssltest.o: ../include/openssl/comp.h ../include/openssl/crypto.h
423ssltest.o: ../include/openssl/des.h ../include/openssl/dh.h 527ssltest.o: ../include/openssl/dh.h ../include/openssl/dsa.h
424ssltest.o: ../include/openssl/dsa.h ../include/openssl/e_os.h 528ssltest.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
425ssltest.o: ../include/openssl/e_os2.h ../include/openssl/err.h 529ssltest.o: ../include/openssl/err.h ../include/openssl/evp.h
426ssltest.o: ../include/openssl/evp.h ../include/openssl/idea.h 530ssltest.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
427ssltest.o: ../include/openssl/lhash.h ../include/openssl/md2.h 531ssltest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
428ssltest.o: ../include/openssl/md4.h ../include/openssl/md5.h 532ssltest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
429ssltest.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h 533ssltest.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
430ssltest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
431ssltest.o: ../include/openssl/opensslv.h ../include/openssl/pem.h
432ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h 534ssltest.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
433ssltest.o: ../include/openssl/rand.h ../include/openssl/rc2.h 535ssltest.o: ../include/openssl/rand.h ../include/openssl/rsa.h
434ssltest.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
435ssltest.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
436ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h 536ssltest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
437ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h 537ssltest.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
438ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h 538ssltest.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
439ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 539ssltest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
440ssltest.o: ../include/openssl/tls1.h ../include/openssl/x509.h 540ssltest.o: ../include/openssl/tls1.h ../include/openssl/ui.h
441ssltest.o: ../include/openssl/x509_vfy.h 541ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.c
diff --git a/src/lib/libssl/test/maketests.com b/src/lib/libssl/test/maketests.com
index 135e0bfeb9..e0be3dd43b 100644
--- a/src/lib/libssl/test/maketests.com
+++ b/src/lib/libssl/test/maketests.com
@@ -143,11 +143,12 @@ $ GOSUB CHECK_OPT_FILE
143$! 143$!
144$! Define The TEST Files. 144$! Define The TEST Files.
145$! 145$!
146$ TEST_FILES = "BNTEST,IDEATEST,MD2TEST,MD4TEST,MD5TEST,HMACTEST,"+ - 146$ TEST_FILES = "BNTEST,ECTEST,IDEATEST,MD2TEST,MD4TEST,MD5TEST,HMACTEST,"+ -
147 "RC2TEST,RC4TEST,RC5TEST,"+ - 147 "RC2TEST,RC4TEST,RC5TEST,"+ -
148 "DESTEST,SHATEST,SHA1TEST,MDC2TEST,RMDTEST,"+ - 148 "DESTEST,SHATEST,SHA1TEST,MDC2TEST,RMDTEST,"+ -
149 "RANDTEST,DHTEST,"+ - 149 "RANDTEST,DHTEST,ENGINETEST,"+ -
150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST" 150 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST,"+ -
151 "EVP_TEST"
151$ TCPIP_PROGRAMS = ",," 152$ TCPIP_PROGRAMS = ",,"
152$ IF COMPILER .EQS. "VAXC" THEN - 153$ IF COMPILER .EQS. "VAXC" THEN -
153 TCPIP_PROGRAMS = ",SSLTEST," 154 TCPIP_PROGRAMS = ",SSLTEST,"
@@ -514,6 +515,7 @@ $ CHECK_OPTIONS:
514$! 515$!
515$! Check To See If P1 Is Blank. 516$! Check To See If P1 Is Blank.
516$! 517$!
518$ P1 = "NORSAREF"
517$ IF (P1.EQS."NORSAREF") 519$ IF (P1.EQS."NORSAREF")
518$ THEN 520$ THEN
519$! 521$!
@@ -729,31 +731,7 @@ $ ENDIF
729$! 731$!
730$! Set Up Initial CC Definitions, Possibly With User Ones 732$! Set Up Initial CC Definitions, Possibly With User Ones
731$! 733$!
732$ CCDEFS = "VMS=1,TCPIP_TYPE_''P4'" 734$ CCDEFS = "TCPIP_TYPE_''P4'"
733$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
734$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
735$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
736$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
737$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
738$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
739$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
740$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
741$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
742$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
743$ IF F$TRNLNM("OPENSSL_NO_DES")
744$ THEN
745$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
746$ ELSE
747$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
748$ ENDIF
749$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
750$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
751$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
752$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
753$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
754$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
755$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
756$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
757$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 735$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
758$ CCEXTRAFLAGS = "" 736$ CCEXTRAFLAGS = ""
759$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 737$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -785,7 +763,8 @@ $ CC = "CC"
785$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" - 763$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
786 THEN CC = "CC/DECC" 764 THEN CC = "CC/DECC"
787$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 765$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
788 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS 766 "/NOLIST/PREFIX=ALL" + -
767 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
789$! 768$!
790$! Define The Linker Options File Name. 769$! Define The Linker Options File Name.
791$! 770$!
@@ -817,7 +796,8 @@ $ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
817$ EXIT 796$ EXIT
818$ ENDIF 797$ ENDIF
819$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 798$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
820$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 799$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
800 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
821$ CCDEFS = CCDEFS + ",""VAXC""" 801$ CCDEFS = CCDEFS + ",""VAXC"""
822$! 802$!
823$! Define <sys> As SYS$COMMON:[SYSLIB] 803$! Define <sys> As SYS$COMMON:[SYSLIB]
@@ -847,7 +827,8 @@ $ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
847$! 827$!
848$! Use GNU C... 828$! Use GNU C...
849$! 829$!
850$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS 830$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
831 "/INCLUDE=(SYS$DISK:[-])" + CCEXTRAFLAGS
851$! 832$!
852$! Define The Linker Options File Name. 833$! Define The Linker Options File Name.
853$! 834$!
@@ -1050,6 +1031,7 @@ $!
1050$! Save directory information 1031$! Save directory information
1051$! 1032$!
1052$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;" 1033$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1034$ __HERE = F$EDIT(__HERE,"UPCASE")
1053$ __TOP = __HERE - "TEST]" 1035$ __TOP = __HERE - "TEST]"
1054$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]" 1036$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1055$! 1037$!
diff --git a/src/lib/libssl/test/tests.com b/src/lib/libssl/test/tests.com
index df8f46e75d..07a3c7f16d 100644
--- a/src/lib/libssl/test/tests.com
+++ b/src/lib/libssl/test/tests.com
@@ -21,14 +21,15 @@ $ else
21$ tests := - 21$ tests := -
22 test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,- 22 test_des,test_idea,test_sha,test_md4,test_md5,test_hmac,-
23 test_md2,test_mdc2,- 23 test_md2,test_mdc2,-
24 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,- 24 test_rmd,test_rc2,test_rc4,test_rc5,test_bf,test_cast,test_rd,-
25 test_rand,test_bn,test_enc,test_x509,test_rsa,test_crl,test_sid,- 25 test_rand,test_bn,test_ec,test_enc,test_x509,test_rsa,test_crl,test_sid,-
26 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,- 26 test_gen,test_req,test_pkcs7,test_verify,test_dh,test_dsa,-
27 test_ss,test_ca,test_ssl 27 test_ss,test_ca,test_engine,test_ssl,test_evp
28$ endif 28$ endif
29$ tests = f$edit(tests,"COLLAPSE") 29$ tests = f$edit(tests,"COLLAPSE")
30$ 30$
31$ BNTEST := bntest 31$ BNTEST := bntest
32$ ECTEST := ectest
32$ EXPTEST := exptest 33$ EXPTEST := exptest
33$ IDEATEST := ideatest 34$ IDEATEST := ideatest
34$ SHATEST := shatest 35$ SHATEST := shatest
@@ -51,6 +52,8 @@ $ DSATEST := dsatest
51$ METHTEST := methtest 52$ METHTEST := methtest
52$ SSLTEST := ssltest 53$ SSLTEST := ssltest
53$ RSATEST := rsa_test 54$ RSATEST := rsa_test
55$ ENGINETEST := enginetest
56$ EVPTEST := evp_test
54$ 57$
55$ tests_i = 0 58$ tests_i = 0
56$ loop_tests: 59$ loop_tests:
@@ -60,6 +63,9 @@ $ if tests_e .eqs. "," then goto exit
60$ gosub 'tests_e' 63$ gosub 'tests_e'
61$ goto loop_tests 64$ goto loop_tests
62$ 65$
66$ test_evp:
67$ mcr 'texe_dir''evptest' evptests.txt
68$ return
63$ test_des: 69$ test_des:
64$ mcr 'texe_dir''destest' 70$ mcr 'texe_dir''destest'
65$ return 71$ return
@@ -157,7 +163,7 @@ RECORD
157$ create/fdl=bntest-vms.fdl bntest-vms.sh 163$ create/fdl=bntest-vms.fdl bntest-vms.sh
158$ open/append foo bntest-vms.sh 164$ open/append foo bntest-vms.sh
159$ type/output=foo: sys$input: 165$ type/output=foo: sys$input:
160<< __FOO__ bc | perl -e 'while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} print STDERR "."; $i++;} print STDERR "\n$i tests passed\n"' 166<< __FOO__ sh -c "`sh ./bctest`" | perl -e '$i=0; while (<STDIN>) {if (/^test (.*)/) {print STDERR "\nverify $1";} elsif (!/^0$/) {die "\nFailed! bc: $_";} else {print STDERR "."; $i++;}} print STDERR "\n$i tests passed\n"'
161$ define/user sys$output bntest-vms.tmp 167$ define/user sys$output bntest-vms.tmp
162$ mcr 'texe_dir''bntest' 168$ mcr 'texe_dir''bntest'
163$ copy bntest-vms.tmp foo: 169$ copy bntest-vms.tmp foo:
@@ -165,12 +171,17 @@ $ delete bntest-vms.tmp;*
165$ type/output=foo: sys$input: 171$ type/output=foo: sys$input:
166__FOO__ 172__FOO__
167$ close foo 173$ close foo
168$ write sys$output "-- copy the [.test]bntest-vms.sh file to a Unix system and run it" 174$ write sys$output "-- copy the [.test]bntest-vms.sh and [.test]bctest files to a Unix system and"
169$ write sys$output "-- through sh or bash to verify that the bignum operations went well." 175$ write sys$output "-- run bntest-vms.sh through sh or bash to verify that the bignum operations"
176$ write sys$output "-- went well."
170$ write sys$output "" 177$ write sys$output ""
171$ write sys$output "test a^b%c implementations" 178$ write sys$output "test a^b%c implementations"
172$ mcr 'texe_dir''exptest' 179$ mcr 'texe_dir''exptest'
173$ return 180$ return
181$ test_ec:
182$ write sys$output "test elliptic curves"
183$ mcr 'texe_dir''ectest'
184$ return
174$ test_verify: 185$ test_verify:
175$ write sys$output "The following command should have some OK's and some failures" 186$ write sys$output "The following command should have some OK's and some failures"
176$ write sys$output "There are definitly a few expired certificates" 187$ write sys$output "There are definitly a few expired certificates"
@@ -201,6 +212,10 @@ $ test_ss:
201$ write sys$output "Generate and certify a test certificate" 212$ write sys$output "Generate and certify a test certificate"
202$ @testss.com 213$ @testss.com
203$ return 214$ return
215$ test_engine:
216$ write sys$output "Manipulate the ENGINE structures"
217$ mcr 'texe_dir''enginetest'
218$ return
204$ test_ssl: 219$ test_ssl:
205$ write sys$output "test SSL protocol" 220$ write sys$output "test SSL protocol"
206$ gosub maybe_test_ss 221$ gosub maybe_test_ss
@@ -220,6 +235,10 @@ $ write sys$output "Generate and certify a test certificate via the 'ca' pro
220$ @testca.com 235$ @testca.com
221$ endif 236$ endif
222$ return 237$ return
238$ test_rd:
239$ write sys$output "test Rijndael"
240$ !mcr 'texe_dir''rdtest'
241$ return
223$ 242$
224$ 243$
225$ exit: 244$ exit:
diff --git a/src/lib/libssl/test/testss b/src/lib/libssl/test/testss
index da62997a5f..8d3557f356 100644
--- a/src/lib/libssl/test/testss
+++ b/src/lib/libssl/test/testss
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2 2
3digest='-mdc2' 3digest='-md5'
4reqcmd="../apps/openssl req" 4reqcmd="../apps/openssl req"
5x509cmd="../apps/openssl x509 $digest" 5x509cmd="../apps/openssl x509 $digest"
6verifycmd="../apps/openssl verify" 6verifycmd="../apps/openssl verify"
@@ -19,7 +19,16 @@ Ucert="certU.ss"
19 19
20echo 20echo
21echo "make a certificate request using 'req'" 21echo "make a certificate request using 'req'"
22$reqcmd -config $CAconf -out $CAreq -keyout $CAkey -new #>err.ss 22
23echo "string to make the random number generator think it has entropy" >> ./.rnd
24
25if ../apps/openssl no-rsa; then
26 req_new='-newkey dsa:../apps/dsa512.pem'
27else
28 req_new='-new'
29fi
30
31$reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss
23if [ $? != 0 ]; then 32if [ $? != 0 ]; then
24 echo "error using 'req' to generate a certificate request" 33 echo "error using 'req' to generate a certificate request"
25 exit 1 34 exit 1
@@ -60,7 +69,7 @@ fi
60 69
61echo 70echo
62echo "make another certificate request using 'req'" 71echo "make another certificate request using 'req'"
63$reqcmd -config $Uconf -out $Ureq -keyout $Ukey -new >err.ss 72$reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss
64if [ $? != 0 ]; then 73if [ $? != 0 ]; then
65 echo "error using 'req' to generate a certificate request" 74 echo "error using 'req' to generate a certificate request"
66 exit 1 75 exit 1
diff --git a/src/lib/libssl/test/testssl b/src/lib/libssl/test/testssl
index a88e290c57..ba5e41c861 100644
--- a/src/lib/libssl/test/testssl
+++ b/src/lib/libssl/test/testssl
@@ -1,81 +1,137 @@
1#!/bin/sh 1#!/bin/sh
2 2
3if [ "$1" = "" ]; then
4 key=../apps/server.pem
5else
6 key="$1"
7fi
8if [ "$2" = "" ]; then
9 cert=../apps/server.pem
10else
11 cert="$2"
12fi
13ssltest="./ssltest -key $key -cert $cert -c_key $key -c_cert $cert"
14
15if ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then
16 dsa_cert=YES
17else
18 dsa_cert=NO
19fi
20
21if [ "$3" = "" ]; then
22 CA="-CApath ../certs"
23else
24 CA="-CAfile $3"
25fi
26
27if [ "$4" = "" ]; then
28 extra=""
29else
30 extra="$4"
31fi
32
33#############################################################################
34
3echo test sslv2 35echo test sslv2
4./ssltest -ssl2 || exit 1 36$ssltest -ssl2 $extra || exit 1
5 37
6echo test sslv2 with server authentication 38echo test sslv2 with server authentication
7./ssltest -ssl2 -server_auth -CApath ../certs || exit 1 39$ssltest -ssl2 -server_auth $CA $extra || exit 1
8 40
9echo test sslv2 with client authentication 41if [ $dsa_cert = NO ]; then
10./ssltest -ssl2 -client_auth -CApath ../certs || exit 1 42 echo test sslv2 with client authentication
43 $ssltest -ssl2 -client_auth $CA $extra || exit 1
11 44
12echo test sslv2 with both client and server authentication 45 echo test sslv2 with both client and server authentication
13./ssltest -ssl2 -server_auth -client_auth -CApath ../certs || exit 1 46 $ssltest -ssl2 -server_auth -client_auth $CA $extra || exit 1
47fi
14 48
15echo test sslv3 49echo test sslv3
16./ssltest -ssl3 || exit 1 50$ssltest -ssl3 $extra || exit 1
17 51
18echo test sslv3 with server authentication 52echo test sslv3 with server authentication
19./ssltest -ssl3 -server_auth -CApath ../certs || exit 1 53$ssltest -ssl3 -server_auth $CA $extra || exit 1
20 54
21echo test sslv3 with client authentication 55echo test sslv3 with client authentication
22./ssltest -ssl3 -client_auth -CApath ../certs || exit 1 56$ssltest -ssl3 -client_auth $CA $extra || exit 1
23 57
24echo test sslv3 with both client and server authentication 58echo test sslv3 with both client and server authentication
25./ssltest -ssl3 -server_auth -client_auth -CApath ../certs || exit 1 59$ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1
26 60
27echo test sslv2/sslv3 61echo test sslv2/sslv3
28./ssltest || exit 1 62$ssltest $extra || exit 1
29 63
30echo test sslv2/sslv3 with server authentication 64echo test sslv2/sslv3 with server authentication
31./ssltest -server_auth -CApath ../certs || exit 1 65$ssltest -server_auth $CA $extra || exit 1
32 66
33echo test sslv2/sslv3 with client authentication 67echo test sslv2/sslv3 with client authentication
34./ssltest -client_auth -CApath ../certs || exit 1 68$ssltest -client_auth $CA $extra || exit 1
35 69
36echo test sslv2/sslv3 with both client and server authentication 70echo test sslv2/sslv3 with both client and server authentication
37./ssltest -server_auth -client_auth -CApath ../certs || exit 1 71$ssltest -server_auth -client_auth $CA $extra || exit 1
38 72
39echo test sslv2 via BIO pair 73echo test sslv2 via BIO pair
40./ssltest -bio_pair -ssl2 || exit 1 74$ssltest -bio_pair -ssl2 $extra || exit 1
41 75
42echo test sslv2 with server authentication via BIO pair 76echo test sslv2 with server authentication via BIO pair
43./ssltest -bio_pair -ssl2 -server_auth -CApath ../certs || exit 1 77$ssltest -bio_pair -ssl2 -server_auth $CA $extra || exit 1
44 78
45echo test sslv2 with client authentication via BIO pair 79if [ $dsa_cert = NO ]; then
46./ssltest -bio_pair -ssl2 -client_auth -CApath ../certs || exit 1 80 echo test sslv2 with client authentication via BIO pair
81 $ssltest -bio_pair -ssl2 -client_auth $CA $extra || exit 1
47 82
48echo test sslv2 with both client and server authentication via BIO pair 83 echo test sslv2 with both client and server authentication via BIO pair
49./ssltest -bio_pair -ssl2 -server_auth -client_auth -CApath ../certs || exit 1 84 $ssltest -bio_pair -ssl2 -server_auth -client_auth $CA $extra || exit 1
85fi
50 86
51echo test sslv3 via BIO pair 87echo test sslv3 via BIO pair
52./ssltest -bio_pair -ssl3 || exit 1 88$ssltest -bio_pair -ssl3 $extra || exit 1
53 89
54echo test sslv3 with server authentication via BIO pair 90echo test sslv3 with server authentication via BIO pair
55./ssltest -bio_pair -ssl3 -server_auth -CApath ../certs || exit 1 91$ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1
56 92
57echo test sslv3 with client authentication via BIO pair 93echo test sslv3 with client authentication via BIO pair
58./ssltest -bio_pair -ssl3 -client_auth -CApath ../certs || exit 1 94$ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1
59 95
60echo test sslv3 with both client and server authentication via BIO pair 96echo test sslv3 with both client and server authentication via BIO pair
61./ssltest -bio_pair -ssl3 -server_auth -client_auth -CApath ../certs || exit 1 97$ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1
62 98
63echo test sslv2/sslv3 via BIO pair 99echo test sslv2/sslv3 via BIO pair
64./ssltest || exit 1 100$ssltest $extra || exit 1
65 101
66echo test sslv2/sslv3 w/o DHE via BIO pair 102if [ $dsa_cert = NO ]; then
67./ssltest -bio_pair -no_dhe || exit 1 103 echo test sslv2/sslv3 w/o DHE via BIO pair
104 $ssltest -bio_pair -no_dhe $extra || exit 1
105fi
68 106
69echo test sslv2/sslv3 with 1024bit DHE 107echo test sslv2/sslv3 with 1024bit DHE via BIO pair
70./ssltest -bio_pair -dhe1024 -v || exit 1 108$ssltest -bio_pair -dhe1024dsa -v $extra || exit 1
71 109
72echo test sslv2/sslv3 with server authentication 110echo test sslv2/sslv3 with server authentication
73./ssltest -bio_pair -server_auth -CApath ../certs || exit 1 111$ssltest -bio_pair -server_auth $CA $extra || exit 1
74 112
75echo test sslv2/sslv3 with client authentication via BIO pair 113echo test sslv2/sslv3 with client authentication via BIO pair
76./ssltest -bio_pair -client_auth -CApath ../certs || exit 1 114$ssltest -bio_pair -client_auth $CA $extra || exit 1
77 115
78echo test sslv2/sslv3 with both client and server authentication via BIO pair 116echo test sslv2/sslv3 with both client and server authentication via BIO pair
79./ssltest -bio_pair -server_auth -client_auth -CApath ../certs || exit 1 117$ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1
118
119echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify
120$ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1
121
122#############################################################################
123
124echo test tls1 with 1024bit anonymous DH, multiple handshakes
125$ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1
126
127if ../apps/openssl no-rsa; then
128 echo skipping RSA tests
129else
130 echo test tls1 with 1024bit RSA, no DHE, multiple handshakes
131 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1
132
133 echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
134 ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
135fi
80 136
81exit 0 137exit 0
diff --git a/src/lib/libssl/test/tmp.bctest b/src/lib/libssl/test/tmp.bctest
new file mode 100644
index 0000000000..aa47d0d46d
--- /dev/null
+++ b/src/lib/libssl/test/tmp.bctest
@@ -0,0 +1,2 @@
10
20
diff --git a/src/lib/libssl/tls1.h b/src/lib/libssl/tls1.h
index cf92ae034f..88ec5fb527 100644
--- a/src/lib/libssl/tls1.h
+++ b/src/lib/libssl/tls1.h
@@ -96,6 +96,22 @@ extern "C" {
96#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 96#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065
97#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 97#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066
98 98
99 /* AES ciphersuites from draft ietf-tls-ciphersuite-03.txt */
100
101#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F
102#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030
103#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031
104#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032
105#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033
106#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034
107
108#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035
109#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036
110#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037
111#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038
112#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039
113#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A
114
99/* XXX 115/* XXX
100 * Inconsistency alert: 116 * Inconsistency alert:
101 * The OpenSSL names of ciphers with ephemeral DH here include the string 117 * The OpenSSL names of ciphers with ephemeral DH here include the string
@@ -110,6 +126,20 @@ extern "C" {
110#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" 126#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA"
111#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" 127#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA"
112#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" 128#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"
129 /* AES ciphersuites from draft-ietf-tls-ciphersuite-06.txt */
130#define TLS1_TXT_RSA_WITH_AES_128_SHA "AESdraft128-SHA"
131#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AESdraft128-SHA"
132#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AESdraft128-SHA"
133#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AESdraft128-SHA"
134#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AESdraft128-SHA"
135#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AESdraft128-SHA"
136
137#define TLS1_TXT_RSA_WITH_AES_256_SHA "AESdraft256-SHA"
138#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AESdraft256-SHA"
139#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AESdraft256-SHA"
140#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AESdraft256-SHA"
141#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AESdraft256-SHA"
142#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AESdraft256-SHA"
113 143
114 144
115#define TLS_CT_RSA_SIGN 1 145#define TLS_CT_RSA_SIGN 1